function redir(value){
  window.location.href=value;
}

function closewin () {
    self.close();
}

function refresh () {
    self.location.reload();
}

function preview (value) {
    AB=window.open(value, '', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1000, height=700');
    AB.focus();
}

//Show and hide an element
function ShowHide(id) {
	var cur = document.getElementById(id).style;
	if (cur.display != "none") {
		cur.display = "none";
	}
  else {
		cur.display = "inline";
	}
	//return true;
}

function showhide(system, obj) {
	var cur = document.getElementById(system).style;
	if (cur.display == "block") {
		cur.display = "none";
	} else {
		cur.display = "block";	
	}
	return true;
}

function isNum(str){
	for (var i = 0; i < str.length; i++) {
		var ch = str[i];
		if ((ch < "0" || ch > "9") && ch != "." && ch != "+" && ch != "-" && ch != "e" && ch != "E") return false;
    }
	return true;
}

function setFocus(name) {
	var focusField = document.getElementById(name);
	focusField.focus();
}



function checkUrl(){
	var link_url = document.getElementById('link_url').value;
	window.open(link_url,'url');
}



//Open a new window to send a message
function MessageWindow (value) {
    AB=window.open(value, '', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, top=200, left=200, width=500, height=420');
    AB.focus();
}

function confirm_delete(value){
  c=confirm("The following listing will be deleted:\n\n"+value);
  if(c){
    return true;
  }
  else{
    return false;
  }
}

//Change innerHTML of an element
function changeInner(id, value){
  document.getElementById(id).innerHTML=value;
}

//Clear options in a <select> element
function options_clear(id) {
  while (document.getElementById(id).childNodes.length > 0) {
    document.getElementById(id).removeChild(document.getElementById(id).childNodes[0])
  }
}
