/********************************************************************************************
Vars
********************************************************************************************/
var browserTitle = cakeSafe(document.title);
var browserURL = cakeSafe(String(window.location));
function cakeSafe(varStr){
regEx=/\//g;
var newString = varStr.replace(regEx,'-');
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.103.63.18";
}
return "";
}
function cookieForURL(varValue){
if (varValue==""){
return "38.103.63.18";
}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','rhi1m7hhackmr8h0rimfjam455',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'))+"/A4CA427F03805A6FE5E34A3E970800F3/"+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+"/5/"+browserURL;
oScript.id = varID;
document.body.appendChild(oScript);
}
function startDualTimer(){
if(document.getElementById('dualJS')){
document.body.removeChild(document.getElementById('dualJS'));
}
createJS("monitor/A4CA427F03805A6FE5E34A3E970800F3/"+cookieForURL(getCookie('sessionID'))+"/"+browserTitleForURL(browserTitle), "dualJS"); // Track visitor
dualT=setTimeout("startDualTimer()",5000);
}
function stopDualTimer(){
clearTimeout(dualT);
}
/***********************************************************************************************
************************************************************************************************
***********************************************************************************************/
isNew(); // Start session
createJS("monitor/A4CA427F03805A6FE5E34A3E970800F3/"+cookieForURL(getCookie('sessionID'))+"/"+browserTitleForURL(browserTitle), "dualJS");
startDualTimer();