document.write("<SCRIPT language='JavaScript' src='js/tabpane.js' type='text/javascript'></SCRIPT>");
document.write("<SCRIPT language='JavaScript' src='js/tree.js' type='text/javascript'></SCRIPT>");
document.write("<SCRIPT language='JavaScript' src='js/helptip.js' type='text/javascript'></SCRIPT>");
document.write("<link rel='stylesheet' href='tab.winclassic.css' />");
document.write("<link rel='stylesheet' href='helptip.css' />");

var isIE = document.all?true:false;

function popupWindow(url, nom, w, h){
 if (!w) w=320
 if (!h) h=260
 if (self.win) win.close()
  win=window.open(url, nom, 'status=no,width=' + w+ ',height=' + h + ',menubar=no,resizable=yes,scrollbars=yes');
  win.focus(); 
}

function updateOptionMenu(index, tgtOptions, group){
  for (m = tgtOptions.length-1; m > 0; m--) {
    tgtOptions[m]=null
  }
  for (i = 0; i < group[index].length; i++){
    tgtOptions[i]=new Option(group[index][i].text, group[index][i].value)
  }
  tgtOptions[0].selected=true
}

function setField(field, value) {
  if (field != null) {
    field.value = value;
  }
}

function clearField(e1, e2, e3, e4) {
    if (e1 != null) {
      e1.value = "";
    }
    if (e2 != null) {
      e2.value = "";
    }
    if (e3 != null) {
      e3.value = "";
    }
    if (e4 != null) {
      e4.value = "";
    }
}

function blankField(e1, e2, e3, e4) {
    if (e1 != null) {
      e1.value = " ";
    }
    if (e2 != null) {
      e2.value = " ";
    }
    if (e3 != null) {
      e3.value = " ";
    }
    if (e4 != null) {
      e4.value = " ";
    }
}

function checkAll(form, name, checkbox) {

  // Find out the (first) current check
  for (var i = 0 ; i < form.elements.length ; i++){
    if (form.elements[i].name == name) {
      checkIt = !form.elements[i].checked;
      break;
    }
  }

  // Check all in the toggle state
  for (var i = 0 ; i < form.elements.length ; i++){
    if (form.elements[i].name == name) {
      form.elements[i].checked = checkIt;
    }
  }
  checkbox.checked = true;
}

function getUrlWithUpdatedParam(url,param,value){
	var targeturl = url.toString();
			
	re1 = new RegExp("([^\?]*\\?.*)("+param+"=[^&]*&?)(.*)","i");
	re2 = new RegExp("([^\?]*\\?)(.*)","i");
	re3 = new RegExp("([^\?]*)","i");
	
	if (targeturl.search(re1) != -1){
		if (value)
			targeturl = targeturl.replace(re1,"$1"+param+"="+value+"&$3");
		else
			targeturl = targeturl.replace(re1,"$1"+"$3");
	}
	else if (targeturl.search(re2) != -1){ 
		if (value)
			targeturl = targeturl.replace(re2,"$1"+param+"="+value+"&$2");
		else
			targeturl = targeturl.replace(re2,"$1"+"$2");
	}
	else { 
		if (value)
			targeturl = targeturl.replace(re3,"$1?"+param+"="+value);
		else
			targeturl = targeturl.replace(re3,"$1");
	}
	
	return targeturl;
}

function promptAction(msg , url, param, defvalue){
  value = top.prompt(msg,defvalue);
	if (value) {
    document.location = getUrlWithUpdatedParam(url, param, value);
  }
}

function confirmAction(msg, url) {
  if (top.confirm(msg)) {
    document.location = url;
  }
}

function progressInsert(msg) {
  document.write("<div id='progress' style=\"position:absolute;display:none;top:200;left:200;border: 1px black solid;padding:3px 3px 3px 3px;background-color:#FFFFFF;font-family: sans-serif;font-size: 80%\"><NOBR><img src='images/jalios/icons/wait.gif' align='texttop'><br>" + msg + "</NOBR></div>");
  document.onmousemove = getMousePosition;
}

function progressShow() {
  document.all["progress"].style.top = mouseY + 10;
  document.all["progress"].style.left = mouseX + 10;
  document.all["progress"].visibility= "visible";
  document.all["progress"].style.display = "block";
}

function progressHide() {
  document.all["progress"].style.display = "none";
}

function getMousePosition(e) {
  if (!isIE) {
    mouseX = e.pageX;
    mouseY = e.pageY;
  }
  if (isIE) {
    mouseX = event.clientX;
    mouseY = event.clientY;
  }
  return true;
}


function doOnLoad(){
  setupAllTabs();
  initaqtrees();
}

// Initialization hook up
// DOM2
if ( typeof window.addEventListener != "undefined" )
	window.addEventListener( "load", doOnLoad, false );

// IE 
else if ( typeof window.attachEvent != "undefined" )
	window.attachEvent( "onload", doOnLoad );

else {
	if ( window.onload != null ) {
		var oldOnload = window.onload;
		window.onload = function ( e ) {
			oldOnload( e );
			doOnLoad();
		};
	}
 	else 
		window.onload = doOnLoad;
}

