var displayID;
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e) {
	  // Internet Explorer
	  try {
	    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	    }
	  catch (e) {
	    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	}
	return xmlHttp;
} 


function ajaxFunction(url, params, display, loading) {
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    }
    displayID = display;
    var loadingImg = loading;
    if(displayID != '') {
    	if(loadingImg == '')
    		loadingImg = 'loading.gif';
		document.getElementById(displayID).innerHTML = "<div class='loading'><img src='images/" + loadingImg + "' /><div>";
    }
    if(params != '') {
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.onreadystatechange=update;
		xmlHttp.send(params);
    }
    else {
		xmlHttp.onreadystatechange=none;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
    }
}

function update() {
	if(xmlHttp.readyState==4) {
		if(displayID != '') {
  			document.getElementById(displayID).innerHTML = xmlHttp.responseText;
  		}
	}
}

function none() {
	
}

function getCheckedValue(radioObj) {
	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 ajaxFunctionRR(url, params, display, loading) {
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null) {
        alert ("Your browser does not support AJAX!");
        return;
    }
    displayID = display;
    var loadingImg = loading;
    if(displayID != '') {
    	if(loadingImg == '')
    		loadingImg = 'loading.gif';
		document.getElementById(displayID).innerHTML = "<div class='loading'><img src='images/" + loadingImg + "' /><div>";
    }
    if(params != '') {
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.onreadystatechange=update;
		xmlHttp.send(params + "&qu=" + document.getElementById('qu').value + "&opt=" + getCheckedValue(document.forms['orderform'].elements['opt']));
    }
    else {
		xmlHttp.onreadystatechange=none;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
    }
}

function update() {
	if(xmlHttp.readyState==4) {
		if(displayID != '') {
  			document.getElementById(displayID).innerHTML = xmlHttp.responseText;
  		}
	}
}

