var __ALC_Deployment = 30;

var _alc=new function(){if(cbCheck()){return;}
var webRoot='//alc3.activalive.com/app/';var ptURL=document.location.protocol+'//cu1.activalive.com/';var firstPinged=false;var clientDetails=[];this.license_id=null;this.deployment_id=null;this.department_status={};this.repingTimeout=0;this.buttons=[];this.startTime=0;this.monitoring=[];var pingRate=20;this.invite=null;this.invites=new Array();this.invite_slider=new Array();var buttonString="";var inviteString='';var checkedDepts;var protocol=document.location.protocol;var coBrowseLoaded=false
var oref=oref=getCookie('__ALC_OREF');var firstPingComplete=false;this.setup=function(license_id,deployment_id){addEventListener(window,'load',function(){_alc.startTracking(license_id,deployment_id);});}
this.startTracking=function(license_id,deployment_id){this.license_id=license_id;this.deployment_id=deployment_id;firstPing();}
this.getSessionId=function(){return getCookie('__ALC_STID');}
function getCookie(name){var start=document.cookie.indexOf(name+"=");var len=start+name.length+1;if(start<0){return null;}
if(start==1){return null;}
var end=document.cookie.indexOf(';',len);if(end==-1){end=document.cookie.length;}
return unescape(document.cookie.substring(len,end));}
function firstPing(){firstPingComplete=false;var details={};if(typeof(window.navigator.language)!='undefined'){details.language=window.navigator.language;}else if(typeof(window.navigator.userLanguage)!='undefined'){details.language=window.navigator.language;}
details.custom=clientDetails;details['Flash Version']=_alc.GetSwfVer();details['Screen']=screen.width+'x'+screen.height;details.time_offset=0-new Date().getTimezoneOffset();src=ptURL+'firstping?userAgent='+encodeURIComponent(window.navigator.userAgent);src+='&oref='+encodeURIComponent(getCookie('__ALC_OREF'));src+='&loc='+encodeURIComponent(_alc.getLocation());src+='&ptid='+encodeURIComponent(getCookie('__ALC_CLIENT_ID_'+__ALC_Deployment));src+='&stid='+encodeURIComponent(getCookie('__ALC_STID'));src+='&deployment='+encodeURIComponent(_alc.deployment_id);src+='&details='+encodeURIComponent(_alc.JSON.stringify(details));src+='&r='+Math.random();doPing(src,pingComplete);}
function pingComplete(){firstPingComplete=true;if(_alc.img.width==1){pingSuccess();}else if(_alc.img.width==2){firstPing();return;}else if(_alc.img.width==3){_alc.invite=_alc.img.height-1;_alc.handleInvite();}else if(_alc.img.width==4){departmentOffline.call(_alc,_alc.img.height-1)
regularPing();return;}else if(_alc.img.width==5){_alc.handleInviteRejection();}else if(_alc.img.width==6){_alc.initCoBrowse();regularPing();return;}
this.repingTimeout=window.setTimeout(regularPing,pingRate*1000);}
function pingSuccess(){for(var i=0;i<checkedDepts.length;i++){for(var j=0;j<_alc.buttons.length;j++){_alc.buttons[j].setDepartmentStatus(checkedDepts[i],true);}}}
function regularPing(extras){if(!extras){extras='';}
src=ptURL+'ping?stid='+encodeURIComponent(getCookie('__ALC_STID'))+'&r='+Math.random()+extras;src+=buttonString;src+=inviteString;doPing(src);}
this.handleInvite=function(){}
this.rollDownInvite=function(){if(this.invite_slider[this.invite]){this.invite_slider[this.invite].start();}}
this.rollBackInvite=function(){if(this.invite_slider[this.invite]){this.invite_slider[this.invite].back();}}
this.rejectInvite=function(){regularPing("&rejectInvite=1&deployment="+this.deployment_id);this.handleInviteRejection();}
this.handleInviteRejection=function(){}
function doPing(url,callback){window.clearTimeout(this.repingTimeout);if(!_alc.img){_alc.img=new Image();if(!document.all){_alc.img.style.position='absolute';_alc.img.style.top='-1000px';_alc.img.id="activa_live_chat_tp";document.body.appendChild(_alc.img);}
if(callback){addEventListener(_alc.img,'load',callback);}}
_alc.img.src=url;}
this.forceCheck=function(){makeButtonString.call(this);if(firstPingComplete){regularPing();}}
this.addDetail=function(label,value){clientDetails.push({label:label,value:value});}
this.startTime=getCookie('__ALC_START');if(!this.startTime){this.startTime=Math.floor(new Date().getTime()/1000);document.cookie='__ALC_START='+this.startTime;}
this.getLocation=function(){return window.location.href;}
this.createDelegate=function(oObject,sMethodName){return function(){return oObject[sMethodName].apply(oObject,arguments);};}
function addEventListener(elem,event,callback){if(elem.addEventListener){elem.addEventListener(event,callback,false);}else{elem.attachEvent('on'+event,callback,false);}}
this.__setStartDeptStatus=function(dept,status){for(var i=0;i<this.buttons.length;i++){this.buttons[i].setDepartmentStatus(dept,status);}
if(!status){for(var j=0;j<this.monitoring.length;j++){if(this.monitoring[j]==dept){this.monitoring.splice(j,1);}}}
makeButtonString.call(this);}
this.__setInvite=function(id,html,showOnStart){var div=document.createElement('div');div.id='__ALC_INVITE_DIV_'+id;div.style.top='-1000px';div.style.position='absolute';div.style.zIndex='1000';div.innerHTML=html;document.body.appendChild(div);this.invites.push(id);var slider=new this.sliderTracker(div);this.invite_slider.push(slider);inviteString+='&invites[]='+id;if(showOnStart){_alc.invite=id;slider.start();}}
function updateButtonStatus(badge){}
function did(elemid){return document.getElementById(elemid);}
function makeDeptString(){var u={};var s='';for(var i=0;i<this.buttons.length;i++){var d=this.buttons[i].department;if(!u[d]){u[d]=1;s+='&d[]='+d;}}
return s;}
function makeButtonIdString(){var u={};var s='';for(var i=0;i<this.buttons.length;i++){var id=this.buttons[i].id;if(id){if(!u[id]){u[id]=1;s+='&b[]='+id;}}}
return s;}
function inArray(arr,value){for(var i=0;i<arr.length;i++){if(arr[i]==value){return true;}}
return false;}
function makeButtonString(){checkedDepts=[];var found;for(var i=0;i<this.buttons.length;i++){if(this.buttons[i].online==false){continue;}
found=false;for(var j=0;j<checkedDepts.length;j++){if(checkedDepts[j]==this.buttons[i].department){found=true;}}
if(!found){checkedDepts.push(this.buttons[i].department);}}
for(var g=0;g<this.monitoring.length;g++){if(!inArray(checkedDepts,this.monitoring[g])){checkedDepts.push(this.monitoring[g]);}}
if(checkedDepts.length>255){throw new Error("Number of departments associated with included badges may not exceed 255");}
buttonString='';for(var h=0;h<checkedDepts.length;h++){buttonString+='&d[]='+checkedDepts[h];}}
function departmentOffline(pos){dept=checkedDepts[pos];for(var i=0;i<this.buttons.length;i++){if(!this.buttons[i].online){continue;}
this.buttons[i].setDepartmentStatus(dept,false);}
for(var j=0;j<this.monitoring.length;j++){if(this.monitoring[j]==dept){this.monitoring.splice(j,1);}}
makeButtonString.call(this);}
if(typeof(__ALC_Deployment)=='undefined'&&typeof(__ALC_Compatability_Mode)=='undefined'){alert("Deployment is not set");return;}
this.startChat=function(button_id,width,height){if(!width){width=750;}
if(!height){height=600;}
if(!button_id){if(this.invite!=null){button_id=this.invites[this.invite];}else{throw new Error("You must pass a button id when requesting a chat");}}
var hash="#license_id="+this.license_id+"&deployment_id="+this.deployment_id+"&button_id="+button_id+"&session_id="+this.getSessionId()+"&tracking_id="+getCookie('__ALC_CLIENT_ID_'+__ALC_Deployment);window.open('https:'+webRoot+'chat.php?id='+this.deployment_id+hash,'_blank','resizable=no,scrollbars=no,width='+width+',height='+height+',status=no');}
this.initCoBrowse=function(){if(!coBrowseLoaded){var s=document.createElement('script');s.type='text/javascript';s.src=webRoot+'js/cb.js';document.body.appendChild(s);}else{_alc.cobrowse.addSwf();}}
this.__getWebRoot=function(){return webRoot;}
function cbCheck(){if(navigator){if(navigator.userAgent){if(navigator.userAgent=='Activa Live Chat CoBrowse'){return true;}}}
return false;}
this.getButton=function(id){for(var i=0;i<this.buttons.length;i++){if(this.buttons[i].id==id){return this.buttons[i];}}
return new Button(false);}
function Button(data){if(data){this.department=data.department;this.id=data.id;this.available_id=data.available;this.unavailable_id=data.unavailable;}
this.enableTimeout=false;this.online=null;this.__disabled=false;this.disable=function(){this.online=false;this.__disabled=true;this.updateState();if(this.enableTimeout){clearTimeout(this.enableTimeout);this.enableTimeout=false;}}
this.enable=function(){this.online=null;this.__disabled=false;_alc.forceCheck();}
this.setDepartmentStatus=function(department,status){if(this.department==department){if(this.online!=status&&!this.__disabled){this.online=status;this.updateState();}}}
this.updateState=function(){available=did(this.available_id);unavailable=did(this.unavailable_id);if(this.online&&!this.__disabled){if(available){available.style.display='';}
if(unavailable){unavailable.style.display='none';}}else{if(available){available.style.display='none';}
if(unavailable){unavailable.style.display='';}}}
this.enableButtonAtDuration=function(duration){var elapsed=Math.ceil(new Date().getTime()/1000-_alc.startTime);if(elapsed>duration){this.__disabled=false;}else{this.disable();setTimeout(_alc.createDelegate(this,'enable'),(duration-elapsed)*1000);}}
this.disableButtonAtDuration=function(duration){var elapsed=Math.ceil(new Date().getTime()/1000-_alc.startTime);if(elapsed>duration){this.__disabled=true;this.updateState();}else{setTimeout(_alc.createDelegate(this,'disable'),(duration-elapsed)*1000);}}
this.enableAfterSeconds=function(duration){this.__disabled=true;this.updateState();this.enableTimeout=this.setTimeout(_alc.createDelegate(this,'enable'),duration*1000);}}
var rolledDownAutoInvite=false;var AutoInvite=function(data){Button.call(this,data);this.html=data.html;this.rolledDown=false;this.slider=false;this.updateState=function(){if(this.online&&!this.rolledDown){this.rollDown();}}
this.rollDown=function(){if(getCookie('__ALC_RI_'+this.id)){return;}
if(rolledDownAutoInvite){return;}
if(!this.slider){this.createElement();}
this.slider.start();rolledDownAutoInvite=this;}
this.createElement=function(){var div=document.createElement('div');div.innerHTML=this.html;div=div.firstChild;div.id='__ALC_AUTOINVITE_DIV_'+this.id;div.style.top='-1000px';div.style.position='absolute';div.style.zIndex='1000';document.body.appendChild(div);this.slider=new _alc.sliderTracker(div);}
this.retract=function(){this.slider.back();this.preventReoccur();rolledDownAutoInvite=false;}
this.retractAfterTime=function(secs){setTimeout(_alc.createDelegate(this,'retract'),secs*1000);}
this.preventReoccur=function(){document.cookie='__ALC_RI_'+this.id+'=1;';}}
this.clearAutoInvite=function(){if(rolledDownAutoInvite){rolledDownAutoInvite.retract();}}
if(typeof(__ALC_Badges)=='undefined'){__ALC_Badges=[];}
for(var i=0;i<__ALC_Badges.length;i++){this.buttons.push(new Button(__ALC_Badges[i]));}
if(!oref){oref=encodeURIComponent(document.referrer);if(!oref){oref="Direct";}
document.cookie='__ALC_OREF='+oref;}
this.createAutoInvite=function(data){var btn=new AutoInvite(data);this.buttons.push(btn);makeButtonString.call(this);return btn;}
this.initDeploymentTracking=function(){var ptid=getCookie('__ALC_CLIENT_ID_'+__ALC_Deployment);if(!ptid){var dt=new Date();dt.setFullYear(dt.getFullYear()+10);ptid=__ALC_Deployment+'-'+getCookie('__ALC_STID');document.cookie='__ALC_CLIENT_ID_'+__ALC_Deployment+'='+ptid+';expires='+dt.toGMTString()+';path=/';}
if(typeof(__ALC_Deployment)!='undefined'){document.write('<s'+'cript type="text/javascript" src="'+webRoot+'deployment.php?id='+__ALC_Deployment+'&ptid='+encodeURIComponent(ptid)+'&stid='+encodeURIComponent(this.getSessionId())+'&oref='+oref+'&r='+Math.random()+makeDeptString.call(this)+makeButtonIdString.call(this)+'"></s'+'cript>');}}
if(!getCookie('__ALC_STID')){document.write('<sc'+'ript type="text/javascript" src="'+protocol+webRoot+'genid.php"></sc'+'ript>');}else{this.initDeploymentTracking();}
makeButtonString.call(this);}
_alc.JSON=function(){function f(n){return n<10?'0'+n:n;}
Date.prototype.toJSON=function(){return this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z';};var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};function stringify(value,whitelist){var a,i,k,l,r=/["\\\x00-\x1f\x7f-\x9f]/g,v;switch(typeof value){case'string':return r.test(value)?'"'+value.replace(r,function(a){var c=m[a];if(c){return c;}
c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+
(c%16).toString(16);})+'"':'"'+value+'"';case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
if(typeof value.toJSON==='function'){return stringify(value.toJSON());}
a=[];if(typeof value.length==='number'&&!(value.propertyIsEnumerable('length'))){l=value.length;for(i=0;i<l;i+=1){a.push(stringify(value[i],whitelist)||'null');}
return'['+a.join(',')+']';}
if(whitelist){l=whitelist.length;for(i=0;i<l;i+=1){k=whitelist[i];if(typeof k==='string'){v=stringify(value[k],whitelist);if(v){a.push(stringify(k)+':'+v);}}}}else{for(k in value){if(typeof k==='string'){v=stringify(value[k],whitelist);if(v){a.push(stringify(k)+':'+v);}}}}
return'{'+a.join(',')+'}';}}
return{stringify:stringify,parse:function(text,filter){var j;function walk(k,v){var i,n;if(v&&typeof v==='object'){for(i in v){if(Object.prototype.hasOwnProperty.apply(v,[i])){n=walk(i,v[i]);if(n!==undefined){v[i]=n;}}}}
return filter(k,v);}
if(/^[\],:{}\s]*$/.test(text.replace(/\\./g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(:?[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof filter==='function'?walk('',j):j;}
throw new SyntaxError('parseJSON');}};}();_alc.GetSwfVer=function(){var flashVer=-1;var isIE=(navigator.appVersion.indexOf("MSIE")!=-1)?true:false;var isWin=(navigator.appVersion.toLowerCase().indexOf("win")!=-1)?true:false;var isOpera=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){var swVer2=navigator.plugins["Shockwave Flash 2.0"]?" 2.0":"";var flashDescription=navigator.plugins["Shockwave Flash"+swVer2].description;var descArray=flashDescription.split(" ");var tempArrayMajor=descArray[2].split(".");var versionMajor=tempArrayMajor[0];var versionMinor=tempArrayMajor[1];if(descArray[3]!=""){tempArrayMinor=descArray[3].split("r");}else{tempArrayMinor=descArray[4].split("r");}
var versionRevision=tempArrayMinor[1]>0?tempArrayMinor[1]:0;var flashVer=versionMajor+"."+versionMinor+"."+versionRevision;}}
else if(navigator.userAgent.toLowerCase().indexOf("webtv/2.6")!=-1)flashVer=4;else if(navigator.userAgent.toLowerCase().indexOf("webtv/2.5")!=-1)flashVer=3;else if(navigator.userAgent.toLowerCase().indexOf("webtv")!=-1)flashVer=2;else if(isIE&&isWin&&!isOpera){flashVer=ControlVersion();}
return flashVer;}
_alc.sliderTracker=function(elem){this.elem=elem;this.POSITION_TOP='top';this.POSITION_CENTER='center';this.delaySpeed=0.15;this.xPos=null;this.yPos=null;this.realWidth=null;this.realHeight=null;this.xOffset=null;this.yOffset=null;this.xDestination=null;this.yDestination=null;this.startPosition=this.POSITION_TOP;this.stopPosition=this.POSITION_CENTER;this.start=function(){this.getWindowSize();this.getOffsets();if(this.startPosition==this.POSITION_TOP){this.xPos=(this.realWidth-elem.offsetWidth)/2;this.yPos=-1*elem.offsetHeight;this.moveTo(this.xPos+this.xOffset,this.yPos+this.yOffset);}else{throw new Error("Unknown Start Position");}
if(this.stopPosition==this.POSITION_CENTER){this.xDestination=(this.realWidth-elem.offsetWidth)/2;this.yDestination=(this.realHeight-elem.offsetHeight)/2;}else{throw new Error("Unknown Stop Position");}
window.setTimeout(_alc.createDelegate(this,'step'),5);}
this.back=function(){this.getWindowSize();this.getOffsets();if(this.startPosition==this.POSITION_TOP){this.xDestination=(this.realWidth-elem.offsetWidth)/2;this.yDestination=-1*elem.offsetHeight;}else{throw new Error("Unknown Start Position");}
window.setTimeout(_alc.createDelegate(this,'step'),5);}
this.step=function(){var dx=Math.abs((this.xOffset+this.xDestination)-(this.xPos+this.xDestination));var dy=Math.abs((this.yOffset+this.yDestination)-(this.yPos+this.yDestination));var d=Math.sqrt(dx*dx+dy*dy);var c=Math.round(d/10);if(this.xPos<this.xDestination){this.xPos+=c*this.delaySpeed;if(this.xPos>this.xDestination){this.xPos=this.xDestination;}}else{this.xPos-=c*this.delaySpeed;if(this.xPos<this.xDestination){this.xPos=this.xDestination;}}
if(this.yPos<this.yDestination){this.yPos+=c*this.delaySpeed;if(this.yPos>this.yDestination){this.yPos=this.yDestination;}}else{this.yPos-=c*this.delaySpeed;if(this.yPos<this.yDestination){this.yPos=this.yDestination;}}
this.moveTo(this.xPos+this.xOffset,this.yPos+this.yOffset);if(this.xPos!=this.xDestination||this.yPos!=this.yDestination){window.setTimeout(_alc.createDelegate(this,'step'),5);}}
this.moveTo=function(x,y){xpos=x;ypos=y;this.elem.style.top=y+'px';this.elem.style.left=x+'px';}
this.getWindowSize=function(){if(window.innerWidth){this.realWidth=window.innerWidth;}else if(document.documentElement&&document.documentElement.clientWidth){this.realWidth=document.documentElement.clientWidth;}else if(document.body){this.realWidth=document.body.clientWidth;}
if(window.innerHeight){this.realHeight=window.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){this.realHeight=document.documentElement.clientHeight;}else if(document.body){this.realHeight=document.body.clientHeight;}}
this.getOffsets=function(){if(window.pageXOffset){this.xOffset=window.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollLeft){this.xOffset=document.documentElement.scrollLeft;}else if(document.body){this.xOffset=document.body.scrollLeft;}
if(window.pageYOffset){this.yOffset=window.pageYOffset;}else if(document.documentElement&&document.documentElement.scrollTop){this.yOffset=document.documentElement.scrollTop}else if(document.body){this.yOffset=document.body.scrollTop;}}}