var icPatronChat=icPatronChat||function(){var initialH=0;var initialW=0;var chatButtonH=80;var chatButtonW=180;var minH=0;var minW=0;var chatH=600;var chatW=380;var _frame=null;var _chatButtonFrame=null;var _host=null;var isIpad=false;var popOutChat;var CHILD_WINDOW_HANDLE=null;var _url="";var win;var showBadge;var customChatButton=false;var xMax;var yMax;var minHeight=400;var minWidth=380;var customWidth=null;var customHeight=null;var windowConfig=null;var browserScrollWidth=21;var windowScrollWidth=17;var leftPos;var topPos;var sessionParameter=[];function resizeChat(frame,h,w){if(frame){frame.height=h;frame.width=w}}function addCss(position){var css=".ie-div-position-customer-chat {display: block;} .chat-iframe-wrap {border-radius: 5px 5px 0 0;z-index: 2147483000;position: fixed;bottom: 100px;width: 380px;min-height: 300px;border-radius: 8px;overflow: hidden;opacity: 1;height: calc(100% - 130px);box-shadow: 0 -5px 50px rgba(0, 0, 0, .2);"+position+": 24px;} .ie-iframe-fixed-customer-chat {background: transparent; border: none; height: 100%;} .ie-iframe-absolute-customer-chat {background: transparent; border: none; top: 0px; float:none; margin: 0px; padding: 0px; position: relative;"+position+": 24px;} .iframe-shadow {border-radius: 5px 5px 0 0;box-shadow: 0 -5px 50px rgba(0, 0, 0, .2);}";var head=document.head||document.getElementsByTagName("head")[0];var style=document.createElement("style");css=css+".button-iframe-wrap {bottom: 0px; position: fixed; height: 10%; display: block; z-index: 2147483638;} .ie-chat-button-iframe-fixed-customer-chat {background: transparent; border: none; bottom: 24px; position: fixed;"+position+": 24px; outline: none} .ie-chat-button-iframe-absolute-customer-chat {background: transparent; border: none; top: 0px; float:none; margin: 0px; padding: 0px; position: relative;"+position+": 24px;}";style.type="text/css";if(style.styleSheet){style.styleSheet.cssText=css}else{style.appendChild(document.createTextNode(css))}head.appendChild(style)}function addChatIframe(url,host){var d;var d1;var d2;d=document.createElement("div");d1=document.createElement("div");d2=document.createElement("div");d.className="ie-div-position-customer-chat";_frame=document.createElement("iframe");_frame.src=url;_frame.allowtransparency="true";_frame.frameborder="0px";_frame.id="icChat";_frame.name="icChat";_frame.title="Chat Window";_frame.scrolling="no";_frame.style.borderStyle="none";_frame.className="ie-iframe-fixed-customer-chat";d1.id="chat-div-wrap";d1.className="chat-iframe-wrap";d1.appendChild(_frame);_chatButtonFrame=document.createElement("iframe");_chatButtonFrame.src=host+"/inContact/ChatClient/chatButton.html";_chatButtonFrame.allowtransparency="true";_chatButtonFrame.frameborder="0px";_chatButtonFrame.id="icChatButton";_chatButtonFrame.name="icChatButton";_chatButtonFrame.scrolling="no";_chatButtonFrame.height=chatButtonH;_chatButtonFrame.width=chatButtonW;_chatButtonFrame.style.borderStyle="none";_chatButtonFrame.className="ie-chat-button-iframe-fixed-customer-chat";d2.className="button-iframe-wrap";d2.appendChild(_chatButtonFrame);d.appendChild(d1);d.appendChild(d2);document.body.appendChild(d)}function isMobileBrowser(){var isMobile=false;if(/Android/i.test(navigator.userAgent||navigator.vendor||window.opera)){isMobile=true}else if(/iPhone/i.test(navigator.userAgent||navigator.vendor||window.opera)){isMobile=true}else if(/BlackBerry/i.test(navigator.userAgent||navigator.vendor||window.opera)){isMobile=true}else if(/webOS/i.test(navigator.userAgent||navigator.vendor||window.opera)){isMobile=true}else if(/IEMobile/i.test(navigator.userAgent||navigator.vendor||window.opera)){isMobile=true}else if(/Opera Mini/i.test(navigator.userAgent||navigator.vendor||window.opera)){isMobile=true}else{isMobile=false}return isMobile}function onMessageReceived(event){var mt;var md;var popInChat;var ispopOutChat=sessionStorage.getItem("isPopOut")&&sessionStorage.getItem("isPopOut")!=="true"?false:true;var position;try{if(event.origin===_host){mt=event.data.messageType;md=event.data.data;switch(mt){case"resize":if(md.minimize===true){resizeChat(_frame,minH,minW);_frame.classList.remove("iframe-shadow");document.getElementById("chat-div-wrap").style.width="0"}else{if(customChatButton===true){if(customHeight&&customWidth!==null){resizeChat(_frame,customHeight,customWidth)}else{resizeChat(_frame,chatH,chatW)}_frame.classList.add("iframe-shadow");document.getElementById("chat-div-wrap").style.height=customHeight+"px";document.getElementById("chat-div-wrap").style.width=customWidth+"px"}else{resizeChat(_frame,chatH,chatW);_frame.classList.add("iframe-shadow");document.getElementById("chat-div-wrap").style.width=chatW+"px"}}if(customChatButton===false){_chatButtonFrame.contentWindow.postMessage({messageType:"resize",data:md},"*")}break;case"isPopIn":sessionStorage.setItem("isPopOut","false");popInChat={messageType:"isPopIn",data:md};_frame.contentWindow.postMessage(popInChat,"*");if(customChatButton===false){_chatButtonFrame.contentWindow.postMessage({messageType:"isPopIn",data:{isPopIn:true}},"*")}break;case"getStoreData":if(CHILD_WINDOW_HANDLE){setTimeout(function(){CHILD_WINDOW_HANDLE.postMessage(popOutChat,"*")},500)}break;case"chatButtonClick":if ( document.getElementById("popCover").style.display === "none" ) { document.getElementById("popCover").style.display = ""; } else { document.getElementById("popCover").style.display = "none" }if(isMobileBrowser()){_chatButtonFrame.contentWindow.postMessage({messageType:"resize",data:{minimize:true}},"*");win=window.open(_url,"_blank");win.focus()}else{_frame.contentWindow.postMessage({messageType:"chatButtonClick",data:md},"*")}break;case"messageCount":_chatButtonFrame.contentWindow.postMessage({messageType:"messageCount",data:md},"*");if(showBadge&&{}.toString.call(showBadge)==="[object Function]"){showBadge(md.msgCount)}break;case"chatProfile":_chatButtonFrame.contentWindow.postMessage({messageType:"chatProfile",data:md},"*");position=md.chatProfile.chatButtonPosition.toLowerCase()==="bottomleft"?"left":"right";addCss(position);if(sessionParameter!=="undefined"&&sessionParameter.length>0){_frame.contentWindow.postMessage({messageType:"storeParameter",data:sessionParameter},"*")}break;case"isChildWindowClosed":_frame.contentWindow.postMessage({messageType:"isChildWindowClosed",data:md},"*");break}}}catch(err){}}function setIpad(){if(/iPad/i.test(navigator.userAgent||navigator.vendor||window.opera)){isIpad=true}}function getHeight(height){if(height<minHeight){height=minHeight}if(height>=window.innerHeight){height=window.innerHeight;document.getElementById("chat-div-wrap").style.maxHeight=height+"px"}return height}function getWidth(width){if(width<minWidth){width=minWidth}if(width>=window.innerWidth-windowScrollWidth){width=window.innerWidth-windowScrollWidth}return width}function setXYPosition(left,top,width,height){var xPosition;var yPosition;xMax=window.innerWidth-width-browserScrollWidth;yMax=window.innerHeight-height;if(left>=0&&left<=xMax){xPosition=left}else if(left<0){xPosition=0}else if(xMax<=0){xPosition=0}else if(left>xMax){xPosition=xMax}if(top>=0&&top<=yMax){yPosition=top}else if(top<=0){yPosition=0}else if(top>yMax){yPosition=yMax}document.getElementById("chat-div-wrap").style.left=xPosition+"px";document.getElementById("chat-div-wrap").style.top=yPosition+"px"}function showEmbed(){var wDiff;var hDiff;var ispopOutChat=sessionStorage.getItem("isPopOut")&&sessionStorage.getItem("isPopOut")!=="true"?false:true;if(customChatButton===true&&_frame&&!ispopOutChat){if(isMobileBrowser()){_chatButtonFrame.contentWindow.postMessage({messageType:"resize",data:{minimize:true}},"*");win=window.open(_url,"_blank");win.focus()}else{if((customHeight&&customWidth)!==null){resizeChat(_frame,customHeight,customWidth)}else if((customHeight||customWidth)===null){wDiff=window.innerWidth-chatW;hDiff=window.innerHeight-chatH;leftPos=wDiff/2;topPos=hDiff/2;setXYPosition(leftPos,topPos,chatW,chatH);document.getElementById("chat-div-wrap").style.bottom=topPos+"px";resizeChat(_frame,chatH,chatW);document.getElementById("chat-div-wrap").style.width=chatW+"px";document.getElementById("chat-div-wrap").style.height=chatH+"px"}_frame.contentWindow.postMessage({messageType:"chatButtonClick",data:{minimize:false}},"*");document.getElementById("chat-div-wrap").style.width=_frame.width+"px";document.getElementById("chat-div-wrap").style.height=_frame.height+"px";if(showBadge&&{}.toString.call(showBadge)==="[object Function]"){showBadge(0)}}}else{if((customHeight||customWidth)!==null){wDiff=window.innerWidth-customWidth;hDiff=window.innerHeight-customHeight;if(hDiff/2>topPos){topPos=topPos}else if(hDiff/2===topPos){topPos=hDiff}else if(hDiff/2<topPos){topPos=hDiff}if(wDiff/2>leftPos){leftPos=leftPos}else if(wDiff/2===leftPos){leftPos=wDiff}else if(wDiff/2<leftPos){leftPos=wDiff}setXYPosition(leftPos,topPos,customWidth,customHeight);document.getElementById("chat-div-wrap").style.top=topPos+"px";resizeChat(_frame,customHeight,customWidth);document.getElementById("chat-div-wrap").style.width=customWidth+"px";document.getElementById("chat-div-wrap").style.height=customHeight+"px";_frame.contentWindow.postMessage({messageType:"chatButtonClick",data:{minimize:false}},"*");if(showBadge&&{}.toString.call(showBadge)==="[object Function]"){showBadge(0)}}else{wDiff=window.innerWidth-chatW;hDiff=window.innerHeight-chatH;leftPos=wDiff/2;topPos=hDiff/2;setXYPosition(leftPos,topPos,chatW,chatH);document.getElementById("chat-div-wrap").style.bottom=topPos+"px";resizeChat(_frame,chatH,chatW);document.getElementById("chat-div-wrap").style.width=chatW+"px";document.getElementById("chat-div-wrap").style.height=chatH+"px";_frame.contentWindow.postMessage({messageType:"chatButtonClick",data:{minimize:false}},"*");if(showBadge&&{}.toString.call(showBadge)==="[object Function]"){showBadge(0)}}}}function windowDimensions(dimension){if(dimension!==null){windowConfig=dimension;dimension.left=isNaN(dimension.left)?10:dimension.left;dimension.top=isNaN(dimension.top)?10:dimension.top;customWidth=isNaN(dimension.width)?chatW:dimension.width;customHeight=isNaN(dimension.height)?chatH:dimension.height;leftPos=dimension.left;topPos=dimension.top;if(customChatButton===true){if(_frame){customHeight=getHeight(customHeight);customWidth=getWidth(customWidth);setXYPosition(dimension.left,dimension.top,customWidth,customHeight)}}}}function onResize(event){const elementVal=document.getElementById("chat-div-wrap").style.width.replace("px","");var width=parseInt(elementVal);if(width===NaN){width=0}if(width>0){if(customChatButton===true&&!isMobileBrowser()){windowDimensions(windowConfig);showEmbed()}}}function addEventListener(){var eventMethod=window.addEventListener?"addEventListener":"attachEvent";var eventer=window[eventMethod];var messageEvent=eventMethod==="attachEvent"?"onmessage":"message";eventer(messageEvent,onMessageReceived,false);eventer("resize",onResize,false)}return{init:function(args,badgeRef){var q="";var opt=[];var i=0;if(args.serverHost&&args.bus_no&&args.poc){_host=args.serverHost;customChatButton=args.customChatButton?true:false;opt=args.params?args.params:[];for(i=0;i<opt.length&&i<9;i++){sessionParameter.push(opt[i]);q=q+"&P"+i+"="+encodeURIComponent(opt[i])}if(!isMobileBrowser()){_url=_host+"/inContact/ChatClient/ChatClient.aspx?poc="+args.poc+"&bu="+args.bus_no}else{_url=_host+"/inContact/ChatClient/ChatClient.aspx?poc="+args.poc+"&bu="+args.bus_no+q}setIpad();addEventListener();if(!sessionStorage.getItem("isPopOut")){sessionStorage.setItem("isPopOut","false")}addChatIframe(_url,_host);resizeChat(_frame,initialH,initialW);if(customChatButton===false){resizeChat(_chatButtonFrame,chatButtonH,chatButtonW)}else{if(badgeRef&&{}.toString.call(badgeRef)==="[object Function]"){showBadge=badgeRef}resizeChat(_chatButtonFrame,initialH,initialW)}document.getElementById("chat-div-wrap").style.width="0";var el = document.getElementById('chat-div-wrap'); var popCover = document.createElement('div'); popCover.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="pop-out-svg injected-svg pop-out-icon" version="1.0" x="0px" y="0px" viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve" width="20px" height="20px" role="button" tabindex="0" style="fill: rgb(127, 127, 127); stroke: rgb(127, 127, 127); stroke-width: 0.75px" data-src="https://home-c71.nice-incontact.com/inContact/ChatClient/styles/svg/pop-out.svg"><title>PopOut Chat Window</title><path d="M14.88,0h-4.28c-0.12,0-0.23,0.04-0.31,0.12c-0.08,0.08-0.12,0.19-0.12,0.31v1.33  c0,0.12,0.04,0.23,0.12,0.31c0.08,0.08,0.19,0.12,0.31,0.12h1.7l-8.06,8.02c-0.22,0.22-0.33,0.48-0.33,0.79  c0,0.31,0.11,0.57,0.33,0.79c0.1,0.11,0.23,0.2,0.37,0.25c0.14,0.05,0.28,0.08,0.43,0.08c0.14,0,0.27-0.03,0.41-0.08  c0.14-0.05,0.26-0.14,0.37-0.25l7.98-7.94v1.36c0,0.12,0.04,0.23,0.12,0.31c0.08,0.08,0.19,0.12,0.31,0.12h1.33  c0.12,0,0.23-0.04,0.31-0.12C15.96,5.45,16,5.34,16,5.22V1.12c0-0.31-0.11-0.58-0.33-0.8S15.19,0,14.88,0z M15.56,8.09h-1.33  c-0.12,0-0.23,0.04-0.31,0.12C13.84,8.3,13.8,8.4,13.8,8.52v4.86c0,0.11-0.04,0.21-0.12,0.3c-0.08,0.08-0.18,0.12-0.3,0.12H2.62  c-0.11,0-0.21-0.04-0.3-0.12c-0.08-0.08-0.12-0.18-0.12-0.3V2.62c0-0.11,0.04-0.21,0.12-0.3C2.41,2.24,2.51,2.2,2.62,2.2H7.3  c0.11,0,0.21-0.04,0.3-0.12c0.08-0.08,0.12-0.19,0.12-0.31V0.44c0-0.12-0.04-0.23-0.12-0.31C7.51,0.04,7.41,0,7.3,0h-6  C0.93,0,0.62,0.12,0.38,0.38S0,0.93,0,1.3v13.42c0,0.35,0.12,0.66,0.38,0.91S0.93,16,1.3,16H14.7c0.36,0,0.67-0.12,0.92-0.38  S16,15.07,16,14.72v-6.2c0-0.11-0.04-0.21-0.12-0.3C15.79,8.14,15.69,8.09,15.56,8.09z"></path></svg>'; popCover.id = 'popCover'; popCover.style = 'position:absolute; z-index: 2147483001; padding-left: 7px; padding-top: 9px; height: 25px; width: 25px;'; el.appendChild(popCover); document.getElementById("popCover").style.display = "none"; var el = document.getElementById("icChat"); el.style.position = "absolute";}},setDimension:function(dimension){windowDimensions(dimension)},hide:function(){if(customChatButton===true&&_frame){if(isMobileBrowser()){_chatButtonFrame.contentWindow.postMessage({messageType:"resize",data:{minimize:true}},"*");win=window.open(_url,"_blank");win.focus()}else{resizeChat(_frame,minH,minW);_frame.height=minH+"px";_frame.width=minW+"px";document.getElementById("chat-div-wrap").style.width=minW+"px";_frame.contentWindow.postMessage({messageType:"chatButtonClick",data:{minimize:true}},"*")}}},show:function(){showEmbed()},setStateWindowToggle:function(){if(document.getElementById("chat-div-wrap").style.width>"0px"){this.hide()}else{if(CHILD_WINDOW_HANDLE!==null&&CHILD_WINDOW_HANDLE.closed===true){CHILD_WINDOW_HANDLE=null;_frame.contentWindow.postMessage({messageType:"isChildWindowClosed",data:{}},"*");sessionStorage.setItem("isPopOut","false");setTimeout(this.show,1e3)}else{this.show();document.getElementById("popCover").style.display='';}}}}}();