function xmlHTTP(module,js,param,progress,result,append) {
    //alert(module+" "+js+" "+param+" "+progress+" "+result+" "+append);
 var xmlhttp;
 /*@cc_on @*/
 /*@if (@_jscript_version >= 5)
   try {xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}
   catch (e) {
     try {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
     catch (E) {xmlhttp=false;}
  }
 @else
  xmlhttp=false
  @end @*/
 if (!xmlhttp && typeof XMLHttpRequest!='undefined'){try {xmlhttp = new XMLHttpRequest();} catch (e) {xmlhttp=false;}}
 if (!xmlhttp && window.createRequest) {try {xmlhttp = window.createRequest();} catch (e) {xmlhttp=false;}}

 if(progress){getItem(progress).innerHTML = "<img src='/static/images/LoadingBar.gif' border=0>";}
 xmlhttp.open("POST", "/",true);
 xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
 xmlhttp.send('module='+module+'&js='+js+'&'+param);
 xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) {
   //debug(xmlhttp.responseText);
   //alert(xmlhttp.responseText);
    if(result){
        if (append == "1"){
	    getItem(result).innerHTML += xmlhttp.responseText;
	} else {
	    getItem(result).innerHTML = xmlhttp.responseText;
	}
    }
   else {eval(xmlhttp.responseText);}
  }
 }
}

// Paramitize encoded string for an Ajax POST request
function param (string){
    var fields=string.split(",");
    var result="";
    for (var i=0, len=fields.length; i<len; ++i){
	    var func = fields[i].split("|");
	    if (func.length==1){
	      result += ((result=="")?'':'&') + func[0];
	    } else {
	      result += ((result=="")?'':'&') + func[0] + "=" + eval('get'+func[1]+'Val("'+func[0]+'");');
	    }
    }
    return result;
}

// Compatible with all major browsers for getting an instance of an object
function getItem(id){
    var itm = false;
    if(document.getElementById)itm = document.getElementById(id);
    else if(document.all)itm = document.all[id];
    else if(document.layers)itm = document.layers[id];
    return itm;
}

// Extract the value from a Text input box
function getTextVal (id){
    return getItem(id).value;
}

// Exrtact the value from a select list
function getSelectVal (id){
    var item = getItem(id);
    return item.options[item.selectedIndex].value;
}

// Extract a value from radio buttons
function getRadioVal (id){
    var radioObj = getItem(id);
    if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";

}


function debug(content) {
 top.consoleRef=window.open('','myconsole','width=600,height=400,menubar=0,toolbar=0,status=0,scrollbars=1,resizable=1')
 top.consoleRef.document.writeln(
  '<html><head><title>Debugger</title></head>'
   +'<body bgcolor=white onLoad="self.focus()">'
   +content
   +'</body></html>'
 )
 top.consoleRef.document.close()
}

