/******************************************************************************************** Vars ********************************************************************************************/ var browserTitle = cakeSafe(document.title); var browserURL = cakeSafe(String(window.location)); var inviteBG = new Image(); inviteBG.src = 'http://chatadvisors.buffalofulfillment.com/img/invites/'; function cakeSafe(varStr){ regEx=/\//g; var newString = varStr.replace(regEx,'-'); regEx=/\&\;/g; newString = newString.replace(regEx,'*amp*'); regEx=/\&/g; newString = newString.replace(regEx,'*amp*'); return escape(newString); } /******************************************************************************************** Cookies ********************************************************************************************/ function setCookie(c_name,value,expiredays){ var exdate=new Date(); exdate.setDate(exdate.getDate()+expiredays); document.cookie=c_name+ "=" +escape(value)+ ((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); } function getCookie(c_name){ if (document.cookie.length>0){ c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1){ c_start=c_start + c_name.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } }else{ return "38.107.191.98"; } return ""; } function cookieForURL(varValue){ if (varValue==""){ return "38.107.191.98"; }else{ return varValue; } } function browserTitleForURL(varValue){ if (varValue==""){ return "No Title"; }else{ return varValue; } } function isNew(){ var visitorSession=''; visitorSession=getCookie('sessionID'); if (visitorSession=='' || visitorSession==null){ setCookie('sessionID','p97u4oampqi86d8hj4n40ibo80',1); return true; }else{ return false; } } /******************************************************************************************** INVITATIONS ********************************************************************************************/ function invite(varMessage, varStyle, varInviteID, varWebsiteKey, varInviteType, varAdvisorPhoto){ switch(varInviteType){ case "STANDARD": var newdiv = document.createElement('div'); newdiv.setAttribute('id','chat-invite'); newdiv.innerHTML = '
'+varMessage+'
'; document.body.appendChild(newdiv); break; case "CUSTOM": caInviteJS(varMessage,varInviteID,varWebsiteKey); break; } } function removeInvite() { var olddiv = document.getElementById('chat-invite'); document.body.removeChild(olddiv); } /******************************************************************************************** CHATS ********************************************************************************************/ function acceptChat(varInviteID,varWebsiteKey){ var d = new Date(); var t = d.getTime(); window.open("http://chatadvisors.buffalofulfillment.com/livesupport/accept/"+varInviteID+"/"+cookieForURL(getCookie('sessionID'))+"/"+varWebsiteKey+"/"+t,"cachat","width=400,height=500"); createJS("accept/"+getCookie('sessionID'), "acceptJS"); removeInvite(); } function requestChat(){ var d = new Date(); var t = d.getTime(); window.open("http://chatadvisors.buffalofulfillment.com/livesupport/request/"+cookieForURL(getCookie('sessionID'))+"/B0BC7DD6A4FFF5728CBC163C65B1FE1A/"+t,"cachat","width=400,height=500"); } function refuseChat(varInviteID){ createJS("refuse/"+varInviteID+"/"+cookieForURL(getCookie('sessionID')), "refuseJS"); removeInvite(); } /******************************************************************************************** TIMERS And CONTROLLERS ********************************************************************************************/ function createJS(varURL, varID){ var oScript = document.createElement("script"); var d = new Date(); var t = d.getTime(); oScript.src = "http://chatadvisors.buffalofulfillment.com/livesupport/"+varURL+"/"+t+"/6/"+browserURL; oScript.id = varID; document.body.appendChild(oScript); } function startDualTimer(){ if(document.getElementById('dualJS')){ document.body.removeChild(document.getElementById('dualJS')); } createJS("monitor/B0BC7DD6A4FFF5728CBC163C65B1FE1A/"+cookieForURL(getCookie('sessionID'))+"/"+browserTitleForURL(browserTitle), "dualJS"); // Track visitor dualT=setTimeout("startDualTimer()",5000); } function stopDualTimer(){ clearTimeout(dualT); } /*********************************************************************************************** ************************************************************************************************ ***********************************************************************************************/ isNew(); // Start session createJS("monitor/B0BC7DD6A4FFF5728CBC163C65B1FE1A/"+cookieForURL(getCookie('sessionID'))+"/"+browserTitleForURL(browserTitle), "dualJS"); startDualTimer();