function staticButton(objName,divID,buttonName,buttonId,config,state,butHtmlTemplate,server,site,protocol,servlet,windowWidth,windowHeight){this.CHAT=1;this.VOICE=2;this.BUTTON=1;this.CHATBOX=2;this.TEXTLINK=3;this.OFFLINE=1;this.ONLINE=2;this.OCCUPIED=3;this.AWAY=4;this.TOP_LEFT=2;this.TOP_RIGHT=3;this.BOTTOM_LEFT=4;this.BOTTOM_RIGHT=5;this.stateImage=[];this.stateImage[this.OFFLINE]='repoffline.gif';this.stateImage[this.ONLINE]='reponline.gif';this.stateImage[this.OCCUPIED]='repoccupied.gif';this.stateImage[this.AWAY]='repoffline.gif';this.config=config;if(this.config.buttonType==this.CHATBOX&&this.config.buttonContent==1){this.config.cb_height=100;this.config.cb_width=150;this.config.cb_borderWidth=0;this.config.cb_borderColor='';}this.objName=objName;this.divID=divID;this.buttonName=buttonName;this.buttonId=buttonId;this.state=state;this.butHtmlTemplate=butHtmlTemplate;this.server=server;this.site=site;this.protocol=protocol;this.servlet=servlet;this.windowWidth=windowWidth;this.windowHeight=windowHeight;this.targetPrefix=this.config.chanel==this.CHAT?'chat':'call';this.randomNum=Math.round(Math.random()*9999999999);this.connErrorCnt=0;this.maxErrorRequests=3;this.ErrorRequestDelay=5;this.imgID='lpChatBtnImgID'+this.randomNum;this.chatBoxSubmitImgID='LPsubmit'+this.randomNum;this.chatBoxTextAreaID='lp_msgfield'+this.randomNum;this.hrefID='lpChatBtnHref'+this.randomNum;this.tableID='lpChatBtnTbl'+this.randomNum;this.poweredbyDivID='lpPoweredByID'+this.randomNum;this.txtLinkSpan='lpTextLinkSpan'+this.randomNum;if(this.config.chanel==this.VOICE){for(var name in this.stateImage){this.stateImage[name]='voice_'+this.stateImage[name];}}if(!this.EventHandler('init')){return true;}this.Start();}staticButton.prototype.Start=function(){if(!this.EventHandler('start')){return true;}var that=this;var div=this.GetObj(this.divID);if(div!=null){var content=this.GetHTML();var tmpDiv=document.createElement('div');tmpDiv.innerHTML=content.html;div.appendChild(tmpDiv);this.addStyleSheet(content.css);var href=this.GetObj(this.hrefID);if(href!=null){href.onclick=function(){that.Clicked();return false;};}if(this.config.buttonType==this.CHATBOX){this.attachEventsToChatBox();}this.addToolTip();}if(typeof(lpMTagStatic.stateChangeCallbacks)=='undefined'){lpMTagStatic.stateChangeCallbacks=[];}lpMTagStatic.stateChangeCallbacks[lpMTagStatic.stateChangeCallbacks.length]=function(){that.StateChangeCallback();};this.Display();};staticButton.prototype.attachEventsToChatBox=function(){var that=this;var txtArea=this.GetObj(this.chatBoxTextAreaID);if(txtArea!=null){txtArea.onblur=function(){if(txtArea.value==''){txtArea.value=that.config.chatBoxText;}};txtArea.onfocus=function(){if(txtArea.value==that.config.chatBoxText){txtArea.value='';}};txtArea.value=this.config.chatBoxText;}};staticButton.prototype.StateChangeCallback=function(){this.makeCall();};staticButton.prototype.makeCall=function(){var that=this;if(!this.EventHandler('makeCall')){return true;}if(typeof(lpConnLib)!='undefined'){var url=this.protocol+'://'+this.server+'/'+this.servlet+this.site+'/';var params=new hcArrayStorage();params.add('site',this.site);params.add('cmd','mTagRepstate');params.add('c',this.config.chanel);params.add('bt',this.config.buttonType);params.add('buttonID',this.config.id);params.add('subCmd','getState');params.add('monitor',1);if(lpMTag.mtagAddToQueue){lpMTag.mtagAddToQueue(url,params,function(dataObj,request){that.callResponseHandler(dataObj,request);},false);}else{lpConnLib.addToQueue(url,params,function(dataObj,request){that.callResponseHandler(dataObj,request);},false);}}};staticButton.prototype.callResponseHandler=function(dataObj){var that=this;if(typeof(dataObj.ResultSet.lpCallError)!='undefined'){this.connErrorCnt++;if(this.connErrorCnt<this.maxErrorRequests){this.loopTimer=setTimeout(function(){that.makeCall();},this.connErrorCnt*this.ErrorRequestDelay*1000);}return;}var result=dataObj.ResultSet.lpData[0].result;this.processResult(result);};staticButton.prototype.processResult=function(result){if(this.state==result){return;}this.state=result;if(!this.EventHandler('state')){return true;}var img=this.GetObj(this.imgID);if(img!=null){var imgSrc=img.src;imgSrc=imgSrc.substr(0,imgSrc.lastIndexOf('/')+1);imgSrc=imgSrc+this.stateImage[result];img.src=imgSrc;}if(this.config.buttonType==this.CHATBOX){var sbmtImg=this.GetObj(this.chatBoxSubmitImgID);if(sbmtImg!=null){var imgSrc=sbmtImg.src;imgSrc=imgSrc.substr(0,imgSrc.lastIndexOf('/')+1);imgSrc=imgSrc+this.stateImage[result];sbmtImg.src=imgSrc;}}if(this.config.buttonType==this.TEXTLINK){var span=this.GetObj(this.txtLinkSpan);if(span!=null){span.innerHTML=this.getTextLinkText(this.state);}}this.addToolTip();};staticButton.prototype.getTextLinkText=function(state){if(state==this.ONLINE){return this.config.displayTextOnline;}else if(state==this.OCCUPIED){return this.config.displayTextOccupied;}else{return this.config.displayTextOffline;}};staticButton.prototype.addToolTip=function(){var tooltip='';if(this.state==this.ONLINE){tooltip=this.config.mouseoverOnline;}else if(this.state==this.OFFLINE||this.state==this.AWAY){tooltip=this.config.mouseoverOffline;}else if(this.state==this.OCCUPIED){tooltip=this.config.mouseoverOccupied;}var href=this.GetObj(this.hrefID);if(href!=null){href.alt=tooltip;href.title=tooltip;}var img=this.GetObj(this.imgID);if(img!=null){img.alt=tooltip;img.title=tooltip;}};staticButton.prototype.GetClickString=function(){var clickStr='';for(var i=0;i<this.config.ude.length;i++){var u=this.config.ude[i];if(u.scope=='CLICK'){if(this.isDynamicUDE(this.config.ude[i])){var r=this.expandDynamicUDE(this.config.ude[i]);if(r!=null){clickStr+='&'+escape(r.name)+'='+escape(r.value);}}else{clickStr+='&'+escape(this.config.ude[i].name)+'='+escape(this.config.ude[i].value);}}}return clickStr;};staticButton.prototype.GetClickhtmlString=function(){var clickStr='';for(var i=0;i<this.config.ude.length;i++){var u=this.config.ude[i];if(u.scope=='CLICK'){if(this.isDynamicUDE(this.config.ude[i])){var r=this.expandDynamicUDE(this.config.ude[i]);if(r!=null){clickStr+='<input type="hidden" value="'+escape(r.value)+'" name="'+escape(r.name)+'"/>';}}else{clickStr+='<input type="hidden" value="'+escape(this.config.ude[i].value)+'" name="'+escape(this.config.ude[i].name)+'"/>';}}}return clickStr;};staticButton.prototype.GetUDEString=function(){var udeStr='';for(var i=0;i<this.config.ude.length;i++){var u=this.config.ude[i];if(u.scope!='CLICK'){if(this.isDynamicUDE(this.config.ude[i])){var r=this.expandDynamicUDE(this.config.ude[i]);if(r!=null){udeStr+='&'+r.scope+'!'+escape(r.name)+'='+escape(r.value);}}else{udeStr+='&'+this.config.ude[i].scope+'!'+escape(this.config.ude[i].name)+'='+escape(this.config.ude[i].value);}}}return udeStr;};staticButton.prototype.GetUDEhtmlString=function(){var udeStr='';for(var i=0;i<this.config.ude.length;i++){var u=this.config.ude[i];if(u.scope!='CLICK'){if(this.isDynamicUDE(this.config.ude[i])){var r=this.expandDynamicUDE(this.config.ude[i]);if(r!=null){udeStr+='<input type="hidden" value="'+escape(r.value)+'" name="'+r.scope+'!'+escape(r.name)+'"/>';}}else{udeStr+='<input type="hidden" value="'+escape(this.config.ude[i].value)+'" name="'+this.config.ude[i].scope+'!'+escape(this.config.ude[i].name)+'"/>';}}}return udeStr;};staticButton.prototype.isDynamicUDE=function(u){return(u.name.indexOf('{')==0||u.value.indexOf('{')==0);};staticButton.prototype.expandDynamicUDE=function(u){var name='';var value='';try{if(u.name.indexOf('{')==0){this.log('Found dynamic ude name: '+u.name);name=this.getDynamicProp(u.name);this.log('Expanded dynamic ude name: '+name);}else{name=u.name;}if(u.value.indexOf('{')==0){this.log('Found dynamic ude value: '+u.value);value=this.getDynamicProp(u.value);this.log('Expanded dynamic ude value: '+value);}else{value=u.value;}}catch(e){this.log('exception in expandDynamicUDE: '+e,'WARN');return null;}return{'name':name,'value':value,'scope':u.scope};};staticButton.prototype.getDynamicProp=function(prop){prop=prop.substr(1);prop=prop.substr(0,prop.length-1);return eval(prop);};staticButton.prototype.GetHTML=function(){var css=[];var html=this.butHtmlTemplate;html=html.replace(/\{IMAGENAME\}/g,this.stateImage[this.state]);html=html.replace(/\{ON_CLICK_HANDLER\}/g,'');html=html.replace(/\{RANDOMNUM\}/g,this.randomNum);html=html.replace(/\{EXTRACSSFORAA\}/g,'');if(this.config.buttonType==this.CHATBOX){html=html.replace(/\{customWantToChatNONJSParams\}/g,this.GetClickhtmlString()+this.GetUDEhtmlString());css=this.getChatBoxCss();}else{html=html.replace(/\{customWantToChatNONJSParams\}/g,this.GetClickString()+this.GetUDEString());}html=html.replace(/\{targetPrefix\}/g,this.targetPrefix);html=html.replace(/\{textLinkValue\}/g,this.getTextLinkText(this.state));html=html.replace(/\{chatBoxText\}/g,'');return{'html':html,'css':css};};staticButton.prototype.getChatBoxCss=function(){var css=[];css[css.length]={'name':'#lp_msgfield'+this.randomNum,'css':'padding-left: 3px;font-family:Arial, Helvetica, sans-serif;font-size: 11px;background-color:#ffffff;width:'+this.config.cb_width+'px;height:'+this.config.cb_height+'px;border:'+this.config.cb_borderWidth+'px solid '+this.config.cb_borderColor+';'};css[css.length]={'name':'#LPChatBoxSubmitTDid'+this.randomNum,'css':'background-repeat:no-repeat;padding-left: 3px;padding-right: 0px;padding-top: 0px;padding-bottom: 0px;vertical-align: top;height: 29px;'};css[css.length]={'name':'#LPChatBoxTxtTDid'+this.randomNum,'css':'padding-left:5px;padding-right: 0px;padding-top: 0px;padding-bottom: 0px;'};css[css.length]={'name':'#lpChatBtnHref'+this.randomNum,'css':'padding-top: 2px;'};css[css.length]={'name':'#lpChatBtnImgID'+this.randomNum,'css':'display: block;'};return css;};staticButton.prototype.Display=function(){if(!this.EventHandler('beforeDisplay')){return true;}if(this.config.buttonType!=this.TEXTLINK){var tbl=this.GetObj(this.tableID);if(tbl!=null){tbl.style.display='';}else{this.log('staticButton '+this.buttonName+'  objName='+this.objName+' Can not find tableID:'+this.tableID,'ERROR');}}this.makeItSticky();if(!this.EventHandler('afterDisplay')){return true;}};staticButton.prototype.log=function(msg,level){if(typeof(lpMTagDebug)!='undefined'&&lpMTagDebug.Display){lpMTagDebug.Display(msg,level,'STATIC_BUTTON');}};staticButton.prototype.Clicked=function(){if(!this.EventHandler('click')){return true;}var fileCmd=(this.config.chanel==this.CHAT)?'visitorWantsToChat':'visitorWantsToTalk';this.winURL=this.protocol+'://'+this.server+'/'+this.servlet+this.site+'/?cmd=file&file='+fileCmd+'&site='+this.site;if(this.config.routingSkill>0){this.winURL+='&SV!skill='+this.config.routingSkillName;}if(this.config.routingAgent>0){this.winURL+='&SV!opid='+this.config.routingAgent;}this.winURL=(typeof(lpAppendVisitorCookies)!='undefined'?lpAppendVisitorCookies(this.winURL):this.winURL);this.winURL=((typeof(lpMTag)!='undefined'&&typeof(lpMTag.addFirstPartyCookies)!='undefined')?lpMTag.addFirstPartyCookies(this.winURL):this.winURL);this.winURL+=this.GetClickString();this.winURL+=this.GetUDEString();if(this.config.buttonType==this.CHATBOX){var el=document.getElementById('lp_msgfield'+this.randomNum);if(el!=null){if(typeof(this.config.blockCCPattern)!='undefined'){el.value=el.value.replace(this.config.blockCCPattern,"****************");}this.winURL+='&SV!message='+el.value;}this.winURL+='&SV!survey_pre-chat_enable=Off';this.winURL+='&SV!source=chatbox';}this.winURL+='&referrer='+escape(document.location);this.winURL+='&referrer='+escape(document.location);if(this.winURL.length>2000){this.winURL=this.winURL.substr(0,2000);}if(!this.EventHandler('windowOpen')){return true;}window.open(this.winURL,this.targetPrefix+this.site,'width='+this.windowWidth+',height='+this.windowHeight+',resizable=yes');return false;};staticButton.prototype.EventHandler=function(ev){this.log('staticButton '+this.buttonName+'  objName='+this.objName+' EVENT: '+ev+' STATE:'+this.state,'DEBUG');var that=this;if(ev=='start'){this.mTagEvent('LP_STATBUTTON_START');}else if(ev=='beforeDisplay'){this.mTagEvent('LP_STATBUTTON_SHOWN');}else if(ev=='click'){this.mTagEvent('LP_STATBUTTON_CLICKED');}else if(ev=='state'){this.mTagEvent('LP_STATBUTTON_STATE');}if(typeof(lpMTagStatic.chatButtonEventHandler)=='function'){return lpMTagStatic.chatButtonEventHandler(ev,that,this.buttonName,this.buttonId);}return true;};staticButton.prototype.GetObj=function(id){if(document.getElementById){return document.getElementById(id);}else{if(document.all){return document.all(id);}}};staticButton.prototype.makeItSticky=function(){if(this.config.stickyType!=this.TOP_LEFT&&this.config.stickyType!=this.TOP_RIGHT&&this.config.stickyType!=this.BOTTOM_LEFT&&this.config.stickyType!=this.BOTTOM_RIGHT){return;}var div=this.GetObj(this.divID);if(div!=null){div.style.position='fixed';if(this.config.stickyType==this.TOP_LEFT){div.style.top=0;div.style.left=0;}else if(this.config.stickyType==this.TOP_RIGHT){div.style.top=0;div.style.right=0;}else if(this.config.stickyType==this.BOTTOM_LEFT){div.style.bottom=0;div.style.left=0;}else if(this.config.stickyType==this.BOTTOM_RIGHT){div.style.bottom=0;div.style.right=0;}}};staticButton.prototype.getStateStr=function(state){if(state==this.ONLINE){return'online';}else if(state==this.OFFLINE){return'offline';}else if(state==this.OCCUPIED){return'busy';}else if(state==this.AWAY){return'away';}};staticButton.prototype.mTagEvent=function(evName){if(typeof(lpMTag)!='undefined'&&typeof(lpMTag.events)!='undefined'&&typeof(lpMTag.events.publish)=='function'){var stateStr=this.getStateStr(this.state);var evData={id:this.buttonId,name:this.buttonName,channel:(this.config.chanel==this.VOICE?'voice':'chat'),buttonState:stateStr};lpMTag.events.publish(evName,evData);}};staticButton.prototype.addStyleSheet=function(css){for(var i=0;i<css.length;i++){var selector=css[i].name;var els=[];if(selector.indexOf('#')==0){els[0]=this.GetObj(selector.substr(1));if(els[0]==null){els=[];}}else{els=document.getElementsByClassName(selector.substr(1));}if(els==null){this.log('NO ELEMENTS FOUND FOR SELECTOR:'+selector,'DEBUG');return;}this.log('SELECTOR:'+selector+' found:'+els.length+' css='+css[i].css,'DEBUG');for(var cnt=0;cnt<els.length;cnt++){var cssRules=this.getCss(css[i].css);this.applyCssToEl(els[cnt],cssRules);}}};staticButton.prototype.applyCssToEl=function(el,cssRules){var st=el.style;if(st){for(var i=0;i<cssRules.length;i++){st[cssRules[i].name]=cssRules[i].value;}}};staticButton.prototype.getCss=function(rules){var r=rules.split(';');var css=[];for(var i=0;i<r.length;i++){if(r[i]!=''){var pos=r[i].indexOf(':');var cName=r[i].substr(0,pos);var cValue=r[i].substr(pos+1);cName=this.trim(cName);cName=this.fixCssNames(cName);css[i]={"name":cName,"value":this.trim(cValue)};}}return css;};staticButton.prototype.fixCssNames=function(cssName){cssName=cssName.replace(/z-index/g,'zIndex');cssName=cssName.replace(/margin-bottom/g,'marginBottom');cssName=cssName.replace(/margin-left/g,'marginLeft');cssName=cssName.replace(/margin-right/g,'marginRight');cssName=cssName.replace(/margin-top/g,'marginTop');cssName=cssName.replace(/margin-bottom/g,'marginBottom');cssName=cssName.replace(/background-color/g,'backgroundColor');cssName=cssName.replace(/list-style/g,'listStyle');cssName=cssName.replace(/font-family/g,'fontFamily');cssName=cssName.replace(/font-style/g,'fontStyle');cssName=cssName.replace(/font-variant/g,'fontVariant');cssName=cssName.replace(/font-weight/g,'fontWeight');cssName=cssName.replace(/font-size/g,'fontSize');cssName=cssName.replace(/line-height/g,'lineHeight');cssName=cssName.replace(/text-align/g,'textAlign');cssName=cssName.replace(/text-decoration/g,'textDecoration');cssName=cssName.replace(/text-indent/g,'textIndent');cssName=cssName.replace(/text-transform/g,'textTransform');cssName=cssName.replace(/vertical-align/g,'verticalAlign');cssName=cssName.replace(/padding-left/g,'paddingLeft');cssName=cssName.replace(/padding-right/g,'paddingRight');cssName=cssName.replace(/padding-top/g,'paddingTop');cssName=cssName.replace(/padding-bottom/g,'paddingBottom');cssName=cssName.replace(/background-repeat/g,'backgroundRepeat');return cssName;};staticButton.prototype.trim=function(str){return str.replace(/^\s\s*/,'').replace(/\s\s*$/,'');};if (typeof(lpMTagStatic)=='undefined') {var lpMTagStatic={};} lpMTagStatic.lpStaticBut13105360446084781577468474471908 = new staticButton('lpMTagStatic.lpStaticBut13105360446084781577468474471908','live_chat','Chat Text Link 1',7,{'id':7,'name':"Chat Text Link 1",chanel:1,enabled:true,buttonType:3,voiceType:-1,stickyType:1,description:"Example Chat Text Link Button",buttonContent:1,addTextToButton:false,addTextToButtonText:"",addTextToButtonPosition:1,routingSkill:-1,routingSkillName:'',routingAgent:-1,mouseoverOnline:"Click here to chat live with a real online representative",mouseoverOccupied:"All our live chat agents are currently occupied. Please try again later or click here to leave us a message.",mouseoverOffline:"Our live chat service is currently offline.  Please try again during business hours or click here to leave us a message.",defaultButton:true,imageFolder:"/hcp/",chatBoxTemplate:"",chatBoxText:"",displayTextOnline:"<span style=\"font-size: small;\"><span style=\"font-family: verdana,geneva;\">Live Chat Now! &gt;</span></span>",displayTextOccupied:"<span style=\"font-size: small;\"><span style=\"font-family: verdana,geneva;\">Click here to leave a message</span></span>",displayTextOffline:"<span style=\"font-size: small;\"><span style=\"font-family: verdana,geneva;\">Click here to leave a message</span></span>",ude: [],cb_width:0,cb_height:0,cb_borderWidth:0,cb_borderColor:"",smartType:2,time_in_queue:10},2, "<a id='lpChatBtnHref{RANDOMNUM}' class='lpChatTextLink'\n   href='https://server.iad.liveperson.net/hc/56027821/?cmd=file&file=visitorWantsToChat&site=56027821&byhref=1{customWantToChatNONJSParams}'\n   target='{targetPrefix}56027821'>\n   <span id=\"lpTextLinkSpan{RANDOMNUM}\" class='lpChatTextLinkText'>{textLinkValue}</span>\n</a>",'server.iad.liveperson.net','56027821','https','hc/','475','400','chat')
