var request;
	var dest;

	function processStateChange()
	{
		 if (request.readyState == 4)
		 {

            if(document.getElementById(dest))
    	  	contentDiv = document.getElementById(dest);
    	  	
    	  	
     		if (request.status == 200)
			{


                ajax_reaction(dest);
				
				
    		} 
			else 
			{
				contentDiv.innerHTML = "Ошибка на странице."
    		}
  		}
	}	
	
	function loadHTML(request_type, URL, post_data, destination)
	{
		Loader=post_data.split("ajax=1");
		if(Loader[1]){
        document.getElementById("ajax_loader").style.display="block";
        center("ajax_loader","body");}
		dest = destination;
		var msxmlhttp = new Array(
				'Msxml2.XMLHTTP.5.0',
				'Msxml2.XMLHTTP.4.0',
				'Msxml2.XMLHTTP.3.0',
				'Msxml2.XMLHTTP',
				'Microsoft.XMLHTTP');

		for (var i = 0; i < msxmlhttp.length; i++)
		{
			try
			{
				request = new ActiveXObject(msxmlhttp[i]);
			} 
			catch (e)
			{
				request = null;
			}
		}
 			
		if(!request && typeof XMLHttpRequest != "undefined")
		request = new XMLHttpRequest();
		if (!request)
		alert("Could not create connection object.");

    	request.onreadystatechange = processStateChange;
    	request.open(request_type, URL, true);
		if (request_type == "POST")
		{
			request.setRequestHeader("Method", "POST " + URL + " HTTP/1.1");
			request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=windows-1251");
		}

		request.send(post_data);
		delete request;
	}

function ajax_reaction(dest){
	
    // После успешного добавления комментария
    response = request.responseText;
	if(document.getElementById("ajax_loader"))
    document.getElementById("ajax_loader").style.display="none";
	

   if(document.getElementById(dest)){

        contentDiv.innerHTML = response;
        return false;
   }

  if(dest=="comments_add[;;;]comments_list"){
     comments_form_clean();

     Data=response.split("[;;;]");
     //document.getElementById("comments_list").innerHTML=Data[1];
     document.getElementById("comments_list").innerHTML=Data;


  }

  Dest2=dest.split(";");
  if(Dest2[0]=="open_module"){
    admin_load_module(response,Dest2[1],Dest2[2]);
    visual_editor();
  }
  else{
    eval(Dest2[0]);
  }



}


function ajax_post(Data)
{
		Data = Data.replace("+","{plus}");
		Data = Data.replace("&","{epersant}");
		
		return Data;
}


	
	

	
