var Ajax =  
{
        GetXMLHTTPRequest : function()
        {
            if (browser == "MSIE")
            {
                var oXMLHTTPRequest = null;
                try //IE
                {
                    oXMLHTTPRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch(err) 
                {
                    try 
                    {
                        oXMLHTTPRequest = new ActiveXObject("Microsoft.XMLHTTP");
                    } 
                    catch(err) 
                    {
                        oXMLHTTPRequest = null;
                    }
                }
            }
            else if (browser == "FF")
            {
                if(!oXMLHTTPRequest) //Mozilla
                {
                    oXMLHTTPRequest = new XMLHttpRequest();
                }
            }
            return oXMLHTTPRequest;
        },      
        HTTPServerRequest : function(strURL,strPostParams,bIsResponseXML,oCallBackFunction,callbackParams)
        {
            var oResponseData = null;
			strURL = decodeAjax(strURL);
			strPostParams = strPostParams ? decodeAjax(strPostParams) : strPostParams;			
            var oXMLHTTPRequest = this.GetXMLHTTPRequest();
            
            if(oXMLHTTPRequest)
            {
                var strMethod = strPostParams ? 'POST' : 'GET';                
                oXMLHTTPRequest.open(strMethod, strURL, true);
                oXMLHTTPRequest.onreadystatechange = function()
                {
                    var bComplete = false;
                    try
                    {
                        if(oXMLHTTPRequest.readyState == 4 && oXMLHTTPRequest.status == 200)
                        {
                            bComplete = true;
                            if(bIsResponseXML)
                            {
                                oResponseData = oXMLHTTPRequest.responseXML;
                            }
                            else
                            {
                                oResponseData = oXMLHTTPRequest.responseText;
                            }
                        }
                    }
                    catch(ex)
                    {       
                        oResponseData = null;
                        bComplete = true;
                    }

                    if(bComplete && oCallBackFunction)
                    {
                        oCallBackFunction(oResponseData,callbackParams);
                    }
                }                       
                if(strPostParams)
                {
				    oXMLHTTPRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=iso-8859-8');
					//oXMLHTTPRequest.setRequestHeader('Content-Encoding','iso-8859-8');
					//oXMLHTTPRequest.setRequestHeader('Content-Language','he');
					oXMLHTTPRequest.setRequestHeader("Content-length", strPostParams.length);
					oXMLHTTPRequest.setRequestHeader("Connection", "close");


                }
                oXMLHTTPRequest.send(strPostParams);                                            
            }
            
            //return the request object
            return oXMLHTTPRequest;
        }       
}

function readXmlAjaxPage(AjaxPage)
{
    if (window.ActiveXObject)
    {
        var doc=new ActiveXObject("Microsoft.XMLDOM");
        doc.async="false";
        doc.loadXML(AjaxPage);
    }
    // code for Mozilla, Firefox, Opera, etc.
    else
    {
        var parser=new DOMParser();
        var doc=parser.parseFromString(AjaxPage,"text/xml");
    }
    if (browser == "MSIE")
    {     
        var custIdNode = doc.documentElement.childNodes[0];        
    }
    else if (browser == "FF")
    {        
        var custIdNode = doc.documentElement.childNodes[1];
    }  
    return custIdNode;      
}

function getXmlDoc(AjaxPage)
{
    if (window.ActiveXObject)
    {
        var doc=new ActiveXObject("Microsoft.XMLDOM");
        doc.async="false";
        doc.loadXML(AjaxPage);
    }
    // code for Mozilla, Firefox, Opera, etc.
    else
    {
        var parser=new DOMParser();
        var doc=parser.parseFromString(AjaxPage,"text/xml");
    }
    if (browser == "MSIE")
    {     
        var custIdNode = doc.documentElement;        
    }
    else if (browser == "FF")
    {        
        var custIdNode = doc.documentElement;
    }  
    return custIdNode;      
}


