var lpMTagConfig = {
        'lpServer' : "server.iad.liveperson.net",
        'lpNumber' : "",
        'lpProtocol' : (document.location.toString().indexOf("https:")==0) ? "https" : "http",
		'sendCookies' : "true"
	}

lpMTagConfig.onLoadCode = new Array();
lpMTagConfig.onLoadCode[lpMTagConfig.onLoadCode.length] = lpOverrideCookie;
function lpOverrideCookie(){lpMonitorTag.prototype.lpSetCallParams=function(lpCmd,extra){var CallParams=new hcArrayStorage();var data=this.lpGetCookie(lpMTagConfig.lpNumber+'-VID');if(data!=null){CallParams.add('visitor',data);if(this.lpGetCookie(lpMTagConfig.lpNumber+'-SKEY')!=null){CallParams.add('msessionkey',this.lpGetCookie(lpMTagConfig.lpNumber+'-SKEY'));}}CallParams.add('site',lpMTagConfig.lpNumber);CallParams.add('cmd',lpCmd);CallParams.add('page',this.lpPageLocation);CallParams.add('id',this.lpPageID);CallParams.add('javaSupport',this.lpJavaEnabled);CallParams.add('visitorStatus',this.lpVisitorStatus);CallParams.add('scriptVersion',this.lpScriptVersion);if(lpCmd=='mTagInPage'){data=this.lpGetCookie(this.dataCookieName);if(data!=''&&data!=null){this.lpDeleteCookie(this.dataCookieName);CallParams.add(data);}}if(typeof(lpMTagConfig.defaultChatInvite)!='undefined'){CallParams.add('defCInvite',lpMTagConfig.defaultChatInvite);}if(typeof(lpMTagConfig.defaultVoiceInvite)!='undefined'){CallParams.add('defVInvite',lpMTagConfig.defaultVoiceInvite);}if(typeof(lpMTagConfig.defaultInvite)!='undefined'){CallParams.add('defCInvite',lpMTagConfig.defaultInvite);CallParams.add('defVInvite',lpMTagConfig.defaultInvite);}if(typeof(lpMTagConfig.cobrowseEnabled)!='undefined'){if(typeof(lpMTagConfig.lpActivePlugin)=='undefined'){lpMTagConfig.lpActivePlugin='none';}CallParams.add('activePlugin',lpMTagConfig.lpActivePlugin);CallParams.add('cobrowse','true');if(typeof(lpMTagConfig.pageWindowName)!='undefined'){CallParams.add('pageWindowName',lpMTagConfig.pageWindowName);}else{var name='';try{if(top&&typeof(top.document)!='undefined'){name=''+top.name;}}catch(e){name='';}CallParams.add('pageWindowName',name);}if(typeof(lpMTagConfig.lpOperatorPageType)!="undefined"){CallParams.add('cobrowsetitle',lpMTagConfig.lpOperatorPageType);}if(typeof(lpMTagConfig.lpOperatorPageUrl)!="undefined"){CallParams.add('cobrowseurl',lpMTagConfig.lpOperatorPageUrl);}}if(lpCmd=='mTagStartPage'||lpCmd=='mTagInPage'){if(typeof(lpMTagConfig.pageVar)!='undefined'&&lpMTagConfig.pageVar.length>0){for(var i=0;i<lpMTagConfig.pageVar.length;i++){CallParams.add('PAGEVAR!'+lpMTagConfig.pageVar[i]);}lpMTagConfig.pageVar=new Array();}if(typeof(lpMTagConfig.sessionVar)!='undefined'&&lpMTagConfig.sessionVar.length>0){for(var i=0;i<lpMTagConfig.sessionVar.length;i++){CallParams.add('SESSIONVAR!'+lpMTagConfig.sessionVar[i]);}lpMTagConfig.sessionVar=new Array();}if(typeof(lpMTagConfig.visitorVar)!='undefined'&&lpMTagConfig.visitorVar.length>0){for(var i=0;i<lpMTagConfig.visitorVar.length;i++){CallParams.add('VISITORVAR!'+lpMTagConfig.visitorVar[i]);}lpMTagConfig.visitorVar=new Array();}}if(lpCmd=='mTagKnockPage'){if(typeof(lpMTagConfig.dynButton)!='undefined'&&lpMTagConfig.dynButton.length>0){var dbut='';for(var i=0;i<lpMTagConfig.dynButton.length;i++){if(i>0)dbut+='#';dbut+=lpMTagConfig.dynButton[i].name+'|';if(typeof(lpMTagConfig.dynButton[i].ovr)!='undefined')dbut+=lpMTagConfig.dynButton[i].ovr+'|';else dbut+='null|';if(typeof(lpMTagConfig.dynButton[i].pid)!='undefined')dbut+=lpMTagConfig.dynButton[i].pid+'|';else dbut+='null|';}CallParams.add('dbut',dbut);}}if(typeof(lpMTagConfig.sendSnippets)!='undefined'){CallParams.add('sendSnippets',lpMTagConfig.sendSnippets);lpMTagConfig.sendSnippets=undefined;}if(typeof(extra)!='undefined'){CallParams.add(extra);}if(this.lpDataToSend!=''){CallParams.add(this.lpDataToSend);this.lpDataToSend='';}CallParams.add('title',this.title);CallParams.add('referrer',document.referrer);return CallParams;};}
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);} 

/*if (window.attachEvent) window.attachEvent('onload',lpAddMonitorTag); // wil load onload of the page
else window.addEventListener("load",lpAddMonitorTag,false); */

//Dynamic Buttons Array
if(typeof(lpMTagConfig.dynButton)=="undefined") lpMTagConfig.dynButton=new Array();

//Variables Arrays - By Scope
if (typeof(lpMTagConfig.pageVar)=='undefined') lpMTagConfig.pageVar = new Array();
if (typeof(lpMTagConfig.sessionVar)=='undefined') lpMTagConfig.sessionVar = new Array();
if (typeof(lpMTagConfig.visitorVar)=='undefined') lpMTagConfig.visitorVar = new Array();

// Function that sends variables to LP - By Scope
function lpAddVars(scope,name,value) 	{
	if (value != 0 && value != "")  //This is optional, depends if client wants to pass 0 or blank values
	{
	value=lpTrimSpaces(value.toString());
	switch (scope){
		case "page": 
			lpMTagConfig.pageVar[lpMTagConfig.pageVar.length] = escape(name)+"="+escape(value);
			break;
		case "session": 
			lpMTagConfig.sessionVar[lpMTagConfig.sessionVar.length] = escape(name)+"="+escape(value);
			break;
		case "visitor": 
			lpMTagConfig.visitorVar[lpMTagConfig.visitorVar.length] = escape(name)+"="+escape(value);
			break;
		}
	}
}

//Visitor activity indicator
//lpMTagConfig.enableActivityMon =<true/false>; //By default true
//lpMTagConfig.inactivityPeriod=<Inactivity Period in Sec>; //By default 120
//lpMTagConfig.actPollingInterval =<value in sec>; // By default 3 sec


//Prevent Invitation shown off page
lpMTagConfig.lpInvitePreventOffpage = true; // <true/false>  Can be change to false.

// Variables submission using lpGetVariables
/*
function lpGetVariables() {
var udes = new Array();
udes['<Scope:page/session/visitor>'] = new Array();
udes['<Scope:page/session/visitor>'][<counter>] = '<Variable Name>=<Variable Value>'; //First counter =0 
return udes;
}
*/

// Immediate Data submission function

function lpSendData(varname,varvalue,varscope)
{
 if(typeof(lpMTag)!='undefined' && typeof(lpMTag.lpSendData)!='undefined')
    lpMTag.lpSendData(varscope+'VAR!'+ varname + '=' + varvalue, true);
}

//The Trim function returns a text value with the leading and trailing spaces removed
function lpTrimSpaces(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

//Omit a specific cookie from the list of cookies that is being sent to LP with the monitor
lpMTagConfig.GetPageCookies = function () {
var cookies = document.cookie;
if ((typeof(cookies) == "undefined") || (cookies == null)) {
            cookies = "";
}
cookies = cookies.replace(/COOKIENAME=[a-zA-Z0-9\-!]*;?/,"");
return cookies;
};

//fix the default underline (css problem) of the invitation
lpMTagConfig.inviteChatShown = function(objName)
{
    var objRef = eval(objName);
    if (objRef==null || objRef.GetObj(objRef.imgCloseID)==null || objRef.GetObj(objRef.imgNeedHelpID)==null) 
        return true;
    objRef.GetObj(objRef.imgCloseID).parentNode.className= "NoUnderline";
    objRef.GetObj(objRef.imgNeedHelpID).parentNode.className= "NoUnderline";
};
