var agentPic; var agentName; //var agentId; var agentPicId; var agentColorId = 1; var agentIsMale; // Add trim support to IE8 if (typeof String.prototype.trim !== 'function') { String.prototype.trim = function () { return this.replace(/^\s\s*/, '').replace(/\s\s*$/g, ''); } } // Set / Get cookie function SetCookie(cName, cValue, expDays) { var dayMilisec = 86400000; var expireDays = expDays; var todayDate = new Date(); var expireDate = new Date(); if (expireDays == null || expireDays == 0) expireDays = 1; var expires = "; path=/"; if (expDays) { expireDate.setTime(todayDate.getTime() + (dayMilisec * expireDays)); expires += "; expires=" + expireDate.toUTCString(); } document.cookie = cName + "=" + escape(cValue) + expires; } function GetCookie(cName) { var docCookies = document.cookie.split(';'); var cookieValue = null; var cookie; if (docCookies.length > 0) { for (var i = 0; i < docCookies.length; i++) { if (docCookies[i].indexOf('=') != -1) cookie = docCookies[i].split('='); if (typeof (cookie) != "undefined" && cName == cookie[0].trim()) { cookieValue = unescape(cookie[1]); break; } } } return cookieValue; } function DeleteCookie(cName) { if (GetCookie(cName)) { document.cookie = cName + "=;expires=Thu, 01-Jan-1970 00:00:01 GMT"; } } function SetDemoAgent(agent_id, agent_name, agent_color_id, isMaleAgent) { var agentClosedColor; var agentOpenedColor; var agentCookie = GetCookie("demoAgent"); var demoAgent; var agentProp; // enable demo only when running in StarAgent site if(window.location.host.indexOf("staragent.co.il") != -1) { if (agentCookie != null && agentCookie.indexOf('~') != -1) { demoAgent = agentCookie.split('~'); for (var i = 0; i < demoAgent.length; i++) { agentProp = demoAgent[i]; if (agentProp.split('=')[0] == "agentName" && agent_name != null) { agentName = unescape(agentProp.split('=')[1]); } else if (agentProp.split('=')[0] == "agentPicId") { agentPicId = agentProp.split('=')[1]; } else if (agentProp.split('=')[0] == "agentColorId") { agentColorId = agentProp.split('=')[1]; } else if (agentProp.split('=')[0] == "agentPic") { agentPic = agentProp.split('=')[1]; } else if (agentProp.split('=')[0] == "agentIsMale") { agentIsMale = agentProp.split('=')[1]; } } } if(agent_name != null) agentName = agent_name; /* if (typeof (agent_id) == "undefined") agentId = 1; else*/ // agent id is the agent pic id (1 - 6) if (agentPicId > 1000) agentPicId = 1; else if(agent_id > 0) agentPicId = agent_id; /* if (typeof (agent_color_id) == "undefined") agentColorId = 1; else*/ if(agent_color_id > 0) agentColorId = agent_color_id; if (agent_id == 0 || typeof(agentPicId) == "undefined") { agentPic = $(this.parent.miniAgent).css('background-image'); } else { agentPic = "url('/Images/Chat/AgentPics/chat_agent_" + agentPicId + ".png')"; } // get the agentPicId from agentPic if (typeof (agentPicId) == "undefined" && typeof (agentPic) != "undefined" && agentPic.indexOf('_') != -1 && agentPic.length > agentPic.indexOf('_') + 4) { var tmpAgentPicId = agentPic.substring(agentPic.lastIndexOf('_') + 1); if (tmpAgentPicId.indexOf('.') != -1) { agentPicId = tmpAgentPicId.split('.')[0]; } } if (typeof (isMaleAgent) != "undefined") { agentIsMale = isMaleAgent; } else if (typeof (agentPicId) != "undefined" && isNaN(agentPicId) == false && agentPicId > 6) { agentIsMale = true; } agentClosedColor = "url('/Images/Chat/chat_close_" + agentColorId + ".png')"; agentOpenedColor = "url('/Images/Chat/chat_open_" + agentColorId + ".png')"; //demoAgent = "agentName=" + agentName + "~agentPicId=" + agentPicId + "~agentPic=" + agentPic + "~agentColorId=" + agentColorId; demoAgent = "agentName=" + agentName + "~agentPicId=" + agentPicId + "~agentPic=" + agentPic + "~agentColorId=" + agentColorId + "~agentIsMale=" + agentIsMale; SetCookie("demoAgent", demoAgent, 1); SetCookie("isMaleAgent", agentIsMale, 1); if(agentName != null && typeof(agentName) != "undefined" && agentName != "") $("#chatIfrm").contents().find(".chatAgentName").text(agentName + ": "); if (agentPic != null && typeof (agentPic) != "undefined" && agentPic != "") { if (typeof ($("#miniAgent").css("background-image")) == "string") $("#miniAgent").css("background-image", agentPic); if (typeof ($("#chatMiniAgent").css("background-image")) == "string") $("#chatMiniAgent").css("background-image", agentPic); } if (agentColorId != null && typeof (agentColorId) != "undefined" && agentColorId > 0) { if ($("#chatIfrm") != null && $("#chatIfrm").contents().find("#chatIframBody") != null) $("#chatIfrm").contents().find("#chatIframBody").css("background-image", agentOpenedColor); if ($("#miniAgentContainer") != null && typeof ($("#miniAgentContainer")) != "undefined") $("#miniAgentContainer").css("background-image", agentClosedColor); } if (typeof (agentIsMale) != "undefined") { if (agentIsMale == true) { if (typeof (maleAgentAwaitsMsg) != "undefined" && maleAgentAwaitsMsg != '') { $('#agentAwaitsMsg').html(maleAgentAwaitsMsg); } if (typeof (maleAgentChatTitle) != "undefined" && maleAgentChatTitle != '' && $("#chatIfrm") != null && $("#chatIfrm").contents().find("#lblTopMessage") != null) { $("#chatIfrm").contents().find("#lblTopMessage").html(maleAgentChatTitle); } } else { if (typeof (femaleAgentAwaitsMsg) != "undefined" && femaleAgentAwaitsMsg != '') { $('#agentAwaitsMsg').html(femaleAgentAwaitsMsg); } if (typeof (femaleAgentChatTitle) != "undefined" && femaleAgentChatTitle != '' && $("#chatIfrm") != null && $("#chatIfrm").contents().find("#lblTopMessage") != null) { $("#chatIfrm").contents().find("#lblTopMessage").html(femaleAgentChatTitle); } } } } } var jsRef = document.createElement('script'); jsRef.type = 'text/javascript'; jsRef.async = true; jsRef.charset = 'UTF-8'; jsRef.src = '//StarAgent.co.il/StarUsersFiles/45492/Agents/34491/Scripts/chatSys.js?ver=636116944295170000'; jsRef.setAttribute('defer', 'defer'); var js = document.getElementsByTagName('script')[0]; js.parentNode.insertBefore(jsRef, js);