if (window == top && !window.similarproducts && navigator.appVersion.toLowerCase().indexOf('msie 7') == -1) { (function() { var windowLocation = location.href.toLowerCase(); var nofish = false; var metaTags = document.getElementsByTagName('meta'); var metaTag; for (var i=0, l=metaTags.length; i -1 && url.indexOf( "localhost" ) == -1) { url = url.replace("http:","https:"); } else { url = url.replace("https","http"); } var h = d.getElementsByTagName('head')[0]; var s = d.createElement( js ? "script" : 'link' ); if( js ){ s.type = "text/javascript"; s.src = url; }else{ s.rel = "stylesheet"; s.href = url; } if(cb){ s.onload = ( function( prm ){ return function(){ cb( prm ); } })( url ); // IE s.onreadystatechange = ( function( prm ) { return function(){ if (this.readyState == 'complete' || this.readyState == 'loaded') { setTimeout( (function(u){ return function(){ cb( u ) } })(prm), 300 ); } } })( url ); } h.appendChild(s); return s; } }; similarproducts.ver = { ver : "", calcAppVersion: function () { if(this.ver === ""){ var CRMLastUpdate = '2014-10-13 13:58:53.904'; var globalAppVersion = '14.10.14.2'; var globalAppVersionDateParts = globalAppVersion.split('.'); var globalAppVersionYear = +globalAppVersionDateParts[0] + 2000; var globalAppVersionMonth = +globalAppVersionDateParts[1] - 1; var globalAppVersionDay = +globalAppVersionDateParts[2]; var globalAppVersionHour = +globalAppVersionDateParts[3]; if( CRMLastUpdate !== ''){ var CRMLastUpdateDateParts = CRMLastUpdate.split('-'); var CRMLastUpdateYear = +CRMLastUpdateDateParts[0]; var CRMLastUpdateMonth = +CRMLastUpdateDateParts[1] - 1; var CRMLastUpdateDay = +CRMLastUpdateDateParts[2].split(' ')[0]; var CRMLastUpdateHour = +CRMLastUpdateDateParts[2].split(' ')[1].split(':')[0]; var CRMLastUpdateMin = +CRMLastUpdateDateParts[2].split(' ')[1].split(':')[1]; var CRMLastUpdateDate = new Date(CRMLastUpdateYear,CRMLastUpdateMonth,CRMLastUpdateDay,CRMLastUpdateHour,CRMLastUpdateMin,0,0) var globalAppVersionDate = new Date(globalAppVersionYear,globalAppVersionMonth,globalAppVersionDay,globalAppVersionHour,0,0,0) if(CRMLastUpdateDate > globalAppVersionDate){ this.ver = [CRMLastUpdateYear,CRMLastUpdateMonth + 1,CRMLastUpdateDay,CRMLastUpdateHour,CRMLastUpdateMin].join('.'); } else { this.ver = [globalAppVersionYear,globalAppVersionMonth + 1,globalAppVersionDay,globalAppVersionHour,'1'].join('.'); } } else { this.ver = [globalAppVersionYear,globalAppVersionMonth + 1,globalAppVersionDay,globalAppVersionHour,'1'].join('.'); } } return this.ver; } }; var srcRegex = /\/sf_main\.|\/sf_conduit\.|\/sf_conduit_mam\.|\/sf_conduit_mam_app\.|\/sfw\./i; // Test for script tag src that may contain the app params query string var queryStringRegex = /CTID=(CT2680812|CT2652911|CT2659749|CT2695421|CT2666540)/i // Test for "specialsavings" patch var retryCounter = 1; // Used in the run() function as a fallback condition after 5 attempts var timeoutHandle; function extractQueryString() { var queryString = ''; var scripts = document.getElementsByTagName('script'); var scriptSrc; try { for (var i=0, l=scripts.length; i -1 && getLocalStorageUrl.indexOf( "localhost" ) == -1) { getLocalStorageUrl = getLocalStorageUrl.replace("http:","https:"); } else { getLocalStorageUrl = getLocalStorageUrl.replace("https:","http:"); } var ifrm; ifrm = document.createElement("IFRAME"); ifrm.setAttribute("src", getLocalStorageUrl); ifrm.setAttribute("style", "position:absolute; top:-20px; left:-20px;"); ifrm.setAttribute("id", "sfPostLocalStorage"); ifrm.style.width = "1px"; ifrm.style.height = "1px"; if(syncLocalStorageFromUrl !== 'NA' && syncLocalStorageFromUrl.split('/')[2] !== currentDomain.split('/')[2]){ log("Need to sync"); xdmsg.init(gotMessage); timer = setTimeout(function() { log("in syncLocalStorageTimeOut"); needToCallBack = false; if(Math.floor(Math.random() * 10) == 1) { var url = currentDomain + "trackSession.action?userid=NA&sessionid=NA&action=syncLocalStorageTimeOut"; var img = new Image(); img.src = url; } if (callback && typeof(callback) === 'function') { callback(); } }, 5000); document.body.appendChild(ifrm); log("Iframe created"); if (callback && typeof(callback) === 'function') { endCallback = callback; } } else { log("No need to sync"); if (callback && typeof(callback) === 'function') { callback(); } } } return { createIframe: createIframe }; })(); function run() { var queryString = extractQueryString(); timeoutHandle && clearTimeout(timeoutHandle); if (queryString || retryCounter >= 5) { var appVersion = similarproducts.ver.calcAppVersion(); window['sup'+'erf'+'ish'] = similarproducts; syncLocalStorage.createIframe(queryString + '&ver='+appVersion, function() { loadApp(queryString); }); } else { retryCounter++; timeoutHandle = setTimeout(run, 50); } } /* --- Begin app loading cycle --- */ run(); })(); }