﻿ function AjaxEngine1(Method,Url,element_id,data)
{
	//this.url=Url;
	//this.method=Method;
	//this.element=element_id;
	
	if(typeof(Url)=="undefined")
	 return false;
	 
	var XmlHttp=false;
   
	if(window.XMLHttpRequest)
	  XmlHttp=new XMLHttpRequest();
	else
		XmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	
	if(typeof(Method)=="undefined")
	  Method="POST";
	  
	//if(typeof(data)=="undefined" || data=="")
	  //data=null;
	 
	XmlHttp.open(Method,Url,true);
	
	if(Method.toUpperCase()=="POST")   
	{
	//alert(Method.toUpperCase());
	
	  XmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	  
	  if(data!=null && data.length>0)
	  XmlHttp.setRequestHeader("Content-Length",data.length);
	  
	  
	  
	  XmlHttp.setRequestHeader("Connection","close");
	 }
	 
	XmlHttp.onreadystatechange=function()
	{
	if(XmlHttp.readyState==4 && XmlHttp.status==200)
	{
		document.getElementById(element_id).innerHTML=XmlHttp.responseText;
		XmlHttp=null;
	}
		
	}
	
	XmlHttp.send(data);
}

 function AjaxEngine(Method,Url,element_id,data,CallBack)
{

    
	if(typeof(Url)=="undefined")
	 return false;
	var XmlHttp=false;
	if(window.XMLHttpRequest)
	  XmlHttp=new XMLHttpRequest();
	else
		XmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	if(typeof(Method)=="undefined")
	  Method="POST";
	//if(typeof(data)=="undefined" || data=="")
	  //data=null;
	XmlHttp.open(Method,Url,true);
	if(Method.toUpperCase()=="POST")   
	{
	//alert(Method.toUpperCase());
	  XmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	  if(data!=null && data.length>0)
	  XmlHttp.setRequestHeader("Content-Length",data.length);
	  XmlHttp.setRequestHeader("Connection","close");
	 }
	XmlHttp.onreadystatechange=function()
	{
	if(XmlHttp.readyState==2)
	document.getElementById(element_id).innerHTML="Loading...";
	if(XmlHttp.readyState==4 && XmlHttp.status==200)
		{
		document.getElementById(element_id).innerHTML=XmlHttp.responseText;
		
		CallBack(XmlHttp.responseText);
		}
	}
	
	XmlHttp.send(data);
}




