   
   function QuotationUpdater()
   {
    var _openConnections=null;
    var _maxXmlHTTPConnections;
	var _pollingInterval; 
	var _updateCallBack;   
    var _requestURL;
   
	function GetXmlHTTP()
    {
		if(typeof XMLHttpRequest!="undefined")
		{
			return new XMLHttpRequest();
		}
		else if(typeof ActiveXObject != "undefined")
		{
			try
			{
				var xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
				return xmlhttp;
			}
			catch(e)
			{
				return null;
			}
		}
		return null;
	}
	
	 function GetUpdates()
	 {
        //get XMLHttp for mozilla or ie.
       
        var req=null;
        if(_openConnections!=null&&_openConnections.length>=_maxXmlHTTPConnections)
        {
            //We will just ignore this request, we can not serve it.
            return;
        }
        if  (req==null)
        {
            req=GetXmlHTTP();
        }           
        if(_openConnections==null) _openConnections=new Array();
        _openConnections.push(req);
        
        //We need to hook up onreadystatechange since this is an async call.  
        //When the response is received, this annonymous function will be called, which will in turn call LoadUpdates
        req.onreadystatechange=LoadUpdates;

        //Send the Request
//        var groupId = window.document.getElementById("_GroupIdHidden").value;
        //req.open("GET","BackOffice/QuotationHandler.ashx?CompanyId="+_companyId,true);
        
        //req.open("GET","http://localhost:1213/Reader/Dispenser.ashx?companyId="+companyId,true);
        req.open("GET",_requestURL,true);
        req.send(null);
     }

	 function LoadUpdates()
	 { 
        var req=null;
        for(var i=0;i<_openConnections.length;i++){
            if(_openConnections[i].readyState==4||_openConnections[i].readyState=='complete')
            {
                req=_openConnections[i];
                _openConnections.splice(i,1);
                break;
            }
        }
        if(req==null)return;
  
        
        //We can use responseText or responseXML.  I prefer responseXML because it is easier to navigate.
        var response=req.responseXML;
        
//        var serializer=new  ActiveXObject("Microsoft.XMLDOM");
//        var response=serializer.serializeToString(req.responseText);
       
        if(response.childNodes!=null&&response.childNodes.length>0){
            var updatesNode=response.firstChild;
            //Mozilla will add text nodes for things like "/r/n".  We want to skip over those nodes.
            while(updatesNode!=null&&updatesNode.nodeName!="updates")updatesNode=updatesNode.nextSibling;
            if(updatesNode==null)return;
            
            var children=updatesNode.childNodes;
            if(children!=null&&children.length>0)
            for( var i=0;i<children.length;i++){
                var node=children[i];
                
                //If the node isn't a "record" it is likely a text node.  Either way, we can skip it.
                if(node.nodeName!="record")continue;
                if(node!=null){
               
                    _updateCallBack(node);
                }
            }
        }

    }
	
	

    this.Initialize=function(pollingInterval,maxXmlHTTPConnections,requestURL,updateCallBack)
    {	
	 _pollingInterval=pollingInterval;
	 _maxXmlHTTPConnections=maxXmlHTTPConnections;
	 _requestURL =requestURL;
	 _updateCallBack=updateCallBack;
	  this.TimeID=window.setInterval(GetUpdates,_pollingInterval);			
	  
    }   
  }  
    
 

 
        


