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

//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;
}
//Swab innerHTML of an element
function SwapInner(id, value1, value2){
  var show = document.getElementById(id);
  if (show.innerHTML == value1){
    show.innerHTML = value2;
  }
  else {
    show.innerHTML = value1;
  }
}

//Give focus to an element
function setFocus(id) {
	var focusField = document.getElementById(id);
	focusField.focus();
}

//Open a new window
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();
}

//Close the current window
function closewin () {
    self.close();
}

//Enables or disables a form element
function DisableEnable(id, state){
  var cur = document.getElementById(id);
  if (state) {
    cur.disabled=state;
  }
  else {
    cur.removeAttribute('disabled');
  }
}

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

//Change image source in an element
function ChangeImage(id, imgsrc, wdt, hgt){
  document.getElementById(id).src=imgsrc;
  if (wdt!=null){
  document.getElementById(id).width=wdt;
  }
  if (hgt!=null){
  document.getElementById(id).height=hgt;
  }
}

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

function colheight(id1, id2){
  a = document.getElementById(id1);
  b = document.getElementById(id2);
  
  lh = a.offsetHeight;
  rh = b.offsetHeight;
  
  if(lh>=rh){
    b.style.height=lh+'px';
  }
  else{
    a.style.height=rh+'px';
  }
}

function checkboxSelectAll(formname){
  a = document.forms[formname];
  len = a.elements.length;
  for(i=0;i<len;i++){
    if(a.elements[i].type == "checkbox"){
      a.elements[i].checked = true;
    }
  }
}

function checkboxClearAll(formname){
  a = document.forms[formname];
  len = a.elements.length;
  for(i=0;i<len;i++){
    if(a.elements[i].type == "checkbox"){
      a.elements[i].checked = false;
    }
  }
}

