var lastId = "";
var pullStat = false;
var postmsg = false;
var msgthread = true;
var txtboxwidth = 0;
var txtboxheight = 0;
var sendbuttonurl;
var windowOnload = function () {
    if (window.postMessage) {
        postmsg = true;
    }
    try {
        if (document.createStyleSheet) {
            document.createStyleSheet('http://newchat.livehelper.com/Client_Chat/pullDiv.css');
        } else {
            var styles = "@import url('http://newchat.livehelper.com/Client_Chat/pullDiv.css');";
            var newSS = document.createElement('link');
            newSS.rel = 'stylesheet';
            newSS.href = 'data:text/css,' + styles;
            document.getElementsByTagName("head")[0].appendChild(newSS);
        }
    } catch (e) { }
}
windowOnload();
function endPull() {
    pullStat = false;
    hidePull();
    setTimeout('removePull()', 1000);
}
function postMssg() {
    var frameval = document.getElementById("PullIframe").contentWindow;
    if (frameval) {
        frameval.postMessage("initchat", "http://newchat.livehelper.com");
    } else {
        setTimeout('postMssg()', 1000);
    }
    if (msgthread) {
        setTimeout('postMssg()', 1000);
    }
}
function hidePull() {
    document.getElementById("pullClient").style.display = 'none';
}
function removePull() {
    if (!pullStat) {
        document.getElementById("pullClient").innerHTML = '';
    }
}
var checkForMessages = function () {
    if (pullStat) {
        try {
            if (location.hash != lastId) {
                lastId = location.hash;
                if (lastId.indexOf('ClosePull') != -1) {
                    endPull();
                } else if (lastId.indexOf('MaxPull') != -1) {
                    maxPull();
                } else if (lastId.indexOf('MinPull') != -1) {
                    minPull();
                }
            }
        } catch (exception) { }
    }
}
function messaging() {
    if (window.addEventListener) {
        window.addEventListener("message", function (e) {
            if (e.data == 'endchat') {
                endPull();
            } else if (e.data == 'maxchat') {
                maxPull();
            } else if (e.data == 'minchat') {
                minPull();
            } else if (e.data == 'msgon') {
                msgthread = false;
            }
        }, false);
    } else {
        window.attachEvent("onmessage", function (e) {
            if (e.data == 'endchat') {
                endPull();
            } else if (e.data == 'maxchat') {
                maxPull();
            } else if (e.data == 'minchat') {
                minPull();
            } else if (e.data == 'msgon') {
                msgthread = false;
            }
        }, false);
    }
}
function minPull() {
    var PullIframe = document.getElementById("PullIframe");
    if (PullIframe) {
        PullIframe.height = '38px';
    }
}
function maxPull() {
    var PullIframe = document.getElementById("PullIframe");
    if (PullIframe) {
        PullIframe.height = '252px';
    }
}
if (postmsg) {
    messaging();
} else {
    self.setInterval(checkForMessages, 1000);
}
var lhIA = new Array();
var lhOpera = false, lhBZ = navigator.userAgent;
var lhLN = "lhMenu";
if (lhBZ.search(/Opera/) != -1) lhOpera = true;
lhIe = (document.all) ? true : false; lhNs4 = (document.layers) ? true : false; lhNs6 = (document.getElementById && !document.all) ? true : false;
lhAF = new Image(), lhCI = new Image(), lhOA = new Image(), lhWZ = new Image();
var lhCK = true, lhSF = 1, lhRnd, lhC, lhG, lhP, lhBV, lhPl, lhDm, lhRf, lhTl, lhTD, lhCT, lhCR; lhAN = navigator.appName, lhBV = navigator.appVersion, lhPl = navigator.platform, lhDm = document.domain, lhRf = document.referrer, lhTl = document.title, lhPg = location.href;
var win = null; efaqWin = null;
var lhST = window.screen.availHeight, lhSW = window.screen.availWidth, lhSD = window.screen.colorDepth;
var lhSM = lhST + "x" + lhSW;
var lhJV, plnStr = "", lhLang, lhLT, lhNow = new Date();
lhLT = lhNow.valueOf();
if (lhNs4) { lhLang = navigator.language; for (pln in navigator.plugins) { plnStr += pln + ","; } }
if (plnStr.length > 499) { plnStr = " "; }
if (lhIe){lhLang=navigator.systemLanguage; 
}
if (!lhPg) lhPg = "local url";
function associateObjWithEvent(obj, methodName) { 
    return (function (e) {
        e = e || window.event;
        return obj[methodName](e, this);
    });
}
var lh_WIN;
function lhLoadChatDirect(companyId, groupName, pageId) {
    var protocol = "http://"; var ssl = "DISABLED";
    if (lh_WIN != null && !lh_WIN.closed) {
        lh_WIN.focus();
    } else {
        lhHaschatted = true;
        var name = "chat1";
        var lhRnd = Math.random();
        if (parseInt(wsz) == 1) {
            lhG1 = unescape(groupName);
            var url = protocol + "newchat.livehelper.com/servlet/lhChat?ACTION=SENDNAMEENTRYSCREEN&WINDOWSIZE=1&COMPANYID=" + companyId + "&GROUPNAME=" + escape(lhG1) + "&RND=" + lhRnd + "&SSL=" + ssl + "&nocache=" + Math.random();
            lh_WIN = window.open(url, name, "toolbar=no,menubar=no,directories=no,status=no,location=no,resizable=yes,scrollbars=no,width=451,height=351");
        }
        else {
            lhG1 = unescape(groupName);
            var url = protocol + "newchat.livehelper.com/servlet/lhChat?ACTION=SENDNAMEENTRYSCREEN&WINDOWSIZE=0&COMPANYID=" + companyId + "&GROUPNAME=" + escape(lhG1) + "&RND=" + lhRnd + "&SSL=" + ssl + "&nocache=" + Math.random();
            lh_WIN = window.open(url, name, "toolbar=no,menubar=no,directories=no,status=no,location=no,resizable=yes,scrollbars=no,width=296,height=301");
        }
        if (lh_WIN != null && !lh_WIN.closed) {
            lh_WIN.focus();
        }
    }
}

function lhLoadEfaq(c, g, p) {
    var protocol = "http://"; var ssl = "DISABLED";
    try {
        lh_Efaq.focus();
        if (navigator.userAgent.indexOf("IE") == -1)
            if (lh_Efaq.document == null) lh_Efaq.document.open();
    } catch (e) {
        var n = "efaqwin";
        var u = protocol + "newchat.livehelper.com/servlet/lhSelfHelp?ACTION=QUESTIONENTRYSCREEN&COMPANYID=" + c + "&SSL=" + ssl;
        lh_Efaq = window.open(u, n, 'width=700,height=400,toolbar=no,menubar=no,directories=no,resizable=yes,scrollbars=yes');
        lh_Efaq.focus();
    }

}
function lhLoadEmail(c, g, p) {
    var protocol = "http://"; var ssl = "DISABLED";
    if (lh_WIN != null && !lh_WIN.closed) {
        lh_WIN.focus();
    } else {
        lhHaschatted = true;
        var name = "email1";
        var lhRnd = Math.random();
        if (parseInt(wsz) == 1) {
            lhG1 = unescape(g);
            var url = protocol + "newchat.livehelper.com/servlet/lhChat?ACTION=SENDMAIL&WINDOWSIZE=1&COMPANYID=" + c + "&GROUPNAME=" + g + "&SSL=" + ssl;
            lh_WIN = window.open(url, name, "toolbar=no,menubar=no,directories=no,status=no,location=no,resizable=yes,scrollbars=no,width=451,height=351");
        }
        else {
            lhG1 = unescape(g);
            var url = protocol + "newchat.livehelper.com/servlet/lhChat?ACTION=SENDMAIL&WINDOWSIZE=0&COMPANYID=" + c + "&GROUPNAME=" + g + "&SSL=" + ssl;
            lh_WIN = window.open(url, name, "toolbar=no,menubar=no,directories=no,status=no,location=no,resizable=yes,scrollbars=no,width=296,height=301");
        }
        if (lh_WIN != null && !lh_WIN.closed) {
            lh_WIN.focus();
        }
    }
}
var N6 = (document.getElementById && !document.all) ? true : false;
var lh_WIN, lh_Efaq;
//var pageVisit = "true";
var liveEngaged = false;
var liveCount = 1;
var liveEngageUrl = null;
var wsz = null
var pullFailed = 0;
var defaultImage = new Image();
defaultImage.src = "http://www.livehelper.com/images4/logo9].gif";
function LHBtnMsgQ() {
    var rnd = Math.random();
    var pageVisit = "true";
    var based = null;
    var id;
    var validity = 1;
    var last_response_time;
    var start_refresh = false;
    var interval = 15000;
    var inVector = new Array();
    var outVector = new Array();

    var request = null;
    var sending = false;
    var lastMsg = "";
    var protocol = "http://";
    var ssl = "DISABLED";
    var imgOnline = new Image();
    var imgOffline = new Image();
    var onlineText, offlineText,statusText;
    //var windowSize=0;
    var windowSize = null;
    var imgID = Math.random(); 
    var imgID2 = Math.random();
    var isPulled = 0;
    var c = null;
    var g = null;
    var op = null;
    var p = null;
    var t = null;
    var lt = null;
    var opStatus = 2;
    var lh_PWin = null;
    var isLiveEngage = false;
    var LastHeadLoc = null;
    var LastScripObj = null;
    this.callLiveInteraction = function (script) {
        if (script != null) {
            try {
                eval(script);
            } catch (e) {
            }
        }
    }
    this.getValidity = function () { return validity; }
    this.setId = function (_id) {
        id = _id;
    }
    this.setParams = function (_c, _g, _op, _p, _b, t) {
        c = _c; g = _g; op = _op; p = _p; based = _b;
        if (t == "imagetext") lt = _op;
    }
    this.setOpStatus = function (obj) {
        var v = obj.opstatus;
        if (v != null)
            opStatus = parseInt(v);
        showStatus();
    }
    this.initWindowSize = function () {
        getWindowSize()
    }
    function getWindowSize() {
        var url = protocol + "newchat.livehelper.com/servlet/lhChat?ACTION=GETWINDOWSIZE&c=" + c + "&id=" + id;
        sendCall(url);
    }
    this.setWindowSize = function (obj) {
        var v = obj.windowsize;
        if (v != null)
            windowSize = parseInt(v);
    }
    var o = this;
    var f = function () {
        start_refresh = true;
        var url = "newbrowse.livehelper.com/servlet/lhBrowse?ACTION=BTNREFRESH&RND=" + rnd + "&p=" + unescape(p) + "&c=" + escape(c) + "&b=" + escape(based) + "&g=" + escape(g) + "&op=" + escape(op) + "&PAGEVISIT=" + pageVisit + "&r=" + (Math.random() + 1) + "&a=" + navigator.appName + "&v=" + parseFloat(lhBV) + "&pl=" + lhPl + "&dm=" + lhDm + "&rf=" + escape(lhRf) + "&tl=" + lhTl + "&cs=true" + "&pg=" + escape(lhPg) + "&sd1=" + lhSM + "&sd2=" + lhSD + "&jsv=" + lhJV + "&ps=" + plnStr + "&lot=" + lhLT + "&ll=" + lhLang + "&LC=" + liveCount + "&pullFailed=" + pullFailed + "&nocache=" + Math.random() + "&id=" + id;
        if (pullFailed == 1)
            pullFailed = 0;
        pageVisit = "false";
        url = protocol + url;
        if (p != "" || t == "invisible")
            sendCall(url);
    }
    var checkIdle = function () {
        if (last_response_time) {
            var residletime = new Date() - last_response_time;
            if (residletime > 60000) {
                setTimeout(f, 10000);
            }
        }
    }
    self.setInterval(checkIdle, interval);
    this.Refresh = function () { setTimeout(f, interval); }
    this.SetProtocol = function (httpType) { protocol = (httpType == "ENABLED") ? "https://" : "http://"; ssl = httpType; }
    this.GetRnd = function () { return rnd; }
    this.setIconImages = function (on, off, type) {
        t = type;
        var _html; var buttonID;		
        switch (t) { 
            case "image":  //image 
                if (document.images) {
                    if (imgOnline != null) imgOnline.src = on;
                    if (imgOffline != null) imgOffline.src = off;
                    _html = '<div>' +
						  	'<div>' +
								'<img id="' + imgID + '" src="' + protocol + 'www.livehelper.com/images/blank.gif" onclick="" alt=""/>' +
							'</div>' +
							'<div id ="pullClient"></div>' +
							'</div>';
                    document.write(_html);
                    if (document.getElementById(imgID) != null) {
                        buttonID = document.getElementById(imgID);
                        buttonID.style.visibility = "hidden";
                        buttonID.style.cursor = "pointer";
                        if (defaultImage != null) {
                            if (imgOnline.src == defaultImage.src) buttonID.src = defaultImage.src;
                            buttonID.style.visibility = "visible";
                        }
                        buttonID.onclick = associateObjWithEvent(this, "doOnClick");
                    }
                }
                break;
            // end case   
            case "text": //text			    
                onlineText = on; offlineText = off;	
					
				if(on != off) statusText = on;
				else {
                	statusText  = (opStatus == 2) ? off : on;
				}
						 _html = '<div>' +
					  		'<div>' +
								'<a href="#"><span id="' + imgID + '"  onclick="" /> ' + statusText + ' </span></a>' +
							'</div>' +
							'<div id ="pullClient"></div>' +
						'</div>';
                document.write(_html);
			    if (document.getElementById(imgID) !=null) { 			 
                    buttonID = document.getElementById(imgID);  
							//if(on != off)  buttonID.style.visibility ="hidden";
							//else buttonID.innerHTML = onlineText ;
                    buttonID.style.cursor = "pointer";
                    buttonID.onclick = associateObjWithEvent(this, "doOnClick");
                }				
                break;
            case "imagetext":
                if (imgOnline != null) imgOnline.src = on;
                if (imgOffline != null) imgOffline.src = off;
                onlineText = offlineText = lt;
                _html = '<div>' +
					  		'<div>' +
								'<a href="#"><span id="' + imgID2 + '"  onclick="" /></span></a>' + '<img id="' + imgID + '" src="' + protocol + 'www.livehelper.com/images/blank.gif" onclick="" alt=""/>' +
							'</div>' +
							'<div id ="pullClient"></div>' +
						'</div>';
                document.write(_html);
                if (document.getElementById(imgID2) != null) {
                    var textID = document.getElementById(imgID2);
                    textID.innerHTML = onlineText;
                    textID.style.cursor = "pointer";
                    textID.onclick = associateObjWithEvent(this, "doOnClick");
                }
                if (document.getElementById(imgID) != null) {
                    buttonID = document.getElementById(imgID);
                    buttonID.style.visibility = "hidden";
                    buttonID.style.cursor = "pointer";
                    if (defaultImage != null) {
                        if (imgOnline.src == defaultImage.src) buttonID.src = defaultImage.src;
                        buttonID.style.visibility = "visible";
                    }
                    buttonID.onclick = associateObjWithEvent(this, "doOnClick");
                }
                break;
            // end case  
            case "efaq": //efaq
                if (document.images) {
                    imgOnline.src = on; imgOffline.src = off;
                    _html = '<div>' +
							'<div>' +
								'<img id="' + imgID + '" src="' + protocol + 'www.livehelper.com/images/blank.gif" onclick="" alt="" />' +
							'</div>' +
							'<div id ="pullClient"></div>' +
						'</div>';
                    document.write(_html);
                    if (document.getElementById(imgID)) {
                        buttonID = document.getElementById(imgID);
                        if (defaultImage != null && defaultImage.complete) {
                            if (imgOnline.src == defaultImage.src)
                                buttonID.src = defaultImage.src;
                            else
                                buttonID.src = imgOnline.src;
                            buttonID.alt = "Efaq";
                        }
                        buttonID.style.cursor = "pointer";
                        buttonID.onclick = associateObjWithEvent(this, "bindEfaq");
                    }
                }
                break;
            // end case  
            case "msgbox":
                if (document.images) {
                    if (imgOnline != null) imgOnline.src = on;
                    if (imgOffline != null) imgOffline.src = off;
                    _html = '<div>' +
							'<div align="center">' +
								'<img id="' + imgID + '" src="' + protocol + 'www.livehelper.com/images/blank.gif" onclick="" alt=""/>' +
							'</div>' +
							'<div align="center">' +
								'<textarea name="textfield" id="lhMsgtflD" class="lhtextnewTfld" style="width:' + txtboxwidth + 'px; height:' + txtboxheight + 'px"></textarea>' +
							'</div>' +
							'<div align="center" style="margin-top:2px;">' +
								'<a href="#" id="lhMsgSendTrigger">' +
									'<img border="0" alt="" src="' + sendbuttonurl + '"/>' +
								'</a>' +
							'</div>' +
							'<div id ="pullClient"></div>' +
						'</div>';
                    document.write(_html);
                    if (document.getElementById(imgID) != null) {
                        buttonID = document.getElementById(imgID);
                        buttonID.style.visibility = "hidden";
                        if (defaultImage != null) {
                            if (imgOnline.src == defaultImage.src)
                                buttonID.src = defaultImage.src;
                            buttonID.style.visibility = "visible";
                        }
                    }
                    if (document.getElementById("lhMsgSendTrigger")) {
                        document.getElementById("lhMsgSendTrigger").onclick = associateObjWithEvent(this, "doOnMsgSend");
                    }
                }
                break;
            case "invisible": // invisible
                document.write('<div id ="pullClient"></div>');
                break;
            // end case  
            default:
                break;
        }
    }

    this.doOnClick = function (evt, elt) { if (elt.id == imgID || elt.id == imgID2) lh_loadChat(); }
    this.doOnMsgSend = function (evt, elt) { sendFromMsgWindow(); }
    this.bindEfaq = function (evt, elt) { if (elt.id == imgID) lh_loadEfaq(); }
    this.getCallback = function (jData) {
        if (jData == null) {
            return;
        }
        if (jData.opstatus != null) opStatus = parseInt(jData.opstatus);
        if (jData.windowsize != null) windowSize = parseInt(jData.windowsize);
        if (jData.validity != null) validity = parseInt(jData.validity);
        if (jData.ispulled != null) isPulled = parseInt(jData.ispulled);
        showStatus();
        var delay = new Date() - last_response_time;
        if (validity != 0 && start_refresh && delay > interval) {
            setTimeout(f, interval);
        }
        last_response_time = new Date();
        JSONremoveRequest();
    }
    this.callRequest = function (url) { sendCall(url); }
    function sendCall(url) {
        request = url;
        aObj = new JSONscriptRequest(request);
        aObj.buildScriptTag();
        aObj.addScriptTag();
    }
    function JSONscriptRequest(fullUrl) {
        this.fullUrl = fullUrl;
        this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
        this.headLoc = document.getElementsByTagName("head").item(0);
        LastHeadLoc = this.headLoc;
        this.scriptId = 'YJscriptId' + JSONscriptRequest.scriptCounter++;
    }
    function JSONremoveRequest() {
        JSONscriptRequest.prototype.removeScriptTag();
    }
    JSONscriptRequest.scriptCounter = 1;
    JSONscriptRequest.prototype.buildScriptTag = function () {
        this.scriptObj = document.createElement("script");
        LastScripObj = this.scriptObj;
        this.scriptObj.setAttribute("type", "text/javascript");
        this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE);
        this.scriptObj.setAttribute("id", this.scriptId);
    }
    JSONscriptRequest.prototype.removeScriptTag = function () {
        try {
            if (LastHeadLoc != null && LastScripObj != null)
                LastHeadLoc.removeChild(LastScripObj);
        } catch (e) { }
    }
    JSONscriptRequest.prototype.addScriptTag = function () {
        this.headLoc.appendChild(this.scriptObj);
    }
    function showStatus() {
        switch (t) {
            case "efaq":
                if (document.getElementById(imgID) != null) {
                    var IMG = document.getElementById(imgID);
                    if (defaultImage.complete) {
                        IMG.src = defaultImage.src;
                        IMG.alt = "Efaq";
                    }
                }
                break;
            case "image": if (document.getElementById(imgID) != null) {
                    var IMG = document.getElementById(imgID);
                    if (IMG.src != defaultImage.src)
                        IMG.style.visibility = (opStatus == 2) ? "hidden" : "visible";
                    if (opStatus != 2) {
                        if (document.images) {
                            if (imgOnline.src == defaultImage.src) {
                                IMG.src = defaultImage.src;
                            } else {
                                IMG.src = (opStatus == 1) ? imgOnline.src : imgOffline.src;
                            } //else
                        } //if
                    } //if
                }
                break;
            case "text": if (document.getElementById(imgID) != null) {
                    var IMG = document.getElementById(imgID);
                    IMG.style.visibility = (opStatus == 2) ? "hidden" : "visible";
                    if (opStatus != 2) {
                        IMG.innerHTML = (opStatus == 1) ? onlineText : offlineText;
                    }
                }
                break;
            case "imagetext":
                if (document.getElementById(imgID2) != null) {
                    var IMG2 = document.getElementById(imgID2);
                    IMG2.style.visibility = (opStatus == 2) ? "hidden" : "visible";
                    if (opStatus != 2) {
                        IMG2.innerHTML = (opStatus == 1) ? onlineText : offlineText;
                    }
                } 
                    if (document.getElementById(imgID) != null) {
                    var IMG = document.getElementById(imgID);
                    if (IMG.src != defaultImage.src)
                        IMG.style.visibility = (opStatus == 2) ? "hidden" : "visible";
                    if (opStatus != 2) {
                        if (document.images) {
                            if (imgOnline.src == defaultImage.src) {
                                IMG.src = defaultImage.src;
                            } else {
                                IMG.src = (opStatus == 1) ? imgOnline.src : imgOffline.src;
                            } //else
                        } //if
                    } //if
                }
                break;
            case "msgbox": if (document.getElementById(imgID) != null) {
                    var IMG = document.getElementById(imgID);
                    if (IMG.src != defaultImage.src)
                        IMG.style.visibility = (opStatus == 2) ? "hidden" : "visible";
                    if (opStatus != 2) {
                        if (document.images) {
                            if (imgOnline.src == defaultImage.src) {
                                IMG.src = defaultImage.src;
                            } else {
                                IMG.src = (opStatus == 1) ? imgOnline.src : imgOffline.src;
                            } //else
                        } //if
                    } //if
                }
                break;
            case "invisible": break;
            default:
        }
        if (isPulled == 1) {
            if (document.getElementById("pullClient") != null) {
                document.getElementById("pullClient").style.display = 'block';
                var loc = window.location;
                var u = protocol + "newchat.livehelper.com/servlet/lhChat?ACTION=SENDCHATSCREEN&WINDOWSIZE=" + windowSize + "&COMPANYID=" + c +
				"&GROUPNAME=" + escape(g) + "&CHATTYPE=Text&CLIENTNAME=Visitor&RND=" + rnd + "&SSL=" + ssl + "&LOC=" + loc + "&nocache=" + Math.random();
                document.getElementById("pullClient").innerHTML = '<div name="PullClientDiv" id="PullClientDiv" class="fixed-pullDiv">' +
						'<iframe frameborder="0" src=' + u + ' width="271" height="252" scrolling="no" id="PullIframe">' +
						'</iframe>' +
		        '</div>';
                pullStat = true;
                isPulled = 0;
                if (postmsg) {
                    postMssg();
                }
            }
        } else if (isPulled == -1 && pullStat) {
            if (document.getElementById("pullClient"))
                document.getElementById("pullClient").style.display = 'none';
            isPulled = 0;
            pullStat = false;
        }
    }
    function lh_loadEfaq() {
        try {
            lh_Efaq.focus();
            if (navigator.userAgent.indexOf("IE") == -1)
                if (lh_Efaq.document == null) lh_Efaq.document.open();
        } catch (e) {
            var n = "efaqwin";
            var u = protocol + "newchat.livehelper.com/servlet/lhSelfHelp?ACTION=QUESTIONENTRYSCREEN&COMPANYID=" + c + "&SSL=" + ssl;
            lh_Efaq = window.open(u, n, 'width=700,height=400,toolbar=no,menubar=no,directories=no,resizable=yes,scrollbars=yes');
            lh_Efaq.focus();
        }
    }
    function lh_loadChat() {
        if (lh_WIN != null && !lh_WIN.closed) {
            lh_WIN.focus();
        } else {
            var name = "chat1"; var lhRnd = Math.random();
            var action;
            if (based == "operator") action = "SENDNAMEENTRYSCREENOPERATOR";
            else if (based == "group") action = "SENDNAMEENTRYSCREENGROUP";
            else action = "SENDNAMEENTRYSCREEN";
            if (parseInt(windowSize) == 1) {
                var url = protocol + "newchat.livehelper.com/servlet/lhChat?ACTION=" + action + "&WINDOWSIZE=1&COMPANYID=" + c +
				"&GROUPNAME=" + unescape(g) + "&OPERATOR=" + unescape(op) +
				"&RND=" + lhRnd + "&SSL=" + ssl + "&nocache=" + Math.random();
                lh_WIN = window.open(url, name, "toolbar=no,menubar=no,directories=no,status=no,location=no,resizable=yes,scrollbars=no,width=451,height=351");
            } else {
                var url1 = protocol + "newchat.livehelper.com/servlet/lhChat?ACTION=" + action + "&WINDOWSIZE=0&COMPANYID=" + c +
				"&GROUPNAME=" + unescape(g) + "&OPERATOR=" + unescape(op) +
				"&RND=" + lhRnd + "&SSL=" + ssl + "&nocache=" + Math.random();
                lh_WIN = window.open(url1, name, "toolbar=no,menubar=no,directories=no,status=no,location=no,resizable=yes,scrollbars=no,width=296,height=301");
            }
            if (lh_WIN != null && !lh_WIN.closed) {
                lh_WIN.focus();
            }
        }
    }
    function closeMsgWindow() {
        if (document.getElementById("pullClient") != null) {
            document.getElementById("pullClient").innerHTML = '';
        }
    }
    function sendFromMsgWindow() {
        if (lh_WIN != null && !lh_WIN.closed) {
            lh_WIN.focus();
        } else {
            var name = "Msgchat";
            var lhRnd = Math.random();
            var action;
            if (based == "operator") action = "SENDNAMEENTRYSCREENOPERATOR";
            else if (based == "group") action = "SENDNAMEENTRYSCREENGROUP";
            else action = "SENDNAMEENTRYSCREEN";
            var inimsg = document.getElementById("lhMsgtflD");
            var inmsgval = "";
            if (inimsg) {
                inmsgval = inimsg.value;
                inimsg.value = "";
            }
            if (inmsgval != "") {
                if (parseInt(windowSize) == 1) {
                    var url = protocol + "newchat.livehelper.com/servlet/lhChat?ACTION=" + action + "&WINDOWSIZE=1&COMPANYID=" + c +
					"&GROUPNAME=" + unescape(g) + "&OPERATOR=" + unescape(op) +
					"&RND=" + lhRnd + "&SSL=" + ssl + "&nocache=" + Math.random() + "&INITIALMSG=" + inmsgval;
                    lh_WIN = window.open(url, name, "toolbar=no,menubar=no,directories=no,status=no,location=no,resizable=yes,scrollbars=no,width=451,height=351");
                } else {
                    var url1 = protocol + "newchat.livehelper.com/servlet/lhChat?ACTION=" + action + "&WINDOWSIZE=0&COMPANYID=" + c +
					"&GROUPNAME=" + unescape(g) + "&OPERATOR=" + unescape(op) +
					"&RND=" + lhRnd + "&SSL=" + ssl + "&nocache=" + Math.random() + "&INITIALMSG=" + inmsgval;
                    lh_WIN = window.open(url1, name, "toolbar=no,menubar=no,directories=no,status=no,location=no,resizable=yes,scrollbars=no,width=296,height=301");
                }
                if (lh_WIN != null && !lh_WIN.closed) {
                    lh_WIN.focus();
                }
            }
        }
    }
}

var pool = new Array();
var l = 0;
function createButtonImage(c, g, op, p, o, z, t, b) {
    var lhBtnMsg = new LHBtnMsgQ();
    if (lhBtnMsg) {
        var protocol = "http://";
        lhBtnMsg.SetProtocol("DISABLED");
        lhBtnMsg.setParams(c, g, op, p, b, t);
        if (op == "imagetext") op = "";
        var urlbr = "newbrowse.livehelper.com/servlet/lhBrowse?ACTION=BTNINIT&c=" + escape(c) + "&b=" + escape(b) + "&g=" + escape(g) + "&op=" + escape(op) + "&p=" + unescape(p) + "&RND=" + lhBtnMsg.GetRnd() + "&nocache=" + Math.random() + "&id=" + l;
        urlbr = protocol + urlbr;
		if(z == "" && o == "" && (t == "image" || t == "efaq")){ 
            z = defaultImage.src; o = z;
        }
        lhBtnMsg.setIconImages(o, z, t);
        lhBtnMsg.setId(l++);
        pool.push(lhBtnMsg);
        if (p != "" || t == "invisible") {
            lhBtnMsg.callRequest(urlbr);  // Send BTNINIT
            lhBtnMsg.initWindowSize();
            lhBtnMsg.Refresh();
        }
    }
}
function setIcon(c, g, p) {
    createButtonImage(c, g, escape(""), p, "", "", "image", null);
}
function setIcon_NoTracker(c, g, p) {
    createButtonImage(c, g, "", p, "", "", "image", null);
}
function setIconImg(c, g, p, i) {
    createButtonImage(c, g, "", p, i, i, "image", "company");
}
function setIconStatusGroup(c, g, p, o, z, t) {
    createButtonImage(c, g, "", p, o, z, "image", "group");
}

function setIconStatusGroup_NoTracker(c, g, p, o, z, t) {
    createButtonImage(c, g, "", p, o, z, "image", "group");
}
function setIconStatusOperator(c, g, r, p, o, z, t) {
    createButtonImage(c, g, r, p, o, z, "image", "operator");
}
function setIconStatusOperator_NoTracker(c, g, r, p, o, z, t) {
    createButtonImage(c, g, r, p, o, z, "image", "operator");
}
function setIconBsyImg(c, g, p, o, z, t) {
    if (t == "text" && o == z)
        createButtonImage(c, g, "", p, o, z, "text", "company");
    else if (t != "text")
        createButtonImage(c, g, "", p, o, z, "image", "company");
}
function setIconImageText(c, g, l, p, o, z, t) {
    createButtonImage(c, g, l, p, o, z, "imagetext", t);
}
function setIconBsyImg_NoTracker(c, g, p, o, z, t) {
    if (t == "text")
        createButtonImage(c, g, "", p, o, z, "text", "company");
    else
        createButtonImage(c, g, "", p, o, z, "image", "company");
}
function setIconTextNew(c, g, p, o, z) {
    createButtonImage(c, g, "", p, o, z, "text", "company");
}
function setIconTextNewGroup(c, g, p, o, z) {
    createButtonImage(c, g, "", p, o, z, "text", "group");
}
function setIconTextNewOperator(c, g, r, p, o, z) {
    createButtonImage(c, g, r, p, o, z, "text", "operator");
}
function setIconText(c, g, p, t) {
    setIconTextNew(c, g, p, t, t);
}
function setIconInvisible(c, g, p) {
    if (!g) g = "	";
    createButtonImage(c, escape(g), "", p, "", "", "invisible", null);
}
function setIconEfaq(c, g, p) {
    createButtonImage(c, g, "", p, "", "", "efaq", null);
}
function setIconBrowse(c, g, p) {
    createButtonImage(c, g, "", p, "", "", "image", "company");
}
function lhSendInfoTag(CID, name, value) {
    var IPAdd = "newbrowse.livehelper.com";
    var str = "http://" + IPAdd + "/servlet/lhBrowse?ACTION=INFOTAG&";
    var len = arguments.length;
    if (len <= 1 || len % 2 == 0) {
        return;
    }
    var tagstr = "";
    for (i = 1; i < len; i += 2) {
        tagstr += escape(arguments[i]) + escape("^") + escape(arguments[i + 1]) + escape(";");
    }
    str += "C=" + CID + "&TAGDATA=" + tagstr;
    var img = new Image();
    var str1 = str;
    img.src = str1;
    return;
}
function loadMsgBox(companeyid, groupname, pageid, imgwidth, imgheight, imgurl, offimgurl, buturl) {
    txtboxwidth = imgwidth;
    txtboxheight = imgheight;
    sendbuttonurl = buturl;
    if (!groupname)
        groupname = "	";
    createButtonImage(companeyid, escape(groupname), "", escape(pageid), imgurl, offimgurl, "msgbox", "group");
}
