function xmlHTTP(module,js,param,progress,result) {
 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/wait.gif' border=0>";}
 xmlhttp.open("POST", "/rpc",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){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("|");
	    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 selection = getItem(id);
    for (i=0; i<selection.length; i++)
	if (selection[i].checked == true)
	return selection[i].value;
}

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()
}
