﻿// JScript File

function ajax()
{            
    try
    {    // Firefox, Opera 8.0+, Safari   
    
        aj=new XMLHttpRequest();
           
    }
    catch (e)
    {    // Internet Explorer    
        try
        {      
            aj=new ActiveXObject("Msxml2.XMLHTTP"); 
               
        }
        catch (e)
        {
            try
            {
                aj=new ActiveXObject("Microsoft.XMLHTTP"); 
                      
            }
            catch (e)
            {        
                alert("Your browser does not support AJAX!");        
                        
            }      
        }    
    }
    return aj;
}
function getresponse(url,obj)
{
    var xmlHttp = new ajax();
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
           obj.innerHTML = xmlHttp.responseText;
        }
    }
    xmlHttp.open("GET",url+"&id="+Math.random(),true);
    xmlHttp.send(null); 

} 
function getxml2(url,callbackobj,obj)
{
    var xmlHttp = new ajax();
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            if (arguments[0] == null)
            callbackobj(xmlHttp.responseXML,obj);
            
        }
    }
    xmlHttp.open("GET",url+"&id="+Math.random(),true);
    xmlHttp.setRequestHeader('Content-Type','text/xml');             
    xmlHttp.setRequestHeader('encoding','UTF-8'); 
    xmlHttp.send(null); 
} 

function getxml(url,callbackobj)
{
    var xmlHttp = new ajax();
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            if (arguments[0] == null)
            callbackobj(xmlHttp.responseXML);
            
        }
    }
    xmlHttp.open("GET",url+"&id="+Math.random(),true);
    xmlHttp.setRequestHeader('Content-Type','text/xml');             
    xmlHttp.setRequestHeader('encoding','UTF-8'); 
    xmlHttp.send(null); 
} 
function gettextFromASPX(url,callbackobj)
{
    var xmlHttp = new ajax();
    xmlHttp.onreadystatechange=function()
    {
       
      if(xmlHttp.readyState==4)
      {           
          if (typeof callbackobj == "function") callbackobj(xmlHttp.responseText); 
           else callbackobj.innerHTML = xmlHttp.responseText;
      }
    }
    xmlHttp.open("GET",url+"&id="+Math.random(),true);
    xmlHttp.send(null); 
}

function gettext(url,callbackobj)
{
    var xmlHttp = new ajax();
    xmlHttp.onreadystatechange=function()
    {
       
      if(xmlHttp.readyState==4)
      {           
           if (typeof callbackobj == "function") callbackobj(xmlHttp.responseText); 
           else callbackobj.innerHTML = xmlHttp.responseText;
      }
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null); 
}


function posttext(url,xml,callbackobj)
{
    var xmlHttp = new ajax();
   // xmlHttp.onreadystatechange=function()
   // {
   //   if(xmlHttp.readyState==4)
   //   {
    //       callbackobj(xmlHttp.responseText);
   //   }
   // }
    xmlHttp.open("POST",url,false);
    xmlHttp.setRequestHeader('Content-Type','text/xml');             
    xmlHttp.setRequestHeader('encoding','UTF-8'); 
    xmlHttp.send(xml);
    callbackobj(xmlHttp.responseText);
}
function postxmlAssync(url,xml,callbackobj)
{
    var xmlHttp = new ajax();
    xmlHttp.onreadystatechange=function()
    {
      if(xmlHttp.readyState==4)
      {
        
           if (typeof callbackobj != "function") callbackobj.innerHTML = xmlHttp.responseText;
           else callbackobj(xmlHttp.responseText);
        
      }
    }
    xmlHttp.open("POST",url+"&id="+Math.random(),true);
    xmlHttp.setRequestHeader('Content-Type','text/xml');             
    xmlHttp.setRequestHeader('encoding','UTF-8'); 
    xmlHttp.send(xml);
    
}


