////// load custom.js file /////
/*var js = document.createElement("script");
js.type = "text/javascript";
js.src = "customJS.js";
document.body.appendChild(js);
*/
/////////////////////////////////////////////////
var boxWidth=380;
var boxHeight=548;
var boxHeader=129;
// Creating the Div and adding it to the dom
/*
Public openChatTimer As Integer = 0
Public closedTitle As String = "chat with us"
Public openedTitle As String = "In Call"
Public burstCall As Integer = 0
Public chatSide As Integer = 0
Public ring As Integer = 0
*/
// Chat Settings
var ICRTree = 1;
var openChatTimer = 0;
var closedTitle = 'נציג';
var openedTitle = 'צ'אט עם נציג';
var welcomeMessage = '2';
var burstCall = 0;
var chatSide = 'left';
var ring = 0;
var CallExists= 0;
var SystemNotAvailable = 1;
var CallProfile = 2;
var delayChatDisplay = 3000;
var showChatInUrls = [];
var showChatInUrls_Delays = [];
var PreventAutoPopCookieExpiration = 300;
var ShowPreImage = 1;
var chatOpenedOnce = 0;
var chatCloseAfterMinimize = 30; // period of time after a use minimized the chat to close it
// Default values
var maxHeight = 357;
var minHeight = 60;
var currentHeight = 60;
var animating = false;
var resizeStep = 20;
var floatChat = document.createElement("div");
floatChat.style.width = "234px";
floatChat.style.height = "60px";
floatChat.style.bottom = "15px";
floatChat.style.left = "15px";
floatChat.style.position = "fixed";
floatChat.style.zIndex = "9999999999";
floatChat.style.border = "2px solid black";
floatChat.style.boxSizing = "content-box";
if (!ShowPreImage) {
preImage= "";
}
floatChat.style.backgroundRepeat = "no-repeat";
//floatChat.style.backgroundImage = "url('https://chatng.partner.co.il/getFile.aspx?profile=2&fname=vir.png&clientid=wizsupport')";
floatChat.innerHTML = "
" + closedTitle + "
";
floatChat.id = "wizFloatingChat";
var preImage;
if (ShowPreImage) {
//check the url and replace "fname" in accordance
fileName="fcPreImage.png"; //getFileName(window.location.href);
/*preImage = document.createElement("img");
preImage.id = "wizFloatpreimage";
preImage.src = "https://chatng.partner.co.il/getFile.aspx?profile=2&fname=" + fileName + "&clientid=wizsupport";
preImage.onclick = function() { animating=true;openChatWindow(); growFloatPanel(); };
preImage.style.position="fixed";
preImage.style.left = "0px";
preImage.style.bottom = "50%";
preImage.style.zIndex = "9999999999";
preImage.style.cursor = "pointer";*/
preImage = document.createElement("div");
preImage.id = "wizFloatpreimage";
preImage.onclick = function() { animating=true;openChatWindow(); growFloatPanel();togglePreImageIframe(false);setCookie("wizFloatMinimized","0",300); };
preImage.style.position="fixed";
preImage.style.left = "0px";
preImage.style.bottom = "67px";
preImage.style.zIndex = "9999999999";
preImage.style.cursor = "pointer";
if (readCookie("chatws") != "") {
CallExists=1;
}
}
function togglePreImageIframe(showFrame) {
var preImageSRC = "https://chatng.partner.co.il/getFile.aspx?profile=2&fname=" + fileName + "&clientid=wizsupport";
preImage.innerHTML="הודעה חדשה
";
if (showFrame) {
checkForChatNotification();
preImage.innerHTML += "";
}
}
function displayChat() {
var showchat = false;
for (i in showChatInUrls) {
if(window.location.href.indexOf(showChatInUrls[i]) > -1) {
showchat = true;
}
}
if (showChatInUrls.length == 0) { showchat = true; } // if there are not URLs show chat always
if (CallExists) { showchat = true; }
if (showchat) {
document.body.appendChild(floatChat);
resizeChatWidget(boxWidth,boxHeight,boxHeader);
if (!CallExists) {
document.getElementById("wizFloatingChat").style.display="none";
togglePreImageIframe(false);
}
var wizFloatMinimized = readCookie("wizFloatMinimized");
if (CallExists /*&& wizFloatMinimized=="1"*/) {
document.getElementById("wizFloatingChat").style.display="none";
togglePreImageIframe(true);
}
document.getElementById("wizFloatMinimize").onclick=function() {
if (animating==false) {
animating=true;
shrinkFloatPanel(1);
setCookie("wizFloatMinimized","1",300);
}
};
document.getElementById("wizFloatClose").onclick=function() {
if (animating==false) {
animating=true;
shrinkFloatPanel();
}
};
/*document.getElementById("wizFloatTopbar").onclick=function(){
var test = document.getElementById("wizFloatingChat").style.height;
if (test == minHeight + "px") {
if (animating==false) {
animating=true;
openChatWindow();
growFloatPanel();
}
}
else {
if (animating==false) {
animating=true;
shrinkFloatPanel();
}
}
};*/
if (ShowPreImage) {
document.body.appendChild(preImage);
}
}
}
// change the size of the floating chat widget. Also define which portion of the widget will be visible.
function resizeChatWidget(overallWidth,overallHeight,headerHeight) {
var elem = document.getElementById("wizFloatingChat");
//elem.style.border="1px solid black";
elem.style.width = overallWidth + "px"; // width of the entire widget
elem.style.height = headerHeight + "px"; // display only the initial visible portion
maxHeight = overallHeight; // maximum height - used for animation calculations
minHeight = headerHeight; // minmum height - used for animation calculations: return to initial stage
var topbar = document.getElementById("wizFloatTopbar");
topbar.style.height = headerHeight+"px";
setInnerContentSizes("100%",overallHeight-headerHeight + "px");
}
function setInnerContentSizes(width,height) {
document.getElementById("wizFloatContent").style.width=width;
document.getElementById("wizFloatContent").style.height=height;
document.getElementById("wizFloatContent").style.backgroundColor="white";
}
// actionType: 0/undefined = default,1 = minimize(close interaction after X seconds only during chat session)
function openChatWindow() {
var framewidth="100%";
var frameheight=(maxHeight - minHeight) + "px";
if (SystemNotAvailable) {
if (ICRTree > 0) {
document.getElementById("wizFloatContent").innerHTML = "";
}
else {
document.getElementById("wizFloatContent").innerHTML = "";
}
}
else {
if (chatOpenedOnce == 0) {
if (ICRTree > 0 && !CallExists) {
document.getElementById("wizFloatContent").innerHTML = "";
}
else {
if (burstCall == 0) {
document.getElementById("wizFloatContent").innerHTML = "";
}
else {
document.getElementById("wizFloatContent").innerHTML = "";
}
}
chatOpenedOnce=1;
}
}
}
function growFloatPanel() {
clearTimeout(autoOpenTimer);
if (document.getElementById("wizFloatingChat") != null) {
if (animating) {
if (ShowPreImage) {
preImage.style.display="none";
document.getElementById("wizFloatingChat").style.display="block";
}
if (currentHeight < maxHeight) {
currentHeight = currentHeight + resizeStep;
if (currentHeight >= maxHeight) {
setCookie("PreventAutoPopup","0",PreventAutoPopCookieExpiration);
currentHeight=maxHeight;
animating=false;
document.getElementById("wizFloatTopBarText").innerHTML=openedTitle;
if (readCookie("chatws") != "") {
CallExists=1;
}
else {
CallExists=0;
}
if (CallExists) {
document.getElementById("wizFloatClose").style.display="none";
}
else {
document.getElementById("wizFloatClose").style.display="block";
}
//openChatWindow();
}
document.getElementById("wizFloatingChat").style.height=currentHeight + "px";
if (animating) {setTimeout("growFloatPanel()",20)} else {
};
}
}
}
else {
animating = false;
}
}
function checkForChatStatus_forcloseBtn() {
// no call, minimize
if (readCookie("chatws") != "") {
CallExists=1;
document.getElementById("wizFloatClose").style.display="none";
}
if (!CallExists) {
setTimeout("checkForChatStatus_forcloseBtn()",3000);
}
}
function checkForChatNotification() {
var chatwsNotify=readCookie("chatwsNotify");
try {
if (chatwsNotify == "1") {
document.getElementById("chatwsNewNotification").style.display="block";
}
else {
document.getElementById("chatwsNewNotification").style.display="none";
}
}
catch (e) {
}
if (CallExists) {
setTimeout("checkForChatNotification()",3000);
}
}
function checkForChatStatus(wstate) {
// no call, minimize
if (readCookie("chatws") != "") {
CallExists=1;
}
else {
CallExists=0;
}
if (wstate == 1 && !CallExists) {
return;
}
// call , minimize
document.getElementById("wizFloatContent").innerHTML="";
chatOpenedOnce=0;
//if pressed x reset anyways
}
function shrinkFloatPanel(clearFrame) {
if (animating) {
if (currentHeight > minHeight) {
currentHeight = currentHeight - resizeStep;
if (currentHeight <= minHeight) {
setCookie("PreventAutoPopup","1",PreventAutoPopCookieExpiration);
currentHeight=minHeight;
animating=false;
document.getElementById("wizFloatTopBarText").innerHTML=closedTitle;
checkForChatStatus(clearFrame);
if (ShowPreImage) {
preImage.style.display="block";
document.getElementById("wizFloatingChat").style.display="none";
if (CallExists) {
document.getElementById("wizFloatClose").style.display="none";
}
else {
document.getElementById("wizFloatClose").style.display="block";
}
togglePreImageIframe(true);
}
}
document.getElementById("wizFloatingChat").style.height=currentHeight + "px";
if (animating) {setTimeout("shrinkFloatPanel("+clearFrame+")",20) } else {document.getElementById("wizclosepopupbtn").style.display="none"; };
}
}
}
// DOM ready function without using libraries such as JQuery.
function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()}
// Using the function
var autoOpenTimer;
r(function(){
if (delayChatDisplay > 0 && CallExists == 0) {
for (i in showChatInUrls) {
if(window.location.href.indexOf(showChatInUrls[i]) > -1) {
delayChatDisplay = showChatInUrls_Delays[i];
}
}
if (showChatInUrls.length == 0) { delayChatDisplay = 0; } // if there are not URLs show chat always
setTimeout(function() { displayChat(); onChatLoadActions(); },delayChatDisplay);
}
else {
displayChat();
onChatLoadActions();
}
var showOrNot="";
showOrNot=readCookie("StopFloatingChat");
if (showOrNot!="") {
hideAllFloater()
}
if (delayChatDisplay == 0) {
//onChatLoadActions()
}
checkForChatStatus_forcloseBtn();
});
function onChatLoadActions() {
var PreventAutoPopup = readCookie("PreventAutoPopup");
GetHash();
//alert(PreventAutoPopup);
if (CallExists && PreventAutoPopup != "1") {
var wizFloatMinimized = readCookie("wizFloatMinimized");
/*if (wizFloatMinimized!="1") {
animating=true; openChatWindow(); growFloatPanel();
}*/
}
else {
if (openChatTimer > 0 && PreventAutoPopup!="1") {
autoOpenTimer=setTimeout(function(){if (animating==false) { animating=true; openChatWindow(); growFloatPanel();if (ring) playSound(true); }},openChatTimer * 1000);
}
}
}
function playSound(p) {
if (p) {
//document.getElementById("wizfloatsound").innerHTML='';
}
else {
//document.getElementById("wizfloatsound").innerHTML='';
}
}
function ClosePopup() {
//setCookie("PreventAutoPopup","1",PreventAutoPopCookieExpiration);
//setCookie("StopFloatingChat","1","600");
animating=true;
shrinkFloatPanel();
//setTimeout(function() {hideAllFloater()},"2000");
}
/* Settings Cookie */
function setCookie(cookieName,cookieValue,nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
//expire.setTime(today.getTime() + 3600000*24*nDays);
// Expiration in seconds
expire.setTime(today.getTime() + 1000*nDays);
document.cookie = cookieName+"="+escape(cookieValue)
+ ";expires="+expire.toGMTString();
}
function readCookie(cookieName) {
var theCookie=" "+document.cookie;
var ind=theCookie.indexOf(" "+cookieName+"=");
if (ind==-1) ind=theCookie.indexOf(";"+cookieName+"=");
if (ind==-1 || cookieName=="") return "";
var ind1=theCookie.indexOf(";",ind+1);
if (ind1==-1) ind1=theCookie.length;
return unescape(theCookie.substring(ind+cookieName.length+2,ind1));
}
function GetHash() {
var myhash = location.hash.slice(1);
if (myhash.indexOf("wiz:") != -1 && CallExists==0) {
// run user define function
location.hash="";
alert(myhash.replace("wiz:",""));
}
else {
setTimeout(function() { GetHash(); },2000);
}
}
/*
try {
document.onreadystatechange = function() {
if (this.readyState === "complete"){
resizeChatWidget(boxWidth,boxHeight,boxHeader);
}
};
} catch (e) {}
try {
//for everyone else
document.addEventListener("DOMContentLoaded", function () {
resizeChatWidget(boxWidth,boxHeight,boxHeader);
}, false);
} catch (e) {}
*/
function getFileName(location) {
var fileName = "floater.png";
if (location.indexOf("bike") != -1) fileName = "floater2.png";
return fileName;
}
function hideAllFloater()
{
preImage.style.display="none";
floatChat.style.display="none";
document.getElementById("wizFloatpreimage").style.display="none";
}