var lc_BaseUrl = 'http://www.chat-to-us.com/';
var lc_refer = encodeURIComponent(document.referrer);
var lc_IE8 = window.XDomainRequest ? true : false;
function lc_XMLHttpRequest(ReqUrl, Response) {
    if (lc_IE8) {
        return new window.XDomainRequest;
    }
    else {
        return new XMLHttpRequest;
    }
}
function lc_LiveInvite() {
    var lc_url = lc_BaseUrl + 'chattous/invite.ashx';
    var lc_bustcache = '?rnd=' + new Date().getTime();
    var lc_login = '&ctu_user=' + ctu_user + '&ctu_pass=' + ctu_pass;
    var lc_req = lc_XMLHttpRequest(lc_url + lc_bustcache + lc_login, lc_Response);
    if (lc_req) {
        if (lc_IE8) {
            lc_req.onload = lc_ShowInvite(lc_req);
            lc_req.open('Get', lc_url + lc_bustcache + lc_login, true);
            lc_req.send();
        }
        else {
            lc_req.open('Get', lc_url + lc_bustcache + lc_login, true);
            lc_req.onreadystatechange = lc_Response(lc_req);
            lc_req.send();
        }
    }
}
function lc_Response(XMLReq) {
    if (XMLReq.readyState == 4) {
        if (XMLReq.status == 200) {
            lc_ShowInvite(XMLReq)
        }
    }
}
function lc_ShowInvite(XMLReq) {
    var lc_InviteText = XMLReq.responseText;
    var lc_ChatInvite = document.all ? document.all['lc_invite'] : document.getElementById('lc_invite');
    var lc_ChatMessage = document.all ? document.all['lc_message'] : document.getElementById('lc_message');
    if (lc_InviteText != '') {
        lc_ChatMessage.innerHTML = lc_InviteText;
        lc_ChatInvite.style.display = '';
        ChatInvite.style.visibility = '';
    }
}
function lc_ShowChat(floating) {
    var lc_url = lc_BaseUrl + 'chattous/operator.ashx';
    var lc_extra = '?referer=' + lc_refer + '&cd=' + window.screen.colorDepth + '&rh=' + screen.height + '&rw=' + screen.width + '&tz=' + (new Date().getTimezoneOffset() / 60) * -1;
    var lc_login = '&ctu_user=' + ctu_user + '&ctu_pass=' + ctu_pass;
    var lc_icon = '';
    try {
        lc_icon = '&ctu_icon=' + ctu_icon;
    } catch (e) {
        lc_icon = '&ctu_icon=';
    }
    var lc_Item = '<div id="lc_window"><a href="javascript:lc_LiveChat()"><img id="_imgLC" src="' + lc_url + lc_extra + lc_login + lc_icon + '" style="border:0px" alt="Click here for live chat" title="Click here for live chat"></a></div>';
    if (typeof (window.innerHeight) == 'number') {
        lc_yoff = window.innerHeight / 2;
    } else {
        if (document.documentElement && document.documentElement.clientHeight) {
            lc_yoff = document.documentElement.clientHeight / 2;
        } else {
            if (document.body && document.body.clientHeight) {
                lc_yoff = document.body.clientHeight / 2;
            }
        }
    }
    if (floating == 1) {
        lc_drawLogo(lc_Item, '', 153, 67, floating, ctu_xoff, ctu_yoff, true)
    } else if (floating == 2) {
        lc_drawLogo(lc_Item, '', 153, 67, floating, -ctu_xoff, ctu_yoff, true)
    } else if (floating == 3) {
        lc_drawLogo(lc_Item, '', 153, 67, floating, ctu_xoff, -ctu_yoff, true)
    } else if (floating == 4) {
        lc_drawLogo(lc_Item, '', 153, 67, floating, -ctu_xoff, -ctu_yoff, true)
    } else if (floating == 5) {
        lc_drawLogo(lc_Item, '', 153, 67, floating, ctu_xoff, lc_yoff, true)
    } else if (floating == 6) {
        lc_drawLogo(lc_Item, '', 153, 67, floating, -ctu_xoff, lc_yoff, true)
    } else {
        document.write(lc_Item);
    }
}
function lc_IconOnly(floating) {
    var lc_url = lc_BaseUrl + 'chattous/icononly.ashx';
    var lc_extra = '?referer=' + lc_refer + '&cd=' + window.screen.colorDepth + '&rh=' + screen.height + '&rw=' + screen.width + '&tz=' + (new Date().getTimezoneOffset() / 60) * -1;
    var lc_login = '&ctu_user=' + ctu_user + '&ctu_pass=' + ctu_pass;
    var lc_icon = '';
    try {
        lc_icon = '&ctu_icon=' + ctu_icon;
    } catch (e) {
        lc_icon = '&ctu_icon=';
    }
    lc_Item = '<div id="lc_window"><a href="javascript:LiveChat()"><img id="_imgLC" src="' + lc_url + lc_extra + lc_login + lc_icon + '" style="border:0px" alt="Click here for live chat" title="Click here for live chat"></a></div>';
    if (typeof (window.innerHeight) == 'number') {
        lc_yoff = window.innerHeight / 2;
    } else {
        if (document.documentElement && document.documentElement.clientHeight) {
            lc_yoff = document.documentElement.clientHeight / 2;
        } else {
            if (document.body && document.body.clientHeight) {
                lc_yoff = document.body.clientHeight / 2;
            }
        }
    }
    if (floating == 1) {
        lc_drawLogo(lc_Item, '', 153, 67, floating, ctu_xoff, ctu_yoff, true)
    } else if (floating == 2) {
        lc_drawLogo(lc_Item, '', 153, 67, floating, -ctu_xoff, ctu_yoff, true)
    } else if (floating == 3) {
        lc_drawLogo(lc_Item, '', 153, 67, floating, ctu_xoff, -ctu_yoff, true)
    } else if (floating == 4) {
        lc_drawLogo(lc_Item, '', 153, 67, floating, -ctu_xoff, -ctu_yoff, true)
    } else if (floating == 5) {
        lc_drawLogo(lc_Item, '', 153, 67, floating, ctu_xoff, lc_yoff, true)
    } else if (floating == 6) {
        lc_drawLogo(lc_Item, '', 153, 67, floating, -ctu_xoff, lc_yoff, true)
    } else {
        document.write(lc_Item);
    }
}
function lc_HideChat(floating) {
    var lc_url = lc_BaseUrl + 'chattous/hidechat.ashx';
    var lc_extra = '?referer=' + lc_refer + '&cd=' + window.screen.colorDepth + '&rh=' + screen.height + '&rw=' + screen.width + '&tz=' + (new Date().getTimezoneOffset() / 60) * -1;
    var lc_login = '&ctu_user=' + ctu_user + '&ctu_pass=' + ctu_pass;
    document.write('<div id="lc_window"><a href="javascript:LiveChat()"><img id="_imgLC" src="' + lc_url + lc_extra + lc_login + '" style="border:0px; width:0px; height:0px" alt="Click here for live chat" title="Click here for live chat"></a></div>');
}
function lc_OpenChat() {
    lc_CloseMe()
    lc_LiveChat()
}
function lc_CloseMe() {
    var lc_ChatInvite = document.all ? document.all['lc_invite'] : document.getElementById('lc_invite');
    var lc_ChatMessage = document.all ? document.all['lc_message'] : document.getElementById('lc_message');
    lc_ChatMessage.innerHTML = '';
    lc_ChatInvite.style.display = 'none';
    lc_ChatInvite.style.visibility = 'hidden';
    window.clearInterval(lc_interval);
}
function lc_LiveChat() {
    var lc_url = lc_BaseUrl + 'chattous/chattous.aspx';
    var lc_login = '?ctu_user=' + ctu_user + '&ctu_pass=' + ctu_pass;
    window.open(lc_url + lc_login, 'chat', 'toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=no,width=584,height=500,top=50,left=50');
    win.focus();
    win.opener = window;
}
function lc_getRefToDivNest(divID, oDoc) {
    if (document.getElementById) {
        return document.getElementById(divID);
    }
    if (document.all) {
        return document.all[divID];
    }
    return document[divID];
}
function lc_drawLogo(l, b, w, h, p, xOf, yOf, s) {
    window.logoCount = (typeof (window.logoCount) == 'number') ? window.logoCount + 1 : 0;
    document.write('<div id="logoNum' + window.logoCount + '" style="position:absolute;left:0px;top:0px;' + (b ? 'background-color:' + b + ';' : '') + 'height:' + h + 'px;width:' + w + 'px;">' + l + '</div><br>');
    window.setInterval('lc_aniLogo(' + p + ',' + s + ',' + w + ',' + h + ',' + xOf + ',' + yOf + ',' + window.logoCount + ')', 50);
}
function lc_aniLogo(p, s, w, h, xOf, yOf, n) {
    var lc_myLogo = lc_getRefToDivNest('logoNum' + n);
    if (!lc_myLogo) {
        return;
    }
    if (lc_myLogo.style) {
        lc_myLogo = lc_myLogo.style;
    }
    var lc_scrW = 0, lc_scrH = 0, lc_scrOfX = 0, lc_scrOfY = 0;
    if (typeof (window.innerWidth) == 'number') {
        lc_scrW = window.innerWidth;
        lc_scrH = window.innerHeight;
    } else {
        if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
            lc_scrW = document.documentElement.clientWidth;
            lc_scrH = document.documentElement.clientHeight;
        } else {
            if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
                lc_scrW = document.body.clientWidth;
                lc_scrH = document.body.clientHeight;
            }
        }
    }
    if (typeof (window.pageYOffset) == 'number') {
        lc_scrOfY = pageYOffset;
        lc_scrOfX = pageXOffset;
    } else {
        if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
            lc_scrOfY = document.body.scrollTop;
            lc_scrOfX = document.body.scrollLeft;
        } else {
            if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
                lc_scrOfY = document.documentElement.scrollTop;
                lc_scrOfX = document.documentElement.scrollLeft;
            }
        }
    }
    var lc_oPix = document.childNodes ? 'px' : 0;
    lc_myLogo.left = (lc_xOf + ((p % 2) ? 0 : lc_scrW - w) + (s ? lc_scrOfX : 0)) + lc_oPix;
    lc_myLogo.top = (lc_yOf + ((p < 3) ? 0 : lc_scrH - h) + (s ? lc_scrOfY : 0)) + lc_oPix;
    if (p > 4) {
        lc_myLogo.top = (lc_yOf) + (s ? lc_scrOfY : 0) + lc_oPix;
    }
}
lc_interval = window.setInterval('lc_LiveInvite()', 20000);
document.write('<div id="lc_invite" style="visibility:hidden;display:none;position:absolute;z-index:0;width:584px;height:275px;left:300px;top:150px;">');
document.write('<table style="width:100%;height:100%;border:1px solid;background:white;">');
document.write('<tr valign="top" style="height:70px">');
document.write('<td colspan="2">');
document.write('<img src="' + lc_BaseUrl + 'chattous/images/logo.jpg" alt="Chat To Us - Operator Invite" style="border:0px;">');
document.write('</td>');
document.write('</tr>');
document.write('<tr valign="top">');
document.write('<td colspan="2">');
document.write('<div id="lc_message"></div>');
document.write('</td>');
document.write('</tr>');
document.write('<tr valign="bottom">');
document.write('<td align="center" style="width:50%">');
document.write('<a href="javascript:lc_OpenChat()">Click here for live chat</a>');
document.write('</td>');
document.write('<td align="center" style="width:50%">');
document.write('<a href="javascript:lc_CloseMe()">Click here to close</a>');
document.write('</td>');
document.write('</tr>');
document.write('</table>');
document.write('</div>');
