function AJR(url,params,targetElement,xmlMethod)
{
	var xmlHttp;
	var xmlTargetElement;
	var xmlMethod;
	var xmlUrl;
	var xmlParams;

	function GetAjaxHttpObject()
	{
		var xmlHttpl=null;
		try
		{
		 	// Firefox, Opera 8.0+, Safari
		 	xmlHttpl=new XMLHttpRequest();
		}
		catch (e)
		{
		 	//Internet Explorer
		 	try
		  	{
		  		xmlHttpl=new ActiveXObject("Msxml2.XMLHTTP");
		  	}
		 	catch (e)
		  	{
		  		xmlHttpl=new ActiveXObject("Microsoft.XMLHTTP");
		  	}
		}
		return xmlHttpl;
	}
	if (xmlMethod==null)
		xmlMethod="POST";
 	this.xmlTargetElement=targetElement;
	this.xmlUrl=url;
	
	this.xmlMethod=xmlMethod;
	this.xmlParams=params;
	this.xmlHttp=GetAjaxHttpObject()
	if (this.xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
	 	return
	}
	this.xmlHttp.onreadystatechange=registreCallbackFunction(this.xmlHttp,this.xmlTargetElement);
	if (this.xmlMethod!="POST")
		 this.xmlUrl+='?'+this.xmlParams;
	this.xmlHttp.open(this.xmlMethod, this.xmlUrl, true);
	if (xmlMethod=="POST"){
		this.xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.xmlHttp.setRequestHeader("Content-length", this.xmlParams.length);
		this.xmlHttp.setRequestHeader("Connection", "close");
		this.xmlHttp.send(this.xmlParams);
	}
	else
	{
		this.xmlHttp.send(null);
	}
	
}


function AJRCB(url,params,targetElement,xmlMethod,ScriptName)
{
	var xmlHttp;
	var xmlTargetElement;
	var xmlMethod;
	var xmlUrl;
	var xmlParams;
	var xmlScript;

	function GetAjaxHttpObject()
	{
	 
		var xmlHttpl=null;
		try
		{
		 	// Firefox, Opera 8.0+, Safari
		 	xmlHttpl=new XMLHttpRequest();
		}
		catch (e)
		{
		 	//Internet Explorer
		 	try
		  	{
		  		xmlHttpl=new ActiveXObject("Msxml2.XMLHTTP");
		  	}
		 	catch (e)
		  	{
		  		xmlHttpl=new ActiveXObject("Microsoft.XMLHTTP");
		  	}
		}
		return xmlHttpl;
	}
	if (xmlMethod==null)
		xmlMethod="POST";
 	this.xmlTargetElement=targetElement;
	this.xmlUrl=url;
	this.xmlScript=ScriptName;
	this.xmlMethod=xmlMethod;
	this.xmlParams=params;
	this.xmlHttp=GetAjaxHttpObject()
	if (this.xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
	 	return
	}
	this.xmlHttp.onreadystatechange=registreCallbackFunctionCB(this.xmlHttp,this.xmlTargetElement,this.xmlScript);
	if (this.xmlMethod!="POST")
		 this.xmlUrl+='?'+this.xmlParams;
	this.xmlHttp.open(this.xmlMethod, this.xmlUrl, true);
	if (xmlMethod=="POST"){
		this.xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.xmlHttp.setRequestHeader("Content-length", this.xmlParams.length);
		this.xmlHttp.setRequestHeader("Connection", "close");
		this.xmlHttp.send(this.xmlParams);
	}
	else
	{
		this.xmlHttp.send(null);
	}
	
}

function registreCallbackFunction(xmlHttp,target){
	return function(){
	//alert(xmlHttp.onreadystatechange)
		if(xmlHttp.readyState == 4){
		//	xmlHttp.onreadystatechange = null;
			//alert('OK')
			if(! xmlHttp.status || xmlHttp.status >= 200 && xmlHttp.status < 300 || xmlHttp.status == 304)
				document.getElementById(target).innerHTML=xmlHttp.responseText;
			else
				alert("Ошибка соединения попробуйте повторить операцию!")
			//alert('OK')
		}
	}
}

function registreCallbackFunctionCB(xmlHttp,target,ScriptName){
	return function(){
	//alert(xmlHttp.onreadystatechange)
		if(xmlHttp.readyState == 4){
		//	xmlHttp.onreadystatechange = null;
			//alert('OK')
			if(! xmlHttp.status || xmlHttp.status >= 200 && xmlHttp.status < 300 || xmlHttp.status == 304){
				document.getElementById(target).innerHTML=xmlHttp.responseText;
				eval(ScriptName);
			}
			else
				alert("Ошибка соединения попробуйте повторить операцию!")
			//alert('OK')
		}
	}
}


