window.cobrowse=(function($){var LOG_LEVEL={ERROR:"ERROR",WARN:"WARN",INFO:"INFO"}; var parse_esurance=parent.location.hostname.indexOf("esurance")!=-1||parent.location.hash.indexOf("RTDEV-37298")!=-1; var CMD_CURRENT_WINDOW="CW"; var CMD_SUPPRESS="SUPPRESS"; var CMD_HEADPART="HEADPART"; var CMD_BODYPART="BODYPART"; var CMD_UPDATE="UPD"; var CMD_UPDATEPART="UPDPART"; var CMD_MOUSE_POSITION="MP"; var CMD_WINDOW_UNLOAD="UNLOAD"; var COBROWSE_CONTROLLER_VERSION=2; var DATA_AGENT_TYPE_HTML="HTML"; var ACTION_CURRENT_WINDOW="currentWindow"; var ACTION_HEAD="head"; var ACTION_RESOURCE="resource"; var ACTION_CHECK_EMBEDDED_RESOURCES="checkEmbeddedResources"; var ACTION_ACTIVE_WINDOW_SET="activeWindowSet"; var ACTION_ACTIVE_WINDOW_UNLOAD="activeWindowUnload"; var CMD_SERVER_ACTIVE_WINDOW_UPDATE="activeWindowUpdate"; var PS_CBC_AUTH="cbcAuth"; var PS_CBC_CHECK="cbcCheck"; var DEFAULT_AUTH_MODE={auth:0}; var isCanvasSupported=!!window.HTMLCanvasElement; var REPOSITORY_DIRECTORY="cbs/resource"; var cntAlertToAgent=0; var MAX_ALERT_SENT=2; var CSS_CLASS_BLOCK_CLICK="tcBlockClick"; var CSS_CLASS_HIGHLIGHT_TEXT="cbHighlightText"; var CSS_CLASS_HIGHLIGHT_INPUTS="cbHilightElement"; var CSS_CLASS_HIGHLIGHT_SELECT="cbHilightSelect"; var CSS_CLASS_HIGHLIGHT_IMAGE="cbHighlightImage"; function initCobrowseRequest(){return{data:null,seq:null,action:null,apg:null,mode:null,deltaTime:null,embeddedResources:[]} }function getPageDocument(attr){var cobrowseDocument; if(parse_esurance){cobrowseDocument=parent.document.getElementById("mainFrame").contentDocument }else{cobrowseDocument=parent.document }if(attr=="head"){return cobrowseDocument.head }else{if(attr=="body"){return cobrowseDocument.body }}return cobrowseDocument }var highlightInfo={colorMap:{"00ff00":"Lime","00ffff":"Aqua",ff00ff:"Fuchsia",ffbbbb:"Pink",bbffbb:"Reef",bbbbff:"Melrose",bbffff:"Onahau",ffbbff:"Pink Lace",ffffbb:"Shalimar",ffffff:"White"},total:0,id:"highlight_",screenReaderDiv:null,screenReaderId:"injectTargetScreenReader"}; var SUPPORTED_HIGHLIGHT_COLORS=Object.keys(highlightInfo.colorMap); var activeWindowId=0; var lastActiveWindowTime=0; var authCheckTimer=null; var TIMERINTERVAL_AUTH_CHECK=5000; var pageUpdateTimer=null; var TIMERINTERVAL_PAGE_UPDATE=2500; var activeWindowSetTimeout=null; var OUT_OF_QUEUE_ORDER=-1; var waitingScrollTo=null; var isWindowSetAsCurrentBeforeAuth=false; var MAX_PAGE_BODY_SIZE=5000000; var suppressedBigBodySize=false; var maskingRules=[]; function generateHighlightCssAI(){var result=""; for(var i=0; i>2; enc2=((chr1&3)<<4)|(chr2>>4); enc3=((chr2&15)<<2)|(chr3>>6); enc4=chr3&63; if(isNaN(chr2)){enc3=enc4=64 }else{if(isNaN(chr3)){enc4=64 }}output=output+_keyStr.charAt(enc1)+_keyStr.charAt(enc2)+_keyStr.charAt(enc3)+_keyStr.charAt(enc4) }return output }var CSS_REGEXP=/\.css(\?.+)?$/gi; function isEmbeddedResourceCss(url){return(url.match(CSS_REGEXP)) }function setEmbeddedImageUsingXMLHTTPRequest(url){var xhr=new XMLHttpRequest(); xhr.open("GET",url,false); xhr.onreadystatechange=function(){if(this.readyState==4){if(this.status==200){try{var data=(cobrowse.isIE)?getIEByteArray_ByteStr(this.responseBody):this.responseText; var base64Code=base64Encode(data); putEmbeddedResource(url,base64Code) }catch(e){logWarn("Warning(setEmbeddedImageUsingXMLHTTPRequest) while calling xhr.onreadystatechange: with"+url); putEmbeddedResource(url,"") }}else{logToServer("Cannot load image ["+url+"]",LOG_LEVEL.ERROR); putEmbeddedResource(url,"") }this.onreadystatechange=null; xhr=null }}; xhr.send(null) }function setEmbeddedImageUsingCanvas(url){var image=new Image(); image.onload=function(){try{var base64Code=getImageBase64DataUsingCanvas(this); base64Code=base64Code.substring(base64Code.indexOf(",")+1); putEmbeddedResource(url,base64Code) }catch(e){logWarn("Warning(setEmbeddedImageUsingCanvas) in image.onload: with"+url); putEmbeddedResource(url,"") }}; image.onerror=function(){logToServer("Cannot load image ["+url+"]",LOG_LEVEL.ERROR); putEmbeddedResource(url,"") }; image.src=url }function getImageBase64DataXML(svgNode){var svgXml=(new XMLSerializer()).serializeToString(svgNode); var image=new Image(); image.src="data:image/svg+xml;base64,"+btoa(svgXml); return image }function getImageBase64DataUsingCanvas(image){var canvas=document.createElement("canvas"); canvas.width=image.width; canvas.height=image.height; var context=canvas.getContext("2d"); try{context.drawImage(image,0,0) }catch(e){logWarn("Failed while drawing image using canvas (IE issue).") }try{var base64Data=canvas.toDataURL() }catch(e){base64Data=""; logWarn("Failed while drawing image using canvas (security issue).") }return base64Data }function getMediaType(styleSheet){try{return styleSheet.media.mediaText }catch(e){return"" }}function isValidMediaType(styleSheet){var media=getMediaType(styleSheet); if(!media||media==""||media.indexOf("all")!=-1||media.indexOf("screen")!=-1||media.indexOf("projection")!=-1){return true }return false }function setEmbeddedResourceCssContent(url){var parentResourceUrl=url.substring(0,url.lastIndexOf("/")+1); var styleSheet=findStyleSheetByUrl(url,parentResourceUrl); if(styleSheet){if(isValidMediaType(styleSheet)){var data=fixCssTextInStyleSheet(styleSheet,parentResourceUrl); var base64Data=base64Encode(data); putEmbeddedResource(url,base64Data) }else{logWarn("Warning(setEmbeddedResourceCssContent): Invalid media type of ["+url+"]. Css content is ignored") }}else{logWarn("Warning(setEmbeddedResourceCssContent): Invalid data of embedded CSS resource for ["+url+"]") }function findStyleSheetByUrl(url,parentResourceUrl){for(var i=0; i0&&obj.selectedIndex!=-1){var option=obj.options[obj.selectedIndex]; data.push("") }}},textarea:{attributes:{readonly:function(obj){inlineAttr("readonly","readonly") }},processTagBody:function(obj){data.push(htmlFilter.content($(obj),escaleNLinTextarea(obj.value))) }},style:empty,script:empty,noscript:empty}; var data=[]; function inlineAttr(name,value){data.push(" ",name,'="',replaceSpclCharsToSendToAI(value),'"') }var executeAttrProcessor=createExecuteAttrProcessor(inlineAttr); function processor(){if(this.nodeType==1){var tag=this.tagName.toLowerCase(); var tagfilter; if(htmlFilter.isHiddenNode&&htmlFilter.isHiddenNode($(this))){if(this.style.display=="none"){tagfilter=DISPLAY_NONE_TAG_FILTER }else{tagfilter=HIDDEN_TAG_FILTER }tagfilter.tag=tag }else{tagfilter=TAG_FILTERS[tag]; if(!tagfilter){tagfilter=DEFAULT_TAG_FILTER }}if(authorized&&(authorized.auth&cobrowse.SHARED_CONTROL)){if(htmlFilter.isBlockClickNode&&htmlFilter.isBlockClickNode($(this))){if(this.className.indexOf(CSS_CLASS_BLOCK_CLICK)==-1){this.className+=" "+CSS_CLASS_BLOCK_CLICK }}}if(tagfilter!==drop&&(!tagfilter.filter||tagfilter.filter(this))){data.push("<",tagfilter.tag?tagfilter.tag:tag); if(tagfilter!==empty){executeAttrProcessor(this,tagfilter,tagfilter.attrProcessor?tagfilter.attrProcessor:defaultAttributeProcessor) }if(tagfilter.allowEmpty){data.push("/>") }else{data.push(">"); if(tagfilter!==empty){if(tagfilter.processTagBody){tagfilter.processTagBody(this) }else{$(this.childNodes).generateHtmlInternal(processor) }}data.push("") }}}else{if(this.nodeType==3&&htmlFilter.contentNode){data.push(htmlFilter.contentNode(this)) }}}this.generateHtmlInternal(processor); return data }; $.fn.generateHtmlInternal=function(processor){this.each(processor) }; function escaleNLinTextarea(value){return value.split("&nl;").join("&&nnll;;") }var DATA_PACKAGE_SIZE_LIMIT=32000; var COOKIE_COBROWSE="cobrowse"; var COOKIE_EXPIRATION=24*60*60; var DIV_ID_COBROWSE_BANNER="tcCobrowseBannerDiv"; var DIV_ID_TERMS_AND_CONDITIONS="tcCbTermsAndConditions"; var DIV_ID_TERMS_CLOSE="tcCbTermsAndConditionsClose"; var DIV_ID_CHAT_SKIN="tcChat_Skin"; var CIV2_CHAT_SKIN="nuanMessagingFrame"; var isAcceptedPage=false; var lastMouse={X:-1,Y:-1}; var mouse={X:-1,Y:-1}; var modified=false; var authorized=null; var bodyLength=-1; var postQueue=[]; var sequence=1; var client_csq=0; var lastBodySentArray=[]; var scrollInfo={width:0,height:0,left:0,top:0,brwsrHeight:0,brwsrWidth:0}; var htmlFilter={}; var cmdRequest; function getJsonpUrl(){return Inq.urls.cobrowseURL+"/cobrowse/logging/logjavascript" }function logToServer(text,level){sendByJsonP(getJsonpUrl(),text,level||LOG_LEVEL.INFO) }function logInfo(message){logToServer(message) }function logWarn(message){logToServer(message,LOG_LEVEL.WARN) }function logError(message,e){var errorDetails="["+getFullBrowserInfo()+"] "+message+", URL: "+top.document.URL; if(logError.caller!=null){errorDetails+=", at:"+logError.caller.toString().split("{")[0] }if(e&&e.message){errorDetails+=", "+e.message; if(e.stack!=null){errorDetails+=",\nStack Trace:"+e.stack }}logToServer(errorDetails,LOG_LEVEL.ERROR); return function(value){logToServer(" Trace value:["+value+"]") } }function sendByJsonP(url,data,level){var jpMsg="cob.client"+(level=="ERROR"?"Error":"Info")+"?cid="+getChatID()+"&wid="+cobrowse.windowId+"&message="+data; var d=new Date(); var jpData={logger:"Cobrowse",timestamp:d.getTime(),level:level,url:window.location.href,message:jpMsg,layout:"JsonLayout"}; $.ajax({type:"GET",url:url,contentType:"application/json",dataType:"jsonp",data:jpData}) }function notifyAgentUponFailure(message){try{if(cntAlertToAgent0&&element.selectedIndex!=-1?htmlFilter.content($(element),element.options[element.selectedIndex].text):"" },getElements:function(){return getPageDocument().getElementsByTagName("SELECT") },cmd:"SEL",getCmdData:function(ix,value){return{IX:ix,OPTION:value} }},textArea:{getValue:function(element){return element.value },getElements:function(){return getPageDocument().getElementsByTagName("TEXTAREA") },cmd:"TA",getCmdData:function(ix,value,input){value=escaleNLinTextarea(value); return{IX:ix,TEXT:htmlFilter.content($(input),replaceSpclCharsToSendToAI(value))} }},swf:{getValue:function(element){var movie=getFlashMovieObject(element.name); if(movie==null){movie=element }try{if(movie.TGetProperty){return movie.TGetProperty("/",4) }}catch(e){logError("Error(inputTypes.swf.getValue)",e)("inputTypes.swf -> movie.TGetProperty") }return"0" },getElements:function(){var objects=getPageDocument().getElementsByTagName("OBJECT"); var swfs=[]; for(var i=0; i0){sendToCBS(ACTION_CHECK_EMBEDDED_RESOURCES,data.join(";"),"action="+ACTION_CHECK_EMBEDDED_RESOURCES) }}function sendCommandCheckEmbeddedResourcesV2(refreshFlag){var cobrowseRequest=initCobrowseRequest(); cobrowseRequest.action=ACTION_CHECK_EMBEDDED_RESOURCES; for(var url in resources){if((resources[url].state==STATE_NEW||refreshFlag)&&(resources[url].hash!=null)){var embeddedResource={absoluteUrl:url,correctedUrl:resources[url].correctedUrl,hash:resources[url].hash}; cobrowseRequest.embeddedResources.push(embeddedResource); resources[url].state=STATE_CHECKED }}if(cobrowseRequest.embeddedResources.length>0){sendToCBS(ACTION_CHECK_EMBEDDED_RESOURCES,cobrowseRequest) }}function sendCommandActiveWindowSet(time){if(isValidChatID()){if(COBROWSE_CONTROLLER_VERSION==2){var cobrowseRequest=initCobrowseRequest(); cobrowseRequest.data=""; cobrowseRequest.action=ACTION_ACTIVE_WINDOW_SET; sendCommandToCBSV2(ACTION_ACTIVE_WINDOW_SET,cobrowseRequest,"×tamp="+time) }else{sendCommandToCBSV1(ACTION_ACTIVE_WINDOW_SET,"","action="+ACTION_ACTIVE_WINDOW_SET+"×tamp="+time) }}}var commandIndex=0; function sendToCBS(command,data,params){if(authorized){if(COBROWSE_CONTROLLER_VERSION==2){sendCommandToCBSV2(command,data,params) }else{sendCommandToCBSV1(command,data,params) }}}function sendCommandToCBSV2(command,requestBody,params,postToServerCommand){if(!postToServerCommand){postToServerCommand="COBROWSE" }var result=prepareV2RequestBody(command,requestBody,url,params); var url=result[0]; requestBody=result[1]; try{var queueItem={command:command,request:[postToServerCommand,"",Inq.getSiteID(),getInqFrameUrl(),url,requestBody,2],errorCallback:callBackProxyError}; if(queueItem.command===CMD_CURRENT_WINDOW||queueItem.command===CMD_SUPPRESS){postQueue.unshift(queueItem) }else{postQueue.push(queueItem) }postQueueItemV2(false) }catch(e){logToServer("Error: "+e.message,LOG_LEVEL.ERROR) }}function prepareV2RequestBody(command,requestBody,url,params){if(command==ACTION_ACTIVE_WINDOW_UNLOAD){url=getServerPath()+"cbs/v2/pageUnload?"+ajaxParams(); requestBody="" }else{if(command==ACTION_RESOURCE||command==ACTION_CHECK_EMBEDDED_RESOURCES){if(!requestBody){requestBody=initCobrowseRequest() }requestBody.apg=isAcceptedPage; url=getServerPath()+"cbs/v2/resource?"+ajaxParams() }else{if(!requestBody){requestBody=initCobrowseRequest() }requestBody.apg=isAcceptedPage; url=getServerPath()+"cbs/v2/cobrowse?"+ajaxParams()+(params?"&"+params:"") }}return[url,requestBody] }function sendCommandToCBSV1(command,data,params,postToServerCommand){if(!postToServerCommand){postToServerCommand="COBROWSE" }var url=getServerPath()+"cbs/cobrowse?SEQ=n&APG="+isAcceptedPage+"&"+ajaxParams()+(params?"&"+params:""); try{var queueItem={command:command,request:[postToServerCommand,"",Inq.getSiteID(),getInqFrameUrl(),url,data,1],errorCallback:callBackProxyError}; if(queueItem.command===CMD_CURRENT_WINDOW||queueItem.command===CMD_SUPPRESS){postQueue.unshift(queueItem) }else{postQueue.push(queueItem) }postQueueItemV1(false) }catch(e){logToServer("Error: "+e.message,LOG_LEVEL.ERROR) }}var waitingAnswer=false; var lastCommandTime=0; function postQueueItemV1(flagStopWaiting){if(flagStopWaiting){waitingAnswer=false }if(!waitingAnswer&&postQueue.length==0){lastCommandTime=-1 }if(!waitingAnswer&&postQueue.length>0){waitingAnswer=true; var item=postQueue.shift(); var seq=item.command===ACTION_ACTIVE_WINDOW_UNLOAD||item.command===ACTION_ACTIVE_WINDOW_SET?OUT_OF_QUEUE_ORDER:sequence++; var boxID=item.command+(commandIndex++); item.boxID=boxID; item.request[1]=boxID; item.request[4]=item.request[4].replace("?SEQ=n&","?SEQ="+seq+"&"); var currentCommand=item.command; if(currentCommand==CMD_HEADPART||currentCommand==CMD_BODYPART){if(lastCommandTime!=-1){item.request[4]+="&deltaTime="+(now()-lastCommandTime) }if(item.request[4].indexOf("&action=")==-1){item.request[4]+="&action="+currentCommand }}Inq.FlashPeer.postRequestToIframeProxy(getServerPath(),item.request,item.request[1],getCallbackContext()); lastCommandTime=now() }}function postQueueItemV2(flagStopWaiting){if(flagStopWaiting){waitingAnswer=false }if(!waitingAnswer&&postQueue.length==0){lastCommandTime=-1 }if(!waitingAnswer&&postQueue.length>0){waitingAnswer=true; var item=postQueue.shift(); var seq=item.command===ACTION_ACTIVE_WINDOW_UNLOAD||item.command===ACTION_ACTIVE_WINDOW_SET?OUT_OF_QUEUE_ORDER:sequence++; var boxID=item.command+(commandIndex++); item.boxID=boxID; item.request[1]=boxID; item.request[5].seq=seq; var currentCommand=item.command; if(currentCommand==CMD_HEADPART||currentCommand==CMD_BODYPART){if(lastCommandTime!=-1){item.request[5].deltaTime=now()-lastCommandTime }if(item.request[5].action==null){item.request[5].action=currentCommand }}Inq.FlashPeer.postRequestToIframeProxy(getServerPath(),item.request,item.request[1],getCallbackContext()); lastCommandTime=now() }}function loadComplete(context){if(context){if(context.data!=null){var cd=context.data; if(cd.action=="ack"){window.Inq.CBC.ackReceived(cd.resp,cd.id) }else{if(cd.action=="auth"){window.Inq.CBC.callBackAuthorized(cd.resp,cd.id) }else{if(cd.action=="error"){var logLine="Response: "+cd.resp+'", ID: "'+cd.id+'", Log: "'+cd.log; callBackProxyError(logLine) }}}}}}function ajaxParams(){return"engagementID="+getChatID()+"&WID="+cobrowse.windowId }function xmlElement(elementName,elementBody){return"<"+elementName+">"+elementBody+"" }function sendCommandController(command,data,requestParams,params){if(COBROWSE_CONTROLLER_VERSION==2){sendCommandV2(command,data,requestParams,params) }else{sendCommandV1(command,data,requestParams) }}function sendCommandV1(command,data,params){var dataStrings=[]; for(var p in data){if(data.hasOwnProperty(p)){dataStrings.push(xmlElement(p,data[p])) }}sendToCBS(command,xmlElement(command,dataStrings.join("")),params?params:"") }function sendCommandV2(command,data,cobrowseRequest,params){if(!cobrowseRequest){cobrowseRequest=initCobrowseRequest() }var dataStrings=[]; for(var p in data){if(data.hasOwnProperty(p)){dataStrings.push(xmlElement(p,data[p])) }}cobrowseRequest.data=xmlElement(command,dataStrings.join("")); sendToCBS(command,cobrowseRequest,params) }function xmlCdata(elementBody){return"" }function getFromDocumentElementOrBody(name){return(getPageDocument()["documentElement"]!=null&&!!getPageDocument().documentElement[name])?getPageDocument().documentElement[name]:getPageDocument().body[name] }function addScrollData(data){data.BRWSR_HEIGHT=scrollInfo.brwsrHeight; data.BRWSR_WIDTH=scrollInfo.brwsrWidth; data.SCRLL_HEIGHT=scrollInfo.height; data.SCRLL_WIDTH=scrollInfo.width; data.SCRLL_LEFT=scrollInfo.left; data.SCRLL_TOP=scrollInfo.top; return data }function addHostedLocation(data){data.LOC=xmlCdata(getParentURL()); return data }function getParentURL(){return parent.location.href }function getServerPath(){var cobURL=Inq.urls.cobrowseURL; if(cobURL.indexOf("https")==-1){cobURL=cobURL.replace("http","https") }return cobURL+"/cobrowse/" }function getCookiePath(){return Inq.CM.getIFrameBaseURL() }function onMouseMove(ev){var e=ev?ev:event; mouse.X=e.pageX!=null?e.pageX:getFromDocumentElementOrBody("scrollLeft")+e.clientX; mouse.Y=e.pageY!=null?e.pageY:getFromDocumentElementOrBody("scrollTop")+e.clientY; return true }function mouseChanged(){if(mouse.X!=lastMouse.X||mouse.Y!=lastMouse.Y){lastMouse.X=mouse.X; lastMouse.Y=mouse.Y; return lastMouse }return false }function checkForInputChanges(inputType){var storage=inputType.storage; if(storage){for(var ix=0; ix0||getPageDocument().documentElement.scrollTop>0)){position=[getPageDocument().documentElement.scrollLeft,getPageDocument().documentElement.scrollTop] }else{if(typeof getPageDocument().body.scrollTop!="undefined"){position=[getPageDocument().body.scrollLeft,getPageDocument().body.scrollTop] }}}return position }function updateScrollChanges(){var changed=false; var scrollPosition=getScrollingPosition(); var clientHeight=getFromDocumentElementOrBody("clientHeight"); var scrollHeight=getFromDocumentElementOrBody("scrollHeight"); var scrollInfoUpdate={width:getPageDocument().defaultView.innerWidth,height:clientHeight,left:scrollPosition[0],top:scrollPosition[1],brwsrHeight:scrollHeight,brwsrWidth:getFromDocumentElementOrBody("scrollWidth")}; if(clientHeight>scrollHeight){scrollInfoUpdate.brwsrHeight=clientHeight; scrollInfoUpdate.height=getPageDocument().defaultView.innerHeight }if(scrollInfo.height!=scrollInfoUpdate.height||scrollInfo.width!=scrollInfoUpdate.width||scrollInfo.left!=scrollInfoUpdate.left||scrollInfo.top!=scrollInfoUpdate.top||scrollInfo.brwsrHeight!=scrollInfoUpdate.brwsrHeight||scrollInfo.brwsrWidth!=scrollInfoUpdate.brwsrWidth){scrollInfo=scrollInfoUpdate; changed=true }return changed }function windowHasFocus(){return window.parent.document.hasFocus() }var browserInfo=""; function getFullBrowserInfo(){if(!browserInfo&&typeof Inq!="undefined"&&Inq.getFullBrowserInfo){browserInfo=Inq.getFullBrowserInfo() }return browserInfo }function getAgentID(){if(typeof Inq!="undefined"&&(Inq.CHM)){return Inq.CHM.getAgentID() }return 0 }function isValidAgentID(){return(getAgentID()!=""&&getAgentID()!=0) }function getChatID(){if(typeof Inq!="undefined"&&(Inq.CHM)){return Inq.CHM.getChatID() }return"0" }function isValidChatID(){return(getChatID()!="0") }function whenActiveWindow(){if(COBROWSE_CONTROLLER_VERSION==2){var cobrowseRequest=initCobrowseRequest(); cobrowseRequest.action=ACTION_CURRENT_WINDOW; sendCommandController(CMD_CURRENT_WINDOW,{},cobrowseRequest,"×tamp="+lastActiveWindowTime) }else{sendCommandController(CMD_CURRENT_WINDOW,{},"action="+ACTION_CURRENT_WINDOW+"×tamp="+lastActiveWindowTime) }if(isSuppressed()){sendCommandController(CMD_SUPPRESS,{MODE:authorized.auth,URL:xmlCdata(getParentURL()),MESSAGE:Inq.getLocalizedMessage("cobrowseSuppressed")}) }restartPageUpdateTimer() }function getHTML(flagSendCW){try{lastBodySentArray=[]; if(isValidChatID()){if(isSuppressed()){if(authorized){sendCommandController(CMD_SUPPRESS,{MODE:authorized.auth,MESSAGE:Inq.getLocalizedMessage("cobrowseSuppressed")}); cobrowseSuppressedPage() }}else{if(flagSendCW){sendCommandController(CMD_CURRENT_WINDOW,{}) }sendHead(); sendBody() }}return true }catch(e){logError("Error(getHTML)",e)("getHTML"); cbcFailHandler(Inq.getLocalizedMessage("cobrowseUnexpectedFail")) }return false }function getInqFrameUrl(){return getDomain(inqFrame.location)+inqFrame.location.pathname }function clearPageUpdateTimer(){try{if(pageUpdateTimer!=null){window.clearTimeout(pageUpdateTimer) }pageUpdateTimer=null }catch(e){logError("Error(clearPageUpdateTimer)",e) }}function restartPageUpdateTimer(){clearPageUpdateTimer(); pageUpdateTimer=window.setTimeout(checkForUpdates,TIMERINTERVAL_PAGE_UPDATE) }function setAuthMode(mode){if(mode.auth){var wasNotAuthorized=!authorized; var sharedAfterStandardMode=authorized&&authorized.auth==cobrowse.ACCEPTED&&mode.auth==cobrowse.ACCEPTED+cobrowse.SHARED_CONTROL; authorized=mode; if(cobrowse.isPersistentWindow){clearPageUpdateTimer() }else{setHighlightStyle(); if(wasNotAuthorized||sharedAfterStandardMode){if(isWindowSetAsCurrentBeforeAuth){isWindowSetAsCurrentBeforeAuth=false; whenActiveWindow() }if(!cmdRequest){requestAICommand() }getHTML(); if(!sharedAfterStandardMode){try{banner.show() }catch(e){logError("Error(setAuthMode: banner.show)",e) }}restartPageUpdateTimer(); var flashPeer=getFlashPeer(); if(flashPeer!=null){if(!(cobrowse.isPersistentWindow&&cobrowse.isIE)){try{flashPeer.ciFocusCobEndBtn() }catch(errDom){}}}}}}else{authorized=null; banner.hide(); removeCobEndButton(); clearPageUpdateTimer() }return authorized }function getCallbackContext(){var context={}; context.callbackFun=loadComplete; return context }function checkAuthorized(){if(isValidChatID()){var id=generateID(PS_CBC_CHECK); var data=["CBCHECK",id,Inq.getSiteID(),getInqFrameUrl(),COOKIE_COBROWSE]; Inq.CM.postRequestToIframe(getCookiePath(),data,id,getCallbackContext()); if(COBROWSE_CONTROLLER_VERSION==2){sendCommandCheckEmbeddedResourcesV2() }else{sendCommandCheckEmbeddedResources() }}}function getItemById(id){var parts=id.split(":"); if(parts.length==1){return getPageDocument().getElementById(id) }else{if(parts[1]=="text"){return textNode(getPageDocument().getElementById(parts[0]),parseInt(parts[2])) }else{var el=getPageDocument().getElementsByTagName(parts[1])[parseInt(parts[2])]; if(parts.length<5){return el }else{if(parts[3]=="text"){return textNode(el,parseInt(parts[4])) }else{throw new Error("Element with id=["+id+"] not found") }}}}}function textNode(el,textIndex){for(var ix=0,n=0; ix4){parentResourceUrl=parentResourceUrl.slice(0,-1); parentResourceUrl=parentResourceUrl.slice(0,parentResourceUrl.lastIndexOf("/")+1) }}}}}}absoluteUrl=parentResourceUrl+resourceUrl }}return absoluteUrl }var URL_REGEXP_SIMPLE=new RegExp("url","i"); var URL_REGEXP_REPLACE=/(^.*)(url)(\()([^(]*)(\).*)($)/gi; function replaceUrlsByAbsolute(data,parentResourceUrl){if(data.match(URL_REGEXP_SIMPLE)){var line; var lines=data.split("\n"); var lix; for(lix=0; lix' }try{var docType=window.parent.document.body.parentNode.previousSibling; if(docType){if(String(docType.constructor).indexOf("DocumentType")!=-1){return constructDocType(docType.name.toLowerCase(),docType.publicId,docType.systemId) }else{if(docType.nodeValue.indexOf("DOCTYPE")==0){return"" }}}return constructDocType("html","-//W3C//DTD XHTML 1.0 Transitional//EN","http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd") }catch(e){logError("Error(getDocType): ",e) }return"" }var SPRINT_MENU_HOTFIX=".sprint-header-inner .sprint-header-meta a,.sprint-header-inner .sprint-header-meta nav ul li,.sprint-header-inner .sprint-header-tools div { float: left; }div.content {clear: both }"; function getCss(){var cssLink=""; var cssText=""; for(var i=0; i-1){cssText=cssContent.cssText+cssText }else{cssText+=cssContent.cssText }}catch(e){logError("Error(getCss/block error of unaccessible property):",e) }}cssText="\n\n"; return cssLink+cssText }function isBannerCss(styleSheet){try{return styleSheet.ownerNode.parentNode.id==DIV_ID_COBROWSE_BANNER }catch(e){return false }}function getFixedCssContent(styleSheet){var cssLink=""; var cssText=""; if(isValidMediaType(styleSheet)&&!isBannerCss(styleSheet)){if(styleSheet.href){var url=convertToAbsoluteUrl(styleSheet.href); if(URL_REGEXP_CHECK_HTTP_PROTOCOL.test(url)){if(isEmbeddedResource(url)){addEmbeddedResource(url); url=getFullEmbeddedResourceURL(url) }cssLink+="\n" }else{logToServer("StyleSheet has incorrect URL and can't be used, HREF: "+url,LOG_LEVEL.ERROR) }}else{cssText+=fixCssTextInStyleSheet(styleSheet) }}return{cssLink:cssLink,cssText:cssText} }function fixAngularRelatedCSS(str){str=str.replace(new RegExp("\\[ng:cloak\\]","g"),"[ng\\:cloak]"); str=str.replace(new RegExp("ng:form","g"),"ng\\:form"); return str }function testGetHTML(){var result=false; try{sendHead(true); sendBody(true); result=true }catch(e){logError("Error while testing getHTML()",e) }return result }function cobrowseMinimizeRestore(){var flashPeer=getFlashPeer(); if(flashPeer!=null){if(flashPeer.isMobile()&&flashPeer.getCobrowseEnableMinimizeRestore()){return true }}return false }function sendHead(isTest){try{updateScrollChanges(); var data=addScrollData(addHostedLocation({SITEID:Inq.getSiteID(),URL:xmlCdata(getParentURL()),MODE:getMode(),DT:xmlCdata(getDocType()),HTML_ATTR:getHTMLNodeAttr()})); if(cobrowseMinimizeRestore()){data.PARAM_COBROWSE_MINIMIZE_RESTORE=true }if(!isTest){splitDataPackage(isTest,{},getCss(),CMD_HEADPART,false,data) }}catch(e){logError("Error(sendHead): head sending"+(isTest?" while performance testing":""),e) }}function getHTMLNodeAttr(){var htmlNode=getPageDocument().getElementsByTagName("HTML")[0]; var attrString=""; for(var i=0; i/gi,">").replace(/0; ){data.DATA=xmlCdata(htmlRest.substr(0,DATA_PACKAGE_SIZE_LIMIT)); htmlRest=htmlRest.substr(DATA_PACKAGE_SIZE_LIMIT); data.MORE=htmlRest.length; if(data.MORE===0&&isHighlightUpdate){data.HIGHLIGHT="" }if(data.MORE===0&&dataForLastPart){data=$.extend({},data,dataForLastPart) }if(!isTest){if(commandName==CMD_HEADPART&&dataForLastPart){if(COBROWSE_CONTROLLER_VERSION==2){var cobrowseRequest=initCobrowseRequest(); cobrowseRequest.action=ACTION_HEAD; cobrowseRequest.mode=authorized.mode; sendCommandController(commandName,data,cobrowseRequest) }else{sendCommandController(commandName,data,"action="+ACTION_HEAD+"&mode="+authorized.auth) }}else{sendCommandController(commandName,data) }}}}}function findDifferenceFromEnd(oldArray,newArray){var ixOld=oldArray.length; var ixNew=newArray.length; var commonLength=0; var commonString; for(; ixNew>=0&&ixOld>=0; ixNew--,ixOld--){if(oldArray[ixOld]!=(commonString=newArray[ixNew])){break }if(commonString!=null){commonLength+=commonString.length }}return{ixNew:ixNew,ixOld:ixOld,ln:commonLength} }function findDifferenceFromStart(oldArray,newArray,limit){var commonLength=0; var commonString; var i=0; for(; i").find(selector); return true }catch(e){logError('Invalid selector in BR and it was ignored (filtered), selector: "'+selector+'"',e); return false }}}function createContent(pageRules){return function($element,unmaskedValue){var value=unmaskedValue; if(value&&value.replace){forAllMatchingRules(pageRules,$element,function(rule){value=value.replace(rule.regex,rule.mask) }) }return value } }function createDetect(pageRules){return function($element,unmaskedValue){var matches=[]; if(unmaskedValue&&unmaskedValue.replace){forAllMatchingRules(pageRules,$element,function(rule){var offset=0; var value=unmaskedValue; var from; while((from=value.search(rule.regex))>-1){var match=value.match(rule.regex)[0]; var to=from+match.length; matches.push({start:from,end:to}); offset+=to; value=value.substr(to) }}) }return matches } }function createHideNodeFilter(pageRules){return function($element){for(var i=0; i" }function wrapInputs(clazz,text){return""+text+"" }function decimalToHex(d,padding){var hex=d.toString(16); padding=typeof(padding)==="undefined"||padding===null?padding=2:padding; while(hex.length0){$(node).before(text.substring(0,start)); node.nodeValue=text.substring(start); node.previousSibling.rightHighlightSeverance=true; if(node.leftHighlightSeverance){node.previousSibling.leftHighlightSeverance=true }else{node.leftHighlightSeverance=true }}return node }catch(e){logError("Error(stripStart)",e) }}function getHighlightingNodes(e1,e2){var arrayNodes=[]; var current=e1; while(current!=e2){if(current.nodeName!="#comment"&¤t.nodeName!="IFRAME"&¤t.nodeName!="STYLE"&¤t.nodeName!="SCRIPT"&¤t.nodeName!="NOSCRIPT"){if(current.hasChildNodes()&¤t.nodeName!="SELECT"&¤t.nodeName!="INPUT"&¤t.nodeName!="TEXTAREA"&¤t.nodeName!="BUTTON"){current=current.firstChild; continue }if(current.nodeName=="#text"||$(current).is(":visible")){arrayNodes.push(current) }}if(current.nextSibling){current=current.nextSibling }else{var parent=current.parentNode; while(!parent.nextSibling&&parent!=e2){parent=parent.parentNode }current=parent==e2?parent:parent.nextSibling }}arrayNodes.push(current); return arrayNodes }function highlightText(elStart,indexStart,elEnd,indexEnd,color){if(!elStart||!elEnd||!color){return }try{var stripedElEnd=stripEnd(elEnd,indexEnd); var stripedElStart=stripStart(elStart,indexStart); if(!stripedElEnd||!stripedElEnd){logError("Error: highlight boundaries are wrong: stripedElEnd="+stripedElEnd+" stripedElStart="+stripedElStart) }else{var elements=getHighlightingNodes(stripedElStart,stripedElEnd); $(elements).each(function(){(highlightElement.bind(this))(color) }) }}catch(e){logError("Error(highlightText)",e) }}function getPageMarker(){return Inq.LDM.page?Inq.LDM.page.mID:null }function uploadResources(urls){for(var j=0; j0),htmlFilter.contentTextFilter); htmlFilter.hideNodeFilter=createHideNodeFilter(rules.maskingHiddenRules); htmlFilter.isHiddenNode=createIsHiddenNode((rules.maskingHiddenRules.length>0),htmlFilter.hideNodeFilter); htmlFilter.blockClickNodeFilter=createBlockClickNodeFilter(rules.maskingBlockClickRules); htmlFilter.isBlockClickNode=createIsBlockClickNode((rules.maskingBlockClickRules.length>0),htmlFilter.blockClickNodeFilter) }catch(e){logError("Error(initialize.htmlFilter)",e) }}function callBackProxyError(error){if(isValidChatID()){logError("Error(callBackProxyError): "+error); try{if(COBROWSE_CONTROLLER_VERSION==2){postQueueItemV2(true) }else{postQueueItemV1(true) }}catch(e){logError("Error(callBackProxyError)",e); waitingAnswer=false }}}function generateID(name){return name+Math.floor(Math.random()*1000011) }return{getCobrowseBannerText:function(){return this.bannerHtml },isCobrowseEngaged:function(){return !!authorized },isSharedControl:function(){return authorized&&(authorized.auth&cobrowse.SHARED_CONTROL) },stopByEtlEvent:function(windowId){if(!Inq.CHM.isMultiChatSupported()||(Inq.CHM.isMultiChatSupported()&&windowId==cobrowse.windowId)||(Inq.CHM.isMultiChatSupported()&&Inq.CHM.isPersistentChat())){terminateCobrowse(ciProxy.ciAgentEndsCob); var flashPeer=getFlashPeer(); if(flashPeer!=null){flashPeer.ciSetFocusOnChatInputField() }}},stop:function(){if(!authorized){return }terminateCobrowse(ciProxy.ciSendCobrowseEnded); var flashPeer=getFlashPeer(); if(flashPeer!=null){flashPeer.ciSetFocusOnChatInputField() }},stopQuiet:function(){terminateCobrowse() },resetCSQ:function(){client_csq=0 },endCobrowse:function(){terminateCobrowse(ciProxy.ciAgentEndsCob) },reset:reset,resetHtmlFilter:initializeHtmlFilter,termsAndConditions:banner.termsAndConditions,testGetHTML:testGetHTML,accept:function(flagStartBenchmarkTest){startCobrowse(flagStartBenchmarkTest,cobrowse.ACCEPTED,"normal") },acceptShare:function(flagStartBenchmarkTest){startCobrowse(flagStartBenchmarkTest,cobrowse.ACCEPTED|cobrowse.SHARED_CONTROL,"shared control") },callBackAuthorized:function(json,boxID){setAuthMode(getAuthModeFromJson(json,boxID)) },callBackProxyError:callBackProxyError,requestAICommand:function(){if(authorized){requestAICommand() }else{cmdRequest=null }},ackReceived:function(jsonString){try{if(COBROWSE_CONTROLLER_VERSION==2){postQueueItemV2(true) }else{postQueueItemV1(true) }}catch(e){logError("Error(ackReceived)",e)(jsonString); waitingAnswer=false }},executeJson:function(command,csq,changeOrder){if(command){try{if(changeOrder||csq>client_csq){client_csq=csq }switch(command.command){case"sendEmbeddedResources":this.sendEmbeddedResources(command.urls); break; case"refresh":this.getHTML(command.sendCW); break; case"doMinimizeOrRestoreChat":this.doMinimizeOrRestoreChat(); break; case"doElementClick":this.doElementClick(command.tagId); break; case"setFocusInputField":this.setFocusInputField(command.tagId); break; case"highlightText":this.highlightText(command.startEl,command.startOffset,command.endEl,command.endOffset,command.color); break; case"highlightInputField":this.highlightInputField(command.tagId,command.color); break; case"unhighlight":this.unhighlight(); break; case"scrollTo":this.scrollTo(command.x,command.y); break; case"endCobrowse":if(command.agentType==DATA_AGENT_TYPE_HTML){this.endCobrowse() }break; case CMD_SERVER_ACTIVE_WINDOW_UPDATE:commandActiveWindowUpdate(command); break; default:logError("Error(executeJson): unknown command ["+command.command+"]") }}catch(e){logError("Error(executeJson)",e) }}requestAICommand() },getHTML:function(flagSendCW){getHTML(flagSendCW); if(COBROWSE_CONTROLLER_VERSION==2){sendCommandCheckEmbeddedResourcesV2(true) }else{sendCommandCheckEmbeddedResources(true) }},highlightInputField:function(inputId,color){var element=getItemById(inputId); if(!element){return }if(element.nodeName=="A"){var lastInnerChild=element.lastChild; while(lastInnerChild.hasChildNodes()){lastInnerChild=lastInnerChild.lastChild }var endOffset; if(lastInnerChild.nodeValue==null){endOffset=0 }else{endOffset=lastInnerChild.length }highlightText(element,0,lastInnerChild,endOffset,color) }else{$(element).each(function(){(highlightElement.bind(this))(color) }) }modified=true; sendUpdate(true); restartPageUpdateTimer() },unhighlight:function(){try{$("."+CSS_CLASS_HIGHLIGHT_TEXT,getPageDocument()).each(function(index){$(this).contents().each(function(){unwrapTextSafely(this) }) }); for(var i=0; i