﻿// JScript File
   
    var xmlHttp_temp = null;
    var isDOM = (document.getElementById ? true : false);
    var is_ie = (navigator.userAgent.indexOf('MSIE') >= 0) ? 1 : 0;
    var is_ie5 = (navigator.appVersion.indexOf("MSIE 5.5")!=-1) ? 1 : 0;
    var is_ie7 = false;;
    var is_opera = ((navigator.userAgent.indexOf("Opera6")!=-1)||(navigator.userAgent.indexOf("Opera/6")!=-1)) ? 1 : 0;
    var is_netscape = (navigator.userAgent.indexOf('Netscape') >= 0) ? 1 : 0;
    var obj;
    var is_ff = false;
    try 
    { 
           obj= new XMLHttpRequest(); 
           if(is_ie)
           { 
            is_ie7 = true;
           }
           else is_ff =true; 
    }

    catch(e){}
    
    
   function ajax(URL, ajaxHandler)
   {
            xmlHttp_temp = GetXmlHttpObject(ajaxHandler);
            xmlHttp_Get(xmlHttp_temp, URL);
   }
 
    function xmlHttp_Get(xmlhttp, url )
    {
        xmlhttp.open('GET', url, true);
        xmlhttp.send(null);
    }
    // XMLHttp send GET request

  function GetXmlHttpObject(handler)
  { 
        var objXmlHttp = null;
        if (!window.XMLHttpRequest)
        {
            // Microsoft
            objXmlHttp = GetMSXmlHttp();
            if (objXmlHttp != null)
            {
             
                objXmlHttp.onreadystatechange = handler;
                
            }
           
        } 
        else
        {
            // Mozilla | Netscape | Safari
            objXmlHttp = new XMLHttpRequest();
            if (objXmlHttp != null)
            {
                if(is_ie7) 
                {
                    //alert("use xml ff");
                    objXmlHttp.onreadystatechange = handler;
                }
                else {
                objXmlHttp.onload = handler;
                objXmlHttp.onerror = handler;
 
                }
                
               
            } 
        } 
        return objXmlHttp; 
   }
   function GetMSXmlHttp()
   {
        var xmlHttp = null;
        var clsids = ["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0",
                     "Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0", 
                     "Msxml2.XMLHTTP.2.6","Microsoft.XMLHTTP.1.0", 
                     "Microsoft.XMLHTTP.1","Microsoft.XMLHTTP"];
        var i;
        for(i=0; i<clsids.length && xmlHttp == null; i++) 
        {
            xmlHttp = CreateXmlHttp(clsids[i]);
           
        }
       
        return xmlHttp;
    }

    function CreateXmlHttp(clsid) 
    {
        var xmlHttp = null;
        try
        {
            xmlHttp = new ActiveXObject(clsid);
            lastclsid = clsid;
            return xmlHttp;
        }
        catch(e) {}
    }
    
    function X(url,handler)
    {
        var self = this;
        this.Handler=function()
        {
            if(self.xmlHttp_temp.readyState == 4 || self.xmlHttp_temp.readyState == 'complete')
               handler(self.xmlHttp_temp);
        }
        this.xmlHttp_temp =GetXmlHttpObject(this.Handler);
        //alert("ajax url is "+url);
        xmlHttp_Get(this.xmlHttp_temp, url);
    }  

    String.prototype.trim = function() {
	    return this.replace(/^\s+|\s+$/g,"");
    }
    