// JavaScript Document
var lpMTagConfig = {
    'lpServer': "server.iad.liveperson.net",
    'lpNumber': "17120213",
    'lpProtocol': "https"
};
function lpAddMonitorTag(src){
    if (typeof(src) == 'undefined' || typeof(src) == 'object') {
        src = lpMTagConfig.lpMTagSrc ? lpMTagConfig.lpMTagSrc : '/hcp/html/mTag.js';
    }
    if (src.indexOf('http') != 0) {
        src = lpMTagConfig.lpProtocol + "://" + lpMTagConfig.lpServer + src + '?site=' + lpMTagConfig.lpNumber;
    }
    else {
        if (src.indexOf('site=') < 0) {
            if (src.indexOf('?') < 0) 
                src = src + '?';
            else 
                src = src + '&';
            src = src + 'site=' + lpMTagConfig.lpNumber;
        }
    };
    var s = document.createElement('script');
    s.setAttribute('type', 'text/javascript');
    s.setAttribute('charset', 'iso-8859-1');
    s.setAttribute('src', src);
    document.getElementsByTagName('head').item(0).appendChild(s);
}

function onLpButtonClick(){
    lpButtonCTTUrl = 'https://server.iad.liveperson.net/hc/'+lpMTagConfig.lpNumber+'/?cmd=file&file=visitorWantsToChat&site='+lpMTagConfig.lpNumber+'&imageUrl=https://images.liveperson.com/lp/'+lpMTagConfig.lpNumber+'&referrer=' + escape(document.location);
    lpButtonCTTUrl = (typeof(lpAppendVisitorCookies) != 'undefined' ? lpAppendVisitorCookies(lpButtonCTTUrl) : lpButtonCTTUrl);
    lpButtonCTTUrl = ((typeof(lpMTag) != 'undefined' && typeof(lpMTag.addFirstPartyCookies) != 'undefined') ? lpMTag.addFirstPartyCookies(lpButtonCTTUrl) : lpButtonCTTUrl);
    window.open(lpButtonCTTUrl, 'chat'+lpMTagConfig.lpNumber, 'width=475,height=400,resizable=yes');
    return false;
}

function onLpSupportClick(){
    lpSupportURL = 'http://solutions.liveperson.com/customer-service/?site='+lpMTagConfig.lpNumber+'&domain=server.iad.liveperson.net&origin=chatbutton&referrer=' + escape(document.location);
    window.open(lpSupportUrl);
    return false;
}

function onLpInsertTag(){
    if (Ext.get('lpTagTarget')) {
        var button = '';
        button += '<div>';
        button += '<table border="0" cellspacing="2" cellpadding="2">';
        button += '<tr>';
        button += ' <td align="center"></td>';
        button += ' <td align="center">';
        button += '  <a id="_lpChatBtn" href="https://server.iad.liveperson.net/hc/'+lpMTagConfig.lpNumber+'/?cmd=file&file=visitorWantsToChat&site='+lpMTagConfig.lpNumber+'&byhref=1&imageUrl=https://images.liveperson.com/lp/'+lpMTagConfig.lpNumber+'" target="chat'+lpMTagConfig.lpNumber+'" onClick="onLpButtonClick();"><img src="https://server.iad.liveperson.net/hc/'+lpMTagConfig.lpNumber+'/?cmd=repstate&site='+lpMTagConfig.lpNumber+'&channel=web&&ver=1&imageUrl=https://images.liveperson.com/lp/'+lpMTagConfig.lpNumber+'" name="hcIcon" border=0></a>';
        button += '  </td>';
        button += '</tr>';
        button += '<tr>';
        button += ' <td>&nbsp;</td>';
        button += ' <td align="center">';
        button += '  <div style="margin-top:5px;">';
        button += '   <span style="font-size:10px; font-family:Arial, Helvetica, sans-serif;"><a href="http://solutions.liveperson.com/live-chat" style="text-decoration:none; color:#000" target="_blank"><b>Live Chat</b></a><span style="color:#000"> by </span><a href="http://www.liveperson.com/" style="text-decoration:none; color:#FF9900" target="_blank">LivePerson</a></span>';
        button += '  </div>';
        button += ' </td>';
        button += '</tr>';
        button += '<tr>';
        button += ' <td>&nbsp;</td>';
        button += ' <td align="center">';
        button += '  <a href="http://solutions.liveperson.com/customer-service/?site='+lpMTagConfig.lpNumber+'&domain=server.iad.liveperson.net&origin=chatbutton" target="_blank" onClick="onLpSupportClick();"><img src="https://server.iad.liveperson.net/hc/'+lpMTagConfig.lpNumber+'/?cmd=rating&site='+lpMTagConfig.lpNumber+'&type=indicator" name="hcRating" alt="Customer Service Rating by LivePerson" border="0"></a>';
        button += ' </td>';
        button += '</tr>';
        button += '</table>';
        button += '</div>';
        
        Ext.DomHelper.append(Ext.get('lpTagTarget'), button);
    }
}

if (window.attachEvent) {
    window.attachEvent('onload', lpAddMonitorTag);
    window.attachEvent('onload', onLpInsertTag);
}
else {
    window.addEventListener("load", lpAddMonitorTag, false);
    window.addEventListener("load", onLpInsertTag, false);
}



