Wt=function(){return};Wt.chat=function(){return};Wt.chat.PublicChat=function(){var API_version="v2.10";var _singleton;_singleton={enablePublicChat:true,site:"",statusExpireMinutes:null,statusCallback:"",msgChatBegun:"Please wait for the chat to begin.",msgPopUpWarn:"Please unblock pop-ups for this chat.",msgUnavailable:"Sorry, chat is temporarily unavailable",crsChatSystem:"",msg:"",wsUrl:"",useInfoForm:null,startOptions:{},getStatus:function(){var params={};this.msg="";try{if(this.enablePublicChat!==true){this.status="offline";this.msg=this.msgUnavailable;this._setCookie("chatStatus"+this.site,this.status,this.statusExpireMinutes);this._setCookie("chatStatusMsg"+this.site,this.msg,this.statusExpireMinutes)}}catch(e){}try{this.status=this._getCookie("chatStatus"+this.site);this.msg=this._getCookie("chatStatusMsg"+this.site);this.useInfoForm=this._getCookie("chatUseForm"+this.site);if(this.status!==null){if(this.msg===null){if(this.status!=="ready"){this.msg=""}else{this.msg=this.msgUnavailable}}if(this.statusCallback){this.statusCallback.call()}return}}catch(e){}params.site=(this.site||"");var urlEncodedParams=this._urlEncode(params);if(urlEncodedParams!==""){urlEncodedParams="&"+this._urlEncode(params)}this.msg=this.msgUnavailable;var jsonUrl=this.wsUrl+"webspeed/public/chat/wsPublicChatStatus.w?upRespFormat=json"+urlEncodedParams;this._jsonp(jsonUrl,"Wt.chat.PublicChat.getStatus_callback")},getStatus_callback:function(result){try{this.status=this._evalJson(result,"status");try{this.useInfoForm=this._evalJson(result,"useForm")}catch(e){}}catch(e){this.status="offline";this.msg=this.msgUnavailable}if(this.status==="ready"&&this.msg===this.msgUnavailable){this.msg=""}this._setCookie("chatStatus"+this.site,this.status,this.statusExpireMinutes);this._setCookie("chatStatusMsg"+this.site,this.msg,this.statusExpireMinutes);this._setCookie("chatUseForm"+this.site,this.useInfoForm,this.statusExpireMinutes);if(this.statusCallback){this.statusCallback.call()}},getWsUrl_callback:function(result){var resultUrl="";try{resultUrl=(this._evalJson(result,"wsUrl")||this.wsUrl)}catch(e){}if(resultUrl!==""){this.wsUrl=resultUrl}if(this.wsUrl.lastIndexOf("/")+1<this.wsUrl.length){this.wsUrl+="/"}this.statusCallback=(this.initParams.statusCallback||this.statusCallback);this.startOptions=(this.initParams.startOptions||{});this.site=(this.initParams.startOptions.site||this.initParams.site||"");this.getStatus()},init:function(params){this.initParams=params;this.msgUnavailable=(this.initParams.msgUnavailable||this.msgUnavailable);this.chatStartInProcess=false;if(this.crsChatSystem!==""){var jsonUrl="http://crslogin.com/php/getUrlAsJsonp.php?system="+this.crsChatSystem;this._jsonp(jsonUrl,"Wt.chat.PublicChat.getWsUrl_callback")}else{this.getWsUrl_callback()}},start:function(options){if(this.status!=="ready"){return}var jsonUrl;var name;var objElem;var params={};var strFeatures;var strName;if(this.chatStartInProcess){alert(this.msgChatBegun);return}try{if(this.chatSessionWindow&&!this.chatSessionWindow.closed){try{this.chatSessionWindow.focus();return}catch(e){return}}}catch(e){}var windowConfig=(this.startOptions.window||{});var top=(windowConfig.top||0);var left=(windowConfig.left||0);var width=(windowConfig.width||350);var height=(window.screen.width>800&&window.screen.height>600?540:(window.screen.availHeight-48));height=(windowConfig.height||height);strFeatures="status=yes,resizable=yes,scrollbars=yes,titlebar=yes,width="+width+",height="+height+",top="+top+",left="+left;var now=new Date();strName=(windowConfig.name||"crs"+now.getTime());this.chatSessionWindow=window.open("about:blank",strName,strFeatures);if(this.chatSessionWindow){if(this.chatSessionWindow.name===undefined){alert(this.msgPopUpWarn);return}}else{alert(this.msgPopUpWarn);return}if(this.useInfoForm!=="true"){this.chatStartInProcess=true}try{this.chatSessionWindow.document.body.innerHTML=this.msgChatBegun}catch(e){}var options=(options||{});options=(typeof options==="object"?options:{});var myOptions=this.startOptions;for(var prop in options){if(typeof myOptions[prop]==="undefined"){myOptions[prop]=options[prop]}else{for(var subprop in options[prop]){myOptions[prop][subprop]=options[prop][subprop]}}}var aClickStream=(myOptions.clickStream||[]);params.clickStream=((aClickStream.toString())||"");params.initialText=((myOptions.initialText)||"");params.shoppingCart=((myOptions.shoppingCart)||"");params.site=((myOptions.site)||this.site||"");for(var prop in myOptions.info){params[prop]=myOptions.info[prop]}if(myOptions.form){var elements=myOptions.form.elements;for(var i=0,len=elements.length;i<len;++i){objElem=elements.item(i);if(objElem.value){name=(objElem.id||objElem.name);params[name]=objElem.value}}}if(this.useInfoForm==="true"){this._openChatInfoForm(params);return}var jsonUrl=this.wsUrl+"webspeed/public/chat/wsChatsessionNew.w?upRespFormat=json&upAction=update&chatAction=getMessage&upLock=no&"+this._urlEncode(params);this._jsonp(jsonUrl,"Wt.chat.PublicChat._postChatsessionComplete")},_copyDataFromServer:function(response){this.sessionData={};for(var prop in response){if(prop!=="err"&&prop!=="info"&&prop!=="warn"){try{this.sessionData[prop]=this._getResponseValue(response,prop)}catch(e){}}}return true},_evalJson:function(jsonString,returnField){var err;var msg;var response;var result;try{result=eval(jsonString);if(result.wtResponse!==undefined){response=result.wtResponse}else{response=result}}catch(e){if(returnField==="status"){if(this.msgUnavailable){this.msg=this.msgUnavailable}return"offline"}else{return}}msg=this._getResponseValue(response,"infoMsg");if(msg){var aInfoMsg=[];aInfoMsg=msg.split("|");for(var i=0,len=aInfoMsg.length;i<len;++i){if(aInfoMsg[i]!==""){switch(i){case 0:this.msgChatBegun=aInfoMsg[i];break;case 1:this.msgPopUpWarn=aInfoMsg[i];break}}}}err=this._getResponseValue(response,"err");if(err){msg=(this._getResponseValue(response,"errMsg")||err);this.msg=msg}return this._getResponseValue(response,returnField)},_getCookie:function(cName){var aCookie=document.cookie.split("; ");for(var i=0;i<aCookie.length;i++){var aCrumb=aCookie[i].split("=");if(cName==aCrumb[0]){return unescape(aCrumb[1])}}return null},_getResponseValue:function(response,tagName){var value="";try{value=response[tagName]}catch(e){}return value},_jsonp:function(url,callback,query){if(url.indexOf("?")>-1){url+="&callback="}else{url+="?callback="}url+=callback+"&";if(query){url+=encodeURIComponent(query)+"&"}url+=new Date().getTime().toString();var script=document.createElement("script");script.setAttribute("src",url);script.setAttribute("type","text/javascript");document.body.appendChild(script)},_openChatInfoForm:function(params){var objElem;var name;var strFeatures;var strName;var strUrl;var objWindow;var value;var windowConfig=(this.startOptions.window||{});this.sessionData=params||{};this.sessionData.mode="edit";this.sessionData.chatrequestor="initiator";this.sessionData.cssUrl=(windowConfig.cssUrl||"");this.sessionData.footerHtml=(windowConfig.footerHtml||"");this.sessionData.headerHtml=(windowConfig.headerHtml||"");this.sessionData.logoUrl=(windowConfig.logoUrl||"");this.sessionData.title=(windowConfig.title||"");this.sessionData.site=(this.site||"");strUrl=this.wsUrl+"webspeed/public/ntOpen.w?upHtmlFile=webspeed/public/chat/pubChatInfoForm.htm&"+this._urlEncode(this.sessionData);this.chatSessionWindow.location.replace(strUrl);try{if(!this.chatSessionWindow.closed){this.chatSessionWindow.focus()}}catch(e){}},_openChatsession:function(){var objElem;var name;var strFeatures;var strName;var strUrl;var objWindow;var value;var windowConfig=(this.startOptions.window||{});this.sessionData.mode="edit";this.sessionData.chatrequestor="initiator";this.sessionData.cssUrl=(windowConfig.cssUrl||"");this.sessionData.footerHtml=(windowConfig.footerHtml||"");this.sessionData.headerHtml=(windowConfig.headerHtml||"");this.sessionData.logoUrl=(windowConfig.logoUrl||"");this.sessionData.title=(windowConfig.title||"");this.sessionData.site=(this.site||"");strUrl=this.wsUrl+"webspeed/public/ntOpen.w?upHtmlFile=webspeed/public/chat/pubChatSession.htm&"+this._urlEncode(this.sessionData);this.chatSessionWindow.location.replace(strUrl);if(this.chatSessionWindow&&!this.chatSessionWindow.closed){try{this.chatSessionWindow.focus()}catch(e){}}},_postChatsessionComplete:function(jsonString){var err;var err;var errMsg;var msg="";var response;var result;var status;this.chatStartInProcess=false;try{result=eval(jsonString);response=result.wtResponse}catch(e){if(this.msgUnavailable){this.status="offline";this.msg=this.msgUnavailable;this.statusCallback.call()}return false}err=this._getResponseValue(response,"err");if(err){msg=(this._getResponseValue(response,"errMsg")||err);this.status="offline";this.msg=msg;if(this.statusCallback){this.statusCallback.call()}return false}var chatAvailable=this._copyDataFromServer(response);if(chatAvailable){this._openChatsession()}},_setCookie:function(cName,value,expireMinutes){var exdate=new Date();exdate.setDate(exdate.getDate()+expireMinutes);document.cookie=cName+"="+escape(value)+";path=/"+((expireMinutes==null)?"":";expires="+exdate.toGMTString())},_urlEncode:function(o){if(!o){return""}var buf=[];for(var key in o){var ov=o[key],k=encodeURIComponent(key);var type=typeof ov;if(type=="undefined"){buf.push(k,"=&")}else{if(type!="function"&&type!="object"){buf.push(k,"=",encodeURIComponent(ov),"&")}else{if(ov.constructor.toString().indexOf("Array")>-1){if(ov.length){for(var i=0,len=ov.length;i<len;i++){buf.push(k,"=",encodeURIComponent(ov[i]===undefined?"":ov[i]),"&")}}else{buf.push(k,"=&")}}}}}buf.pop();return buf.join("")}};return _singleton}();
