﻿
 function openLiveChat(domain)
 {
    window.open('LiveChat.aspx?domain=' + domain ,'LiveChat','width=480,height=360,toolbar=no,scrollbars=no,location=no,resizable=no');
 }  
 

 
 
 //Call the server code to display the correct live chat button
        function CallServerForLiveChatStatus(){
            CallServerForLiveChatStatus('en-GB');        
        }
        
        //Call the server code to display the correct live chat button
        function CallServerForLiveChatStatus(culture){

          var url= 'LiveChatOperatorStatus.get?culture='+ culture + '&rand=' + new Date().getTime();
          var req = newXMLHttpRequest();
          var callbackHandler = getReadyStateHandler(req);
          req.onreadystatechange = callbackHandler;
          req.open("GET", url, true);
          req.setRequestHeader("Content-Type", "text/xml");
      
          req.send("");
        }
        
        //create a XmlHttp object
        function newXMLHttpRequest() {
        var xmlreq = false;
        //if support XmlHttp, then create the XmlHttp object
        if (window.XMLHttpRequest) {
	        xmlreq = new XMLHttpRequest();
        } else if (window.ActiveXObject) {
		        // judge whether to support the XmlHttp ActiveX
	        try { 
		        xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
	        } catch (e1) { 
		        // fail in creaing the first ActiveX control
		        try {
			        xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
		        } catch (e2) {
			         // both failed, then return false
		        } 
	        }
        }
        return xmlreq;
        } 

        //the server side callback function
        function getReadyStateHandler(req) {
	        return function () {
	        if (req.readyState == 4) {//already loaded
		        if (req.status == 200) {//return successfully
		       
		            if(req.responseText == "True"){		            
		        
		                document.getElementById("liveChat").style.display = 'block';
		                document.getElementById("contactSales").style.display = 'none';
		               
		            }else{
		               document.getElementById("liveChat").style.display = 'none';
		                document.getElementById("contactSales").style.display = 'block';
		            }
		        
		        } 
    	        }
 	        }
        }
        
       