/*
 * Ajax Object
 */
function createAjaxObj(handler){ 
	var objXmlHttp=null
	if (navigator.userAgent.indexOf("Opera")>=0){
		alert("This example doesn't work in Opera");
		return; 
		}
	if (navigator.userAgent.indexOf("MSIE")>=0){ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0) strName="Microsoft.XMLHTTP"
		try{ 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
			} 
		catch(e){ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
			} 
		} 
	if (navigator.userAgent.indexOf("Mozilla")>=0){
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
}

function ajaxObj(page,method,functionName,params){
	this.xmlHttp = createAjaxObj(getValues);
	this.page=page;
	this.params=params;
	this.method=method;
	this.functionName=functionName
	this.sendValues=sendValues;
	this.getValues=getValues;
	function sendValues(sendItems){
		if (this.xmlHttp){
			var instanceOfObj=this
			if(typeof(this.page)=="undefined") return;
			if(this.method.toLowerCase()=="post"){
				this.xmlHttp.onreadystatechange=function(){instanceOfObj.getValues();}
				this.xmlHttp.open("POST",this.page,true);
				this.xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				this.xmlHttp.send(sendItems);
				
			}
			else {
				this.xmlHttp.open("GET",this.page,true);
				this.xmlHttp.send(null);
			}
		}
	}
	function getValues(){
		if(typeof(this.xmlHttp)!="undefined"){
			if (this.xmlHttp.readyState==4){
				if (this.xmlHttp.status==200){
				this.functionName(this.xmlHttp.responseText);
				}
			}
		} 	
	}
}