

function encodeMe(value) 
{

    try {
      return escape(value);
    } catch(e) {
       return encodeURIComponent(value);
    }
   
}
     

function QAjax() 
{
	this.ajaxReq;
	
 	if (window.XMLHttpRequest) { 
        this.ajaxReq = new XMLHttpRequest();
        if (this.ajaxReq.overrideMimeType) {
            this.ajaxReq.overrideMimeType('text/xml');
        } 
    } else if (window.ActiveXObject) { 
        try {
             this.ajaxReq = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
          try {
             this.ajaxReq = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (e) {}
        }
    }

    if (!this.ajaxReq) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    
    this.ajaxReq.onreadystatechange = this.ajaxAutoResponder;
}

    
	QAjax.prototype.sndpgmmsg=function(msgText) {
	 	if  (this.msgAreaDivision) {
             this.msgAreaDivision.innerHTML = msgText;
        }
    }

	QAjax.prototype.ajaxAutoResponder=function() {
		if ( this.getReadyState() == 4 ) {
           if ( this.getStatus() == 200) {
                window.location = this.url;
           }
        }
    }

   
	QAjax.prototype.setURL = function(szURL) {
	     this.url = szURL;
	}
	
	QAjax.prototype.setCallback = function(newCallBack) {
	     this.ajaxReq.onreadystatechange = newCallBack;
	}
	
	QAjax.prototype.overrideMimeType=function(mimeType) {
		 this.ajaxReq.overrideMimeType(mimeType);
	}
	
    QAjax.prototype.activate = function() {
		this.ajaxReq.open('POST', this.url, true);
	    this.ajaxReq.send(null);
	}

	QAjax.prototype.setMessageArea=function(divName) {
		if  (divName) {
		    this.msgAreaDivision = divName;
		}
    }
 
	QAjax.prototype.setUser=function(theUser,thePWD) {
	    if (theUser) {
	        this.ajaxReq.userid = theUser;
	    }
	    if (thePWD) {
	        this.ajaxReq.pwd = thePWD;
	    }
	}
	
    QAjax.prototype.SendNow=function(url, usr, pwd) {
	    if (usr && pwd) {
	        this.ajaxReq.open('POST', url, true, usr, pwd);
	    }
	    else {
	        this.ajaxReq.open('POST', url, true);
	    }   
		this.ajaxReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	    this.ajaxReq.send(null);
	}  
	  
    QAjax.prototype.SendSignOn=function(url, usr, pwd) {
        if (url) {
           this.url = url;
        }
	    if (!this.ajaxReq.onreadystatechange || this.ajaxReq.onreadystatechange =="") { 
	         this.ajaxReq.onreadystatechange = this.ajaxAutoResponder;
	    }
	    if (usr && pwd) {
	        this.ajaxReq.open('POST', this.url, true, usr, pwd);
	    }
	    else {
	        this.ajaxReq.open('POST', this.url, true);
	    }  
		this.sndpgmmsg('<div style="color:green;">'+"Sign On in progress..."+'</span>');
		this.ajaxReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	    this.ajaxReq.send(null);
	}  

	
    QAjax.prototype.SendSync=function(url, usr, pwd) {
		this.ajaxReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	    this.ajaxReq.open('POST', url, false, usr, pwd);
	    this.ajaxReq.send(null);
	}  

	  
    QAjax.prototype.SendPost=function(url, params, usr, pwd) {
    	this.ajaxReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
    	if (params) {
    		this.ajaxReq.setRequestHeader("Content-length", params.length);
    	}
        this.ajaxReq.open('POST', url, false, usr, pwd);
	    this.ajaxReq.send(params);
	}    

	
    QAjax.prototype.getResponseXML=function() {
         return this.ajaxReq.responseXML;
    }
    
    QAjax.prototype.getResponseText=function() {
         return this.ajaxReq.responseText;
    }
    
    QAjax.prototype.getReadyState=function() {
         return this.ajaxReq.readyState;
    }
    
    QAjax.prototype.getStatus=function() {
         return this.ajaxReq.status;
    }
    
    QAjax.prototype.getXMLNodeText = function(myNode,i) {
       this.theNode = this.ajaxReq.responseXML.getElementsByTagName(myNode)[i];
       if  (this.theNode) {
            this.theNodeText  = this.theNode.childNodes[0];
           if  (this.theNodeText) {
	           return this.theNodeText.nodeValue;
           }
       }
    }
    
    QAjax.prototype.getXMLNodeText = function(myNode) {
       this.theNode = this.ajaxReq.responseXML.getElementsByTagName(myNode)[0];
       if  (this.theNode) {
            this.theNodeText  = this.theNode.childNodes[0];
           if  (this.theNodeText) {
	           return this.theNodeText.nodeValue;
           }
       }
    }
          