﻿function Ajax()
{
	var xmlhttp, bComplete = false;
  	try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  	catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  	catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  	catch (e) { xmlhttp = false; }}}
  	if (!xmlhttp){
  	  return null;
  	 }
  	 
	this.request = function(sURL, sMethod, sVars, fnDone)
	  {

	    if (!xmlhttp) return false;
	    bComplete = false;
	    sMethod = sMethod.toUpperCase();

	    try {
	      if (sMethod == "GET")
	      {
	        xmlhttp.open(sMethod, sURL, true);
	        sVars="";
	      }
	      else
	      {
	        //alert("POST");
	        xmlhttp.open(sMethod, sURL, true);
	        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
	        xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8");
	      }
	      xmlhttp.onreadystatechange = function(){
	        if (xmlhttp.readyState == 4 && !bComplete)
	        {
	          bComplete = true;
	          fnDone(xmlhttp);
	        }};
	        //alert(sVars);
	      xmlhttp.send(sVars);
	    }
	    catch(z) { return false; }
	    return true;
	  };
}


function _Update(sURL, element,elementparent)
	  {
	  	
	    var setContext=function(xmlhttp)
	    {
    		if (typeof element == 'string')
     		 	element = document.getElementById(element);
            if (typeof elementparent == 'string')
     		 	elementparent = document.getElementById(elementparent);
            
     		element.innerHTML=xmlhttp.responseText;
     		
     		if(element.innerHTML.length > 0)
     		    elementparent.style.display = "block";
     	    else
     	        elementparent.style.display = "none";
	    }
	    var aj=new Ajax();
	   aj.request(sURL,"GET",'',setContext);
	  }


