var isOpera = (navigator.userAgent.indexOf("Opera") != -1)? true : false;
var isIE = (navigator.appName == "Microsoft Internet Explorer" && !isOpera)? true : false;
var HTTPRequestMethod;

function GetSiteUrl()
{
   // Function return current site url
   var i = window.location.protocol + "//" + window.location.host;
   return i;
}

var xmlHandler = "";
function loadXMLDoc(url)
{
   // Function set XMLRequest object
   // branch for native XMLHttpRequest object
   if (window.XMLHttpRequest)
   {
      xmlHandler = new XMLHttpRequest();
      xmlHandler.onreadystatechange = HandleStateChange;
      xmlHandler.open("GET", url, true);
      xmlHandler.send(null);
   }
   else if(window.ActiveXObject)
   {
      // branch for IE/Windows ActiveX version
      xmlHandler = new ActiveXObject("Microsoft.XMLHTTP");
      if(xmlHandler)
      {
         xmlHandler.onreadystatechange = HandleStateChange;
         xmlHandler.open("GET", url, true);
         xmlHandler.send();
      }
   }
}

function loadXMLPost(url, post)
{
   // Function set XMLRequest object
   // branch for native XMLHttpRequest object
   if (window.XMLHttpRequest)
   {
      xmlHandler = new XMLHttpRequest();
      xmlHandler.onreadystatechange = HandleStateChange;
      xmlHandler.open("POST", url, true);
      xmlHandler.setRequestHeader('Content-Type','application/x-www-form-urlencoded encoding=utf-8');
      xmlHandler.send(post);
   }
   else if(window.ActiveXObject)
   {
      // branch for IE/Windows ActiveX version
      xmlHandler = new ActiveXObject("Microsoft.XMLHTTP");
      if(xmlHandler)
      {
         xmlHandler.onreadystatechange = HandleStateChange;
         xmlHandler.open("POST", url, true);
         xmlHandler.setRequestHeader('Content-Type','application/x-www-form-urlencoded encoding=utf-8');
         xmlHandler.send(post);
      }
   }
}

function loadXMLHead(url)
{
   // Function set XMLRequest object
   // branch for native XMLHttpRequest object
   if (window.XMLHttpRequest)
   {
      xmlHandler = new XMLHttpRequest();
      xmlHandler.onreadystatechange = HandleStateChange;
      xmlHandler.open("HEAD", url, true);
      xmlHandler.send(null);
   }
   else if(window.ActiveXObject)
   {
      // branch for IE/Windows ActiveX version
      xmlHandler = new ActiveXObject("Microsoft.XMLHTTP");
      if(xmlHandler)
      {
         xmlHandler.onreadystatechange = HandleStateChange;
         xmlHandler.open("HEAD", url, false);
         xmlHandler.send(null);
      }
   }
}

function HandleStateChange()
{
   // Function listen handlerAnswer
   // only if handler shows "complete"

   //ShowProgress(xmlHandler.readyState);
   if (xmlHandler.readyState == 4)
   {
      // only if "OK"
      if(xmlHandler.status == 200)
      {
      	/*
      	alert(xmlHandler.responseText);
      	return;
         */
			/*
      	eval(xmlHandler.responseText);
      	eval(HTTPRequestMethod + "(true)");
      	return;
      	*/
         // ...processing statements go here...
         xmlResult = xmlHandler.responseXML.documentElement;
         retMethod = xmlResult.getElementsByTagName('method')[0].firstChild.data;
         eval(retMethod + "(xmlResult)");
      }
   }
}

function _HTMLEncode( text )
{
	if ( typeof( text ) != "string" )
		text = text.toString() ;

	text = text.replace(/&/g, "&amp;") ;
	text = text.replace(/"/g, "&quot;") ;
	text = text.replace(/</g, "&lt;") ;
	text = text.replace(/>/g, "&gt;") ;
	text = text.replace(/'/g, "&#39;") ;

	return text ;
}