var GUID=null;var visitorId=null;var visitorName=null;var referrer=null;var source="";var endStatus="0";var websiteId=null;var host=new String();var SessionCookie=null;var ChatStatusCookie=null;var windowDisplayed=false;host=location.hostname.toString();if(host.substring(0,4)=="www."){host=host.substring(4,host.length)}var statusErased=false;function addLoadEvent(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func}else{window.onload=function(){if(oldonload){oldonload()}func()}}}function GetDomainName(url){return url.split(/\/+/g)[1]}function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1,c.length)}if(c.indexOf(nameEQ)==0){return c.substring(nameEQ.length,c.length)}}}function createCookie(name,value,hours){if(hours){var date=new Date();date.setTime(date.getTime()+(hours*60*60*1000));var expires="; expires="+date.toGMTString()}else var expires="";document.cookie=name+"="+value+expires+"; path=/; domain="+host+";"}function createCookieWithDayExpiry(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString()}else var expires="";document.cookie=name+"="+value+expires+"; path=/"}function setCookie(name,value,expires,path,domain,secure){var curCookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")+((secure)?"; secure":"");document.cookie=curCookie}function jsonpCreator(url){var script=document.createElement("script");script.setAttribute("src",url);script.setAttribute("type","text/javascript");script.setAttribute("charset","UTF-8");document.body.appendChild(script)}function InsertVisitorIdOnlyResponse(result){if(result!=null){if(result[0]!=""){visitorId=result[0];visitorName=result[1];GUID=result[2];createCookie(LC_VIC,"Session="+result[2],2160);if(readCookie(LC_VIC)!=null){SetSource()}}}}function InsertVisitorIdOnly(){jsonpCreator(_chatURL+"InsertVisitorIdOnly?method=InsertVisitorIdOnlyResponse")}function SetSource(){source=_trackURL+"?MySession="+"Session="+GUID+"&visitorId="+visitorId+"&websiteId="+websiteId+"&isNew=true&ref=";if(!referrer){referrer="None"}CreateIframe(referrer,source);var DNDCookie=readCookie(LC_DND);var IgnCook=readCookie(LC_IGN);if(statusErased&&DNDCookie==null&&IgnCook==null){setTimeout("StartChatProcess()",1000)}else if(IgnCook==null){getUsernameServiceURL=_chatURL+"GetUserOnMinimumChatsByLanguage?parDomain=";getUsernameServiceURL+=host;var dt=new Date();getUsernameServiceURL+="&strRandom=";getUsernameServiceURL+=dt.getTime().toString();getUsernameServiceURL+="&method=onGetUserOnMinimumChatsResponse";jsonpCreator(getUsernameServiceURL)}}function CreateIframe(ref,src){src+=escape(ref);src+="&url="+escape(document.URL.toString());ifrm=document.createElement("IFRAME");ifrm.setAttribute("src",src);ifrm.style.border="none";ifrm.style.width=0+"px";ifrm.style.height=0+"px";document.body.appendChild(ifrm)}function onGetWebsiteIDResponse(result){if(result!=null){websiteId=result;if(result!=0){var setId=InsertVisitorIdOnly()}}}function onGetVisitorIdForSessionIdResponse(result){if(result!=null){if(result!="0"){source=_trackURL+"?MySession="+SessionCookie+"&websiteId="+websiteId+"&ref=";CreateIframe(referrer,source);var DNDCookie=readCookie(LC_DND);var IgnCook=readCookie(LC_IGN);if(statusErased&&DNDCookie==null&&IgnCook==null){setTimeout("StartChatProcess()",1000)}else if(IgnCook==null){getUsernameServiceURL=_chatURL+"GetUserOnMinimumChatsByLanguage?parDomain=";getUsernameServiceURL+=host;var dt=new Date();getUsernameServiceURL+="&strRandom=";getUsernameServiceURL+=dt.getTime().toString();getUsernameServiceURL+="&method=onGetUserOnMinimumChatsResponse";jsonpCreator(getUsernameServiceURL)}}else{createCookie(LC_VIC,null,-24);SessionCookie="";InsertVisitorIdOnly()}}}function onGetWebsiteIDResponseOnly(result){if(result!=null){if(result!=0){websiteId=result;var index=SessionCookie.search("Session=")+8;GUID=SessionCookie.substring(index,index+32);var getVisitorIdForSessionId=_chatURL+"GetVisitorIdforSessionId?parSession=";getVisitorIdForSessionId+=GUID;getVisitorIdForSessionId+="&parRandom=";var dt=new Date();getVisitorIdForSessionId+=dt.getTime().toString();getVisitorIdForSessionId+="&method=onGetVisitorIdForSessionIdResponse";jsonpCreator(getVisitorIdForSessionId)}}}function makeFrame(){var refDomain="";SessionCookie=readCookie(LC_VIC);if(document.referrer&&document.referrer!=""){referrer=document.referrer.toString()}if(referrer){refDomain=GetDomainName(referrer)}if(refDomain!=location.hostname||refDomain==""||readCookie(LC_CEC)==null){createCookie(LC_CEC,null,-24);statusErased=true}ChatStatusCookie=readCookie(LC_CEC);if(ChatStatusCookie!=null){var index2=ChatStatusCookie.search("EndStatus=")+10;endStatus=ChatStatusCookie.substring(index2,index2+1)}if(SessionCookie!=null&&SessionCookie!=""){var websiteIdURL=_chatURL+"GetWebsiteID?parDomain=";websiteIdURL+=escape(host);var dt=new Date();websiteIdURL+="&strRandom=";websiteIdURL+=dt.getTime().toString();websiteIdURL+="&method=onGetWebsiteIDResponseOnly";jsonpCreator(websiteIdURL)}else{var websiteIdURL=_chatURL+"GetWebsiteID?parDomain=";websiteIdURL+=escape(host);var dt=new Date();websiteIdURL+="&strRandom=";websiteIdURL+=dt.getTime().toString();websiteIdURL+="&method=onGetWebsiteIDResponse";jsonpCreator(websiteIdURL)}}function liveChatGreet(){if(!windowDisplayed){windowDisplayed=true;WithoutGreet=true;clearTimeout(GreetingTimer);StartChatProcess()}}function WG_OnOfflineClick(){window.open(_offlineURL+"?websiteId="+websiteId+"&MySession="+"Session="+GUID,"_blank","menubar=0,resizable=0,width=630,height=450,scrollbars=0")}function onGetUserOnMinimumChatsResponse(result){if(result!=null){var lc_anchorTag=null;var anchorTag=null;if(result!=""){if(typeof(LC_textStatus)!="undefined"&&LC_textStatus){document.getElementById("live_chat_status").setAttribute("href","javascript:liveChatGreet()")}else{if(document.getElementById("live_chat_img")==null){if(typeof(lc_img_anchor)=="undefined"){var anchorTag=document.createElement("a");anchorTag.setAttribute("href","javascript:liveChatGreet()");anchorTag.style.border="none"}else{lc_anchorTag=document.getElementById("live_chat_anchor")}var footDiv=document.getElementById(liveChatStatus);var imgTag=document.createElement("img");imgTag.style.border="none";imgTag.setAttribute("id","live_chat_img");imgTag.setAttribute("src",_imageURL+LC_onlineImg);if(typeof(lc_img_anchor)=="undefined"){anchorTag.appendChild(imgTag);footDiv.appendChild(anchorTag)}else{lc_anchorTag.appendChild(imgTag)}}else{}}}else{if(typeof(LC_textStatus)!="undefined"&&LC_textStatus){document.getElementById("live_chat_status").setAttribute("href","javascript:WG_OnOfflineClick()")}else{if(document.getElementById("live_chat_img")==null){if(typeof(lc_img_anchor)=="undefined"){var anchorTag=document.createElement("a");anchorTag.setAttribute("href","javascript:WG_OnOfflineClick()");anchorTag.style.border="none"}else{lc_anchorTag=document.getElementById("live_chat_anchor")}var footDiv=document.getElementById(liveChatStatus);var imgTag=document.createElement("img");imgTag.style.border="none";imgTag.setAttribute("id","live_chat_img");imgTag.setAttribute("src",_imageURL+LC_onlineImg);if(typeof(lc_img_anchor)=="undefined"){anchorTag.appendChild(imgTag);footDiv.appendChild(anchorTag)}else{lc_anchorTag.appendChild(imgTag)}}else{}}}}}makeFrame();var autoGreetMessage=null;var autoGreetTime=null;var lc_message=null;var isGetVisitorName=false;var isPageSwitching=false;var username=null;var senderId=null;var actualUserId=null;var chatId=null;var messageId=0;var messagesFromServer=new Array();var firstMessage=true;var unblock=true;var completeChatText="";var chatCloseMessageTimer=null;var isCautioned=false;var isWindowClosing=false;var pageToPush="";var greetId=null;var isOnlyGreeted=false;var lastUserMessageId=0;var WithoutGreet=false;var GreetingTimer=null;var isAlreadyInChat=false;var CloseGreet=null;var checkAutoTransfer=false;var intervalsForGettingMessages=new Array();var timersForCloseMessage=new Array();var timerForUserMessage=new Array();var preReqArray=new Array();var MsgWin=document.getElementById("txtMessageWin");var ChatWin=document.getElementById("txtChatWin");var statusDIV=document.getElementById("typingstatus")?document.getElementById("typingstatus"):undefined;var lc_servicestatus="";function StartChatProcess(){if(!isAlreadyInChat){if(GUID!=null){var visitorIdURL=_chatURL+"GetChatPrerequisiteByLanguage?parSession=";visitorIdURL+=escape(GUID);visitorIdURL+="&parDomain=";visitorIdURL+=host;visitorIdURL+="&parIsNew=";if(visitorId!=null&&visitorId!="")visitorIdURL+="true";else visitorIdURL+="false";var dt=new Date();visitorIdURL+="&strRandom=";visitorIdURL+=dt.getTime().toString();visitorIdURL+="&method=onGetChatPrerequisiteResponse";jsonpCreator(visitorIdURL)}}}function onInsertOfflineStatusResponse(result){if(result!=null){}}function InsertOfflineStatus(){var visitorIdURL=_chatURL+"InsertOfflineStatus?parSessionId=";visitorIdURL+=escape(GUID);visitorIdURL+="&parDomain=";visitorIdURL+=host;visitorIdURL+="&parPreReq=";visitorIdURL+=preReqArray;var dt=new Date();visitorIdURL+="&parRandom=";visitorIdURL+=dt.getTime().toString();visitorIdURL+="&method=onInsertOfflineStatusResponse";jsonpCreator(visitorIdURL)}function onGetChatPrerequisiteResponse(result){var aLink=document.getElementById("conversationDIV");if(result!=null){preReqArray=result;var lc_anchorTag=null;var anchorTag=null;if(visitorId===null){visitorId=result[0];visitorName=result[1]}if(result[4]=="-1"){username=result[5];if(document.getElementById("cwin_username")!=null){document.getElementById("cwin_username").innerHTML=username}if(username!=""&&username!=null){if(!WithoutGreet){if(typeof(LC_textStatus)!="undefined"&&LC_textStatus){document.getElementById("live_chat_status").setAttribute("href","javascript:liveChatGreet()")}else{if(document.getElementById("live_chat_img")==null){if(typeof(lc_img_anchor)=="undefined"){anchorTag=document.createElement("a");anchorTag.setAttribute("href","javascript:liveChatGreet()");anchorTag.style.border="none"}else{lc_anchorTag=document.getElementById("live_chat_anchor")}var footDiv=document.getElementById(liveChatStatus);var imgTag=document.createElement("img");imgTag.style.border="none";imgTag.setAttribute("id","live_chat_img");imgTag.setAttribute("src",_imageURL+LC_onlineImg);if(typeof(lc_img_anchor)=="undefined"){anchorTag.appendChild(imgTag);footDiv.appendChild(anchorTag)}else{lc_anchorTag.appendChild(imgTag)}}}}senderId=result[6];actualUserId=result[6];autoGreetTime=result[7];autoGreetMessage=result[8];lc_message=result[8];lc_servicestatus=result[9];if(!WithoutGreet){if(lc_servicestatus=="1"){GreetingTimer=setTimeout("showWindow()",autoGreetTime*1000)}}else{setTimeout("showWindow()",1000)}}else{if(typeof(LC_textStatus)!="undefined"&&LC_textStatus){document.getElementById("live_chat_status").setAttribute("href","javascript:WG_OnOfflineClick()")}else{if(document.getElementById("live_chat_img")==null){if(typeof(lc_img_anchor)=="undefined"){var anchorTag=document.createElement("a");anchorTag.setAttribute("href","javascript:WG_OnOfflineClick()");anchorTag.style.border="none"}else{lc_anchorTag=document.getElementById("live_chat_anchor")}var footDiv=document.getElementById(liveChatStatus);var imgTag=document.createElement("img");imgTag.style.border="none";imgTag.setAttribute("id","live_chat_img");imgTag.setAttribute("src",_imageURL+LC_offlineImg);if(typeof(lc_img_anchor)=="undefined"){anchorTag.appendChild(imgTag);footDiv.appendChild(anchorTag)}else{lc_anchorTag.appendChild(imgTag)}}else{var imgTag=document.getElementById("live_chat_img");imgTag.style.border="none";imgTag.setAttribute("src",_imageURL+LC_offlineImg)}InsertOfflineStatus()}}}else if(result[4]=="1"){isAlreadyInChat=true;chatId=result[5];actualUserId=result[6];username=result[7];if(username!=""){if(document.getElementById("cwin_username")!=null){document.getElementById("cwin_username").innerHTML=username}if(typeof(LC_textStatus)!="undefined"&&LC_textStatus){document.getElementById("live_chat_status").setAttribute("href","javascript:liveChatGreet()")}else{if(document.getElementById("live_chat_img")==null){var anchorTag=document.createElement("a");anchorTag.setAttribute("href","javascript:liveChatGreet()");anchorTag.style.border="none";var footDiv=document.getElementById(liveChatStatus);var imgTag=document.createElement("img");imgTag.style.border="none";imgTag.setAttribute("id","live_chat_img");imgTag.setAttribute("src",_imageURL+LC_onlineImg);anchorTag.appendChild(imgTag);footDiv.appendChild(anchorTag)}else{var imgTag=document.getElementById("live_chat_img");imgTag.style.border="none";imgTag.setAttribute("src",_imageURL+LC_onlineImg)}}messageId=result[8];lc_message=result[9];senderId=result[10];lc_servicestatus=result[11];firstMessage=false;Dom.setStyle('ChatDiv','display','block');Dom.setStyle('ChatDiv','opacity',0);var fadeinatrib={opacity:{from:0,to:1}};var animmindiv=new YAHOO.util.Anim('ChatDiv',fadeinatrib);animmindiv.animate();if(senderId==0){ChatWin.value+=visitorName+": "+lc_message+"\n";ChatWin.scrollTop=ChatWin.scrollHeight}else{ChatWin.value+=username+": "+lc_message+"\n";ChatWin.scrollTop=ChatWin.scrollHeight}chatMessageAltURL=_chatURL+"GetChatMessagesAlt?parChatId=";chatMessageAltURL+=chatId;chatMessageAltURL+="&parMessageId=";chatMessageAltURL+=messageId;var dt=new Date();chatMessageAltURL+="&strRandom=";chatMessageAltURL+=dt.getTime().toString();chatMessageAltURL+="&method=onGetChatMessagesAltResponse";jsonpCreator(chatMessageAltURL);YAHOO.util.Event.addListener('conversationDIV','click',onConversationClick)}}aLink.style.display='block'}}function onConversationClick(){window.open(_convURL+"?chatId="+chatId,"_blank","menubar=0,resizable=1,width=400,height=500,scrollbars=1")}function showWindow(){windowDisplayed=true;Dom.setStyle('ChatDiv','display','block');Dom.setStyle('ChatDiv','opacity',0);var fadeinatrib={opacity:{from:0,to:1}};var animmindiv=new YAHOO.util.Anim('ChatDiv',fadeinatrib);animmindiv.animate();if(readCookie(LC_CEC)!=null){createCookie(LC_CEC,null,-24)}ChatWin.value=username+": "+lc_message+"\n";dt=new Date();var greetInfoInsertURL=_chatURL+"InsertGreetInfo?parUserId=";greetInfoInsertURL+=senderId;greetInfoInsertURL+="&parVisitorId=";greetInfoInsertURL+=visitorId;greetInfoInsertURL+="&parWebsiteId=";greetInfoInsertURL+=websiteId;greetInfoInsertURL+="&parRandom=";greetInfoInsertURL+=dt.getTime().toString();greetInfoInsertURL+="&method=onInsertGreetInfoResponse";jsonpCreator(greetInfoInsertURL)}function onInsertGreetInfoResponse(result){if(result!=null){greetId=result;isOnlyGreeted=true;CloseGreet=setTimeout("CloseOnlyGreet()",1000*60*5)}}function onInsertChatInfoResponse(result){if(result!=null){chatId=result[0];isAlreadyInChat=true;YAHOO.util.Event.addListener('conversationDIV','click',onConversationClick);SetIntervalForMessages()}}function insertChatMessages(){var chatMessageInsertURL=_chatURL+"InsertChatMessage?parMessage=";var strChatMessageTmp=lc_message.toString();var updatedChatMessage=ReplaceSpecialCharacters(escape(strChatMessageTmp));chatMessageInsertURL+=updatedChatMessage;chatMessageInsertURL+="&parChatId=";chatMessageInsertURL+=chatId;chatMessageInsertURL+="&parUserId=";chatMessageInsertURL+=senderId;chatMessageInsertURL+="&parAssignedUserId=";chatMessageInsertURL+=actualUserId;chatMessageInsertURL+="&parTimestamp=";var messageTimeStamp=new Date();chatMessageInsertURL+=messageTimeStamp.getFullYear().toString()+"_"+messageTimeStamp.getMonth().toString()+"_"+messageTimeStamp.getDate().toString()+"_"+messageTimeStamp.getHours().toString()+"_"+messageTimeStamp.getMinutes().toString()+"_"+messageTimeStamp.getSeconds().toString();chatMessageInsertURL+="&method=onInsertChatMessageResponse";jsonpCreator(chatMessageInsertURL)}function onInsertChatMessageResponse(result){if(result!=null){if(!firstMessage){SetIntervalForMessages()}}}function GetNextMessage(){var dt=new Date();chatMessageAltURL=_chatURL+"GetChatMessagesAlt?parChatId=";chatMessageAltURL+=chatId;chatMessageAltURL+="&parMessageId=";chatMessageAltURL+=messageId;chatMessageAltURL+="&strRandom=";chatMessageAltURL+=dt.getTime().toString();chatMessageAltURL+="&method=onGetChatMessagesAltResponse";jsonpCreator(chatMessageAltURL)}function onUpdateTypingStatusURLResponse(result){if(result!=null){if(result){return}else{return}}}function onUserTypingStatusResponse(result){if(result!=null){if(result){if(statusDIV!==undefined)statusDIV.style.visibility="visible"}else{if(statusDIV!==undefined)statusDIV.style.visibility="hidden"}}}function GetUserTypingStatusMethod(){var getOperatorTypingStatusURL=_chatURL+"GetUserTypingStatus?parUserId=";getOperatorTypingStatusURL+=chatId;var dt=new Date();getOperatorTypingStatusURL+="&strRandom=";getOperatorTypingStatusURL+=dt.getTime().toString();getOperatorTypingStatusURL+="&method=onUserTypingStatusResponse";jsonpCreator(getOperatorTypingStatusURL);return}function onGetStatusOfMessageResponse(result){if(result!=null){Dom.setStyle('ChatDiv','display','block');Dom.setStyle('ChatDiv','opacity',0);var fadeinatrib={opacity:{from:0,to:1}};var animmindiv=new YAHOO.util.Anim('ChatDiv',fadeinatrib);animmindiv.animate();senderId=result;if(result==0){ChatWin.value+=visitorName+": "+lc_message+"\n";ChatWin.scrollTop=ChatWin.scrollHeight}else if(result==senderId){ChatWin.value+=username+": "+lc_message+"\n";ChatWin.scrollTop=ChatWin.scrollHeight}else{actualUserId=result;var getUserNameURL=_chatURL+"GetUsername?parUserId=";getUserNameURL+=senderId;var dt=new Date();getUserNameURL+="&strRandom=";getUserNameURL+=dt.getTime().toString();getUserNameURL+="&method=onGetUsernameOnlyResponse";jsonpCreator(getUserNameURL)}}}function onGetUsernameOnlyResponse(result){if(result!=null){username=result;ChatWin.value+=username+": "+lc_message+"\n";ChatWin.scrollTop=ChatWin.scrollHeight;actualUserId=senderId}}function onGetVisitorNameOnlyResponse(result){if(result!=null){visitorName=result.toString()}}function GetVisitorNameMethod(){var visitorNameURL=_chatURL+"GetVisitorName?parVisitorId=";visitorNameURL+=visitorId;var dt=new Date();visitorNameURL+="&strRandom=";visitorNameURL+=dt.getTime().toString();visitorNameURL+="&method=onGetVisitorNameOnlyResponse";jsonpCreator(visitorNameURL)}function onGetChatMessagesAltResponse(result){if(result!=null){messagesFromServer=result;RetreiveAllMessages()}}function openURL(){if(pageToPush!=""&&pageToPush!=null){window.open(pageToPush,"_blank","menubar=1,resizable=1,width=800,height=600,scrollbars=1")}}YAHOO.util.Event.addListener('btnURL','click',openURL);function ExtractURL(){var regexp=/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;if(regexp.test(messagesFromServer[count].toString())){var urlArr=messagesFromServer[count].toString().match(regexp);pageToPush=urlArr[0].toString();openURL()}}function RetreiveAllMessages(){ClearIntervalForMessages();if(messagesFromServer.length>1){visitorName=messagesFromServer[messagesFromServer.length-4];if(messagesFromServer[messagesFromServer.length-2]!=""){username=messagesFromServer[messagesFromServer.length-2];actualUserId=messagesFromServer[messagesFromServer.length-3];senderId=messagesFromServer[messagesFromServer.length-3];if(document.getElementById("cwin_username")!=null){document.getElementById("cwin_username").innerHTML=username}}if(messagesFromServer[0]!=""){for(count=0;count<messagesFromServer.length-7;count+=2){lc_message=messagesFromServer[count];messageId=messagesFromServer[count+1];ChatWin.value+=username+": "+lc_message+"\n";ChatWin.scrollTop=ChatWin.scrollHeight;ExtractURL()}}if(messagesFromServer[messagesFromServer.length-7]==="True"){ClearIntervalForMessages();ChatWin.value=username+": This Chat has been closed due to inactivity and the window will close now in 10 seconds. To chat again kindly refresh your page."+"\n";setTimeout("document.getElementById('ChatDiv').style.display = 'none'",10*1000);if(messagesFromServer[messagesFromServer.length-6]==="1"){createCookie(LC_DND,LC_DND+"=1",8064)}else if(messagesFromServer[messagesFromServer.length-5]==="1"){createCookie(LC_IGN,LC_IGN+"=1",16128)}return}if(statusDIV!=undefined){if(messagesFromServer[messagesFromServer.length-1]==="True"){statusDIV.style.visibility="visible"}else{statusDIV.style.visibility="hidden"}}}SetIntervalForMessages()}function onGetUserLoginStatusResponse(result){if(result!=null){if(result[1]!=""){actualUserId=result[0];username=result[1]}checkAutoTransfer=false}}function GetUserLoginStatus(){var getUserLogin=_chatURL+"GetUserLoginStatus?parUserId="+actualUserId;getUserLogin+="&parChatId="+chatId;getUserLogin+="&parDomain="+host;var dt=new Date();getUserLogin+="&parRandom="+dt.getTime().toString();getUserLogin+="&method=onGetUserLoginStatusResponse";jsonpCreator(getUserLogin)}function onGetNewUserIdOnly(result){if(result!=null){senderId=result;var getUserURL=_chatURL+"TransferTempChatMessages?parChatId=";getUserURL+=chatId;getUserURL+="&parUserId=";getUserURL+=result;var dt=new Date();getUserURL+="&strRandom=";getUserURL+=dt.getTime().toString();getUserURL+="&method=onTransferTempChatMessagesResponse";jsonpCreator(getUserURL)}}function onTransferTempChatMessagesResponse(result){if(result!=null){if(result==""){var getUserNameURL=_chatURL+"GetUsername?parUserId=";getUserNameURL+=senderId;var dt=new Date();getUserNameURL+="&strRandom=";getUserNameURL+=dt.getTime().toString();getUserNameURL+="&method=onGetUsernameOnly";jsonpCreator(getUserNameURL)}else{}}}function onGetUsernameOnly(result){if(result!=null){username=result}}function SetTimerForAutoTransfer(){for(var i=0;i<timerForUserMessage.length;i++){if(timerForUserMessage[i]==null){timerForUserMessage=setTimeout("TransferChat()",3*60*1000);return}}timerForUserMessage[timerForUserMessage.length]=setTimeout("TransferChat()",3*60*1000)}function ClearTimerForUserMessage(){for(var i=0;i<timerForUserMessage.length;i++){clearTimeout(timerForUserMessage[i])}}function SendChatMessage(){if(MsgWin.value.toString().length>=300){MsgWin.value.toString().substr(0,300)}clearTimeout(chatCloseMessageTimer);if(isCautioned){ChatWin.value="";ChatWin.value=completeChatText;isCautioned=false}var str=MsgWin.value;var trimmed=str.replace(/^\s+|\s+$/g,'');if(trimmed!=""){lc_message=MsgWin.value;ChatWin.value+=visitorName.toString()+": "+lc_message+"\n";MsgWin.scrollTop=MsgWin.scrollHeight;ChatWin.scrollTop=ChatWin.scrollHeight;MsgWin.value="";senderId=0;if(firstMessage){clearTimeout(CloseGreet);firstMessage=false;isOnlyGreeted=false;Dom.setStyle('conversationDIV','display','block');InsertChat()}else{ClearIntervalForMessages();insertChatMessages();SetTimerVar=false}}}YAHOO.util.Event.addListener('btnSend','click',SendChatMessage);function onUpdateUserChatResponse(result){if(result!=null){}}function SetIntervalForMessages(){for(var i=0;i<intervalsForGettingMessages.length;i++){if(intervalsForGettingMessages[i]==null){intervalsForGettingMessages[i]=setTimeout("GetNextMessage()",1800);return}}intervalsForGettingMessages[intervalsForGettingMessages.length]=setTimeout("GetNextMessage()",1800)}function ClearIntervalForMessages(){for(var i=0;i<intervalsForGettingMessages.length;i++){clearTimeout(intervalsForGettingMessages[i])}}function CloseChatWindow(){windowDisplayed=false;var attributes={opacity:{from:1,to:0}};var anim=new YAHOO.util.Anim('ChatDiv',attributes);anim.animate();anim.onComplete.subscribe(function(){Dom.setStyle('ChatDiv','display','none')});if(!isOnlyGreeted){var EndChatURL=_chatURL+"UpdateChatEndTime?parChatId=";EndChatURL+=chatId;EndChatURL+="&parChatEndTime=";var chatEndTimeDate=new Date();EndChatURL+=chatEndTimeDate.getDate().toString()+"_"+chatEndTimeDate.getMonth().toString()+"_"+chatEndTimeDate.getFullYear().toString()+"_"+chatEndTimeDate.getHours().toString()+"_"+chatEndTimeDate.getMinutes().toString()+"_"+chatEndTimeDate.getSeconds().toString();EndChatURL+="&method=onEndChatResponse";jsonpCreator(EndChatURL)}else{createCookie(LC_CEC,"EndStatus=1",1);isAlreadyInChat=false}ChatWin.value="";MsgWin.value="";ClearTimerForCloseMessage();ClearIntervalForMessages()}function CloseOnlyGreet(){var attributes={opacity:{from:1,to:0}};var anim=new YAHOO.util.Anim('ChatDiv',attributes);anim.animate();anim.onComplete.subscribe(function(){Dom.setStyle('ChatDiv','display','none')});createCookie(LC_CEC,"EndStatus=1",1);isAlreadyInChat=false}YAHOO.util.Event.addListener('closeBTN','click',CloseChatWindow);function onEndChatResponse(result){if(result!=null){if(result||result==""){firstMessage=true;createCookie(LC_CEC,"EndStatus=1",1);isAlreadyInChat=false;ChatWin.value="";MsgWin.value="";ClearTimerForCloseMessage();ClearIntervalForMessages()}}}function ResetChatEndTime(){var EndChatURL=_chatURL+"UpdateChatEndTime?parChatId=";EndChatURL+=chatId;EndChatURL+="&parChatEndTime=";EndChatURL+="";EndChatURL+="&method=onUpdateChatEndTimeResponse";jsonpCreator(EndChatURL)}function onUpdateChatEndTimeResponse(result){if(result!=null){if(result!=""){}}}function BlockKey(){MsgWin.value="";setTimeout("unblock=true",1000)}function onKeyPressFunc(){if(MsgWin.value.toString().length>=300){var tmpMessage=MsgWin.value.toString();MsgWin.value=tmpMessage.substr(0,300)}if(unblock){var messageSender=SendChatMessage();unblock=false}BlockKey()}var press=new YAHOO.util.KeyListener('txtMessageWin',{keys:13},{fn:onKeyPressFunc,correctScope:true},"keypress");press.enable();function onKeyUpFunc(){MsgWin.value=""}var up=new YAHOO.util.KeyListener('txtMessageWin',{keys:13},{fn:onKeyUpFunc,correctScope:true},"keyup");up.enable();function ClearMsgWin(){MsgWin.value=""}function onPageLeavingUpdateVisitorReponse(result){if(result!=null){if(result){return}else{return}if(isWindowClosing){CloseChatWindow()}}}function ResetChatTimer(){if(visitorId!=0){var liveVisitorResetURL=_chatURL+"UpdateVisitorStatus?parVisitorId=";liveVisitorResetURL+=visitorId+"&parIsLiveVisitor=";liveVisitorResetURL+=false;var dt=new Date();liveVisitorResetURL+="&strRandom=";liveVisitorResetURL+=dt.getTime().toString();liveVisitorResetURL+="&method=onPageLeavingUpdateVisitorReponse";jsonpCreator(liveVisitorResetURL);for(i=0;i<30;){i++}}ClearIntervalForMessages()}function CheckWindowClosing(){if(window.event.clientY<0&&(window.event.clientX>(document.documentElement.clientWidth-5)||window.event.clientX<15)){isWindowClosing=true;var liveVisitorClosingURL=_chatURL+"UpdateVisitorStatus?parVisitorId=";liveVisitorClosingURL+=visitorId+"&parIsLiveVisitor=";liveVisitorClosingURL+=false;var dt=new Date();liveVisitorClosingURL+="&strRandom=";liveVisitorClosingURL+=dt.getTime().toString();liveVisitorClosingURL+="&method=onPageLeavingUpdateVisitorReponse";jsonpCreator(liveVisitorClosingURL);CloseChatWindow();for(i=0;i<30;){i++}}}function CloseChatMessage(){completeChatText=ChatWin.value;ChatWin.value+="\n"+"Due to Inactivity this chat window will close in 2 minutes!"+"\n";chatCloseMessageTimer=setTimeout("CloseChatWindow()",2*60*1000);isCautioned=true}function SetTimerForCloseMessage(){for(var i=0;i<timersForCloseMessage.length;i++){if(timersForCloseMessage[i]==null){timersForCloseMessage[i]=setTimeout("CloseChatMessage()",3*60*1000);return}}timersForCloseMessage[timersForCloseMessage.length]=setTimeout("CloseChatMessage()",3*60*1000)}function ClearTimerForCloseMessage(){for(var i=0;i<timersForCloseMessage.length;i++){clearTimeout(timersForCloseMessage[i])}}function InsertChat(){var chatInfoInsertURL=_chatURL+"InsertChatInfoAndMessage?parUserId=";chatInfoInsertURL+=actualUserId;chatInfoInsertURL+="&parAssignedUserId=";chatInfoInsertURL+=actualUserId;chatInfoInsertURL+="&parWebsiteId=";chatInfoInsertURL+=websiteId;chatInfoInsertURL+="&parVisitorId=";chatInfoInsertURL+=visitorId;chatInfoInsertURL+="&parRunningStatus=";chatInfoInsertURL+=false;chatInfoInsertURL+="&parVisitorName=";chatInfoInsertURL+=visitorName;chatInfoInsertURL+="&parGreetId=";chatInfoInsertURL+=greetId;chatInfoInsertURL+="&parGreetMessage=";var newGreetMessage=ReplaceSpecialCharacters(autoGreetMessage);chatInfoInsertURL+=newGreetMessage;chatInfoInsertURL+="&parChatMessage=";chatInfoInsertURL+=ReplaceSpecialCharacters(lc_message);chatInfoInsertURL+="&parRandom=";var dt=new Date();chatInfoInsertURL+=dt.getTime().toString();chatInfoInsertURL+="&method=onInsertChatInfoResponse";jsonpCreator(chatInfoInsertURL)}function ReplaceSpecialCharacters(stringValue){var updatedString="";updatedString=stringValue.replace("#","#");updatedString=updatedString.replace("$","$");updatedString=updatedString.replace("&","&");updatedString=updatedString.replace("+","+");updatedString=updatedString.replace(",",",");updatedString=updatedString.replace("/","/");updatedString=updatedString.replace(":",":");updatedString=updatedString.replace(";",";");updatedString=updatedString.replace("=","=");updatedString=updatedString.replace("?","?");updatedString=updatedString.replace("@","@");return updatedString}