function cursor_wait() {
document.body.style.cursor = 'wait';
}
function cursor_clear() {
document.body.style.cursor = 'default';
}

function postBack(url,params,field,Load)
{
	cursor_wait();
	if(document.getElementById(field).style.display == "none"){
		document.getElementById(field).style.display = "block"
	}
	if(Load == 1){
		loader(field);
	}
	xmlHttp=GetXmlHttpObject();
	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	if(field != "void"){
		xmlHttp.onreadystatechange=function() { stateChanged(field); };
	}
	xmlHttp.send(params);
	cursor_clear();
}

function loader(field)
{
		document.getElementById(field).innerHTML="<table cellpadding=\"3\" cellspacing=\"0\" align=\"center\" width=\"100%\" border=\"0\" height=\"50px\" class=\"loader\"><tr><td valign=\"middle\" align=\"right\"><img src=\"tac.globals/images/loading.gif\" loop=\"1\" align=\"middle\" /></td><td valign=\"middle\">Loading</td></tr></table>";

}

function uploading(field)
{
		document.getElementById(field).innerHTML="<table cellpadding=\"3px\" cellspacing=\"0\" align=\"center\" width=\"100%\" border=\"0\" height=\"20px\" class=\"loader\" style=\"padding-top:0px; margin-top:-2px;\"><tr><td valign=\"middle\" align=\"right\"><img src=\"tac.globals/images/loading_blue.gif\" loop=\"1\" align=\"middle\" width=\"16\" height=\"16\" /></td><td valign=\"bottom\">Uploading File</td></tr></table>";

}

function stateChanged(field) 
{
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		if(document.getElementById(field).style.display == "none"){
			document.getElementById(field).style.display = "block"
		}
		document.getElementById(field).innerHTML=xmlHttp.responseText;
		footer();

	}
	
} 


function GetXmlHttpObject(handler)
{ 
	var objXMLHttp=null;
	if(window.XMLHttpRequest)
	{	objXMLHttp=new XMLHttpRequest();	}
	else if(window.ActiveXObject)
	{	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");	}
	return objXMLHttp;
}

function loadCell(url,field){
	

	xmlHttp=GetXmlHttpObject();
	xmlHttp.open("POST",url,true);
	xmlHttp.onreadystatechange=function() { stateChanged(field); };
	xmlHttp.send(null);

}

function fieldClose(field){
	
	document.getElementById(field).style.display = "none";

}

function fieldOpen(field){
	
	document.getElementById(field).style.display = "block";

}

function shadow(url,params,field,Class,Load){
	document.getElementById("shadow").style.display = "block";
	document.getElementById(field).className = Class;
	document.getElementById(field).style.display = "block";
	postBack(url,params,field,Load);
}

function shadowClose(field){
	document.getElementById("shadow").style.display = "none";
	document.getElementById(field).style.display = "none";
	document.getElementById(field).innerHtml = "";
}

function getSelectedRadioValue() {
   // returns the value of the selected radio button or 0 if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return 0;
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} 