//javascript
//DEFAULT
function AjaxHandler(obj){	
	this.hostObj=obj;
	}
AjaxHandler.prototype.called = function(){

	//alert("CALLED"+this.hostObj);
	}
AjaxHandler.prototype.loading = function(){	
	
	//alert("LOADING"+this.hostObj);
	}
AjaxHandler.prototype.handle = function(txt){
	this.hostObj.innerHTML = this.hostObj.innerHTML+(txt);
	if(this.onHandle!=undefined)
	this.onHandle(this.vars);
	//alert("HANDLE:"+this.hostObj+" return:"+txt);
	}

AjaxHandler.prototype.unload = function(){	
	//alert("UNLOADING"+this.hostObj);
	}

function ajaxFunction(url, vars, obj)
{
	obj.vars=vars;
	var xmlHttp;
try{
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }catch (e){
  // Internet Explorer
  try{
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }catch (e){
    try{
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }catch (e){
      alert("Your browser does not support AJAX!");
      return false;
      }
   }
}

  xmlHttp.onreadystatechange=function(){
	if(xmlHttp.readyState==2){
	  //is called
		obj.called();
    }else if(xmlHttp.readyState==3){
	  //is loading
		obj.loading();
    }else if(xmlHttp.readyState==4){
	  //loaded!
		obj.handle(xmlHttp.responseText);	
		obj.unload();
      }
    }  
  if(!vars) vars="";
  xmlHttp.open("POST",url,true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

  xmlHttp.setRequestHeader("Content-length", vars.length);
  xmlHttp.setRequestHeader("Connection", "close");  
  xmlHttp.send(vars);
  }
