try { /***************** * Setup Module ****************/ if(window.QSI === undefined) window.QSI = {}; if (!QSI.dbg) QSI.dbg = { c:function(){} }; if (QSI.reg === undefined) QSI.reg = {}; if (QSI.global === undefined) QSI.global = { currentZIndex:2000000000, imagePath:"https://siteintercept.qualtrics.com/WRSiteInterceptEngine/../WRQualtricsShared/Graphics", graphicPath:"https://siteintercept.qualtrics.com/WRSiteInterceptEngine/../WRQualtricsSiteIntercept/Graphic.php?IM=" }; if (QSI.ed === undefined) QSI.ed = {}; QSI.ed['SI_8vQ35kk5K5QPUsA'] = null; //This is used by IE to get the stored user data off the storage element QSI.id = 'SI_8vQ35kk5K5QPUsA'; QSI.Browser = { name:'Firefox', version:4 }; /**************** * Global Includes ****************/ if(!QSI.util) QSI.util = { $:function(n) { if (typeof n == 'string') n = document.getElementById(n); return n; }, setStyle:function(el,s) { for (var sid in s) { try { el.style[sid] = s[sid]; } catch(e){} } }, build:function(type,att,inner) { var el = document.createElement(type); if (att) { for (var id in att) { switch (id) { case 'style': this.setStyle(el,att[id]); break; case 'className': el.className = att[id]; break; case 'id': el.id = att[id]; break; default: el.setAttribute(id,att[id]); } } } if (inner) { if (QSI.util.isString(inner)) { if (type == 'style' && el.styleSheet) { el.styleSheet.cssText = inner; } else { el.appendChild(document.createTextNode(String(inner))); } } else if (QSI.util.isArray(inner)) { for (var i=0,ilen=inner.length;i 0) str = str.substr(0,index); return str; }, getDimensions:function(el) { var inDom = true; if (!el.parentNode || !el.parentNode.tagName) { document.body.appendChild(el); inDom = false; } var display = el.style.display || this.getComputedStyle(el).display; if (display != 'none' && display != null) // Safari bug return {width: el.offsetWidth, height: el.offsetHeight}; var els = el.style; var originalVisibility = els.visibility; var originalPosition = els.position; var originalDisplay = els.display; els.visibility = 'hidden'; els.position = 'absolute'; els.display = 'block'; var originalWidth = el.clientWidth; var originalHeight = el.clientHeight; els.display = originalDisplay; els.position = originalPosition; els.visibility = originalVisibility; if (!inDom) { el.parentNode.removeChild(el); } return {width: originalWidth, height: originalHeight}; }, cumulativeOffset: function(el,incb) { var t=0, l=0, bt=0, bl=0, ctb=0,clb=0; try{ do { if (incb) { if (!this.isIE8()) { var st=this.getComputedStyle(el); bt = st.borderLeftStyle=='none'?0:this.parseBorderSize(st.borderLeftWidth); bl = st.borderLeftStyle=='none'?0:this.parseBorderSize(st.borderTopWidth); } } t += (el.offsetTop || 0)+bt; l += (el.offsetLeft || 0)+bl; ctb += bt; clb += bl; el = el.offsetParent; } while (el); } catch(e){} return {left:l, top:t,bleft:clb,btop:ctb}; }, scrollTop:function() { if (document.body.scrollTop) return document.body.scrollTop; return document.documentElement.scrollTop; }, parseBorderSize:function(s) { if (s.indexOf('px') > 0) { s = s.substr(0,s.indexOf('px')); } else if (s.indexOf('em') > 0) { s = (s.substr(0,s.indexOf('em')))*16; } else { switch(s) { case 'thin': s=1; break; case 'medium': s=3; break; case 'thick': s=5; break default: s=0; } if (this.isIE()) s+=1; } return parseFloat(s); }, getComputedStyle:function(el) { return el.currentStyle || window.getComputedStyle(el,null); }, getPageSize:function(win) { win = win || window; var windowWidth, windowHeight; if (win.self.innerHeight) { // all except Explorer windowWidth = win.self.innerWidth; windowHeight = win.self.innerHeight; } else if (win.document.documentElement && win.document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = win.document.documentElement.clientWidth; windowHeight = win.document.documentElement.clientHeight; } else if (win.document.body) { // other Explorers windowWidth = win.document.body.clientWidth; windowHeight = win.document.body.clientHeight; } return {width:windowWidth, height:windowHeight}; }, getScrollOffsets:function() { var scrOfX = 0, scrOfY = 0; if( typeof( window.pageYOffset ) == 'number' ) { //Netscape compliant scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { //DOM compliant scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { //IE6 standards compliant mode scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } return [ scrOfX, scrOfY ]; }, pageMode:function(){ return ( document.compatMode == 'CSS1Compat' ) ? 'Standards' : 'Quirks'; }, isFixed:function() { return !(QSI.Browser.name == 'Internet Explorer' && (this.pageMode() != 'Standards' || QSI.util.isIE6())); }, fixPNG:function(img,width,height) { var temp = new Image(); img.style.backgroundColor='transparent'; var node = QSI.util.build('span',{ id:img.id, className:img.className, title:img.title, //cssText:img.cssText, fontSize:0, onclick:img.onclick, style:{ filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src + "', sizingMethod='scale')", width:img.style.width || img.width, height:img.style.height || img.height, position:img.style.position, top:img.style.top, left:img.style.left, cursor:img.style.cursor } }, ''); temp.onload = function() { node.style.display = 'inline-block'; node.style.setAttribute('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + img.src + "', sizingMethod='scale')"); node.style.width = img.style.width || temp.width; node.style.height = img.style.height || temp.height; }; temp.src = img.src; //document.body.appendChild(temp); return node; }, openTarget:function(url, options, embeddedData) { if (!url) return; if (embeddedData) { url += ("&Q_ED=" + encodeURIComponent(QSI.EmbeddedData.generateDynamicEmbeddedData(embeddedData))); } if (options.targetNewWindow) { try { var size = QSI.util.getPageSize(); var width = options.targetFullScreen?screen.width||size.width:options.targetWidth; var height = options.targetFullScreen?screen.height||size.height:options.targetHeight; var win = window.open(url,'targetwindow','location=1,status=1,scrollbars=1,resizable=yes,width='+width+',height='+height); win.moveTo(0,0); } catch(e){QSI.dbg.c(e);} } else if (options.targetEmbedded) { new QSI.EmbeddedTarget(url, options); } else if (options.targetPopUnder) { new QSI.PopUnderTarget(url, options); } else { window.location = url; } }, impress:function(url) { if (url) { var i = QSI.util.build('img',{src:url+'&r=' +(new Date()).getTime(),style:{display:'none'}}); document.body.appendChild(i); } }, getQueryParam:function(url,key) { key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+key+"=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(url); if( results == null ) return ""; else return results[1]; }, decodeURL:function(str) { return unescape(str.replace(/\+/g, " ")); }, capFirst:function(str) { return str.charAt(0).toUpperCase() + str.slice(1); }, observe:function(el,e,f) { if (el.addEventListener) { el.addEventListener(e, f, false); } else if (el.attachEvent) { el.attachEvent( "on" + e, f ); } else if (el['on' + this.capFirst(e)]) { el['on' + this.capFirst(e)] = f; } }, stopObserving:function(el,e,f) { if (el.removeEventListener) { el.removeEventListener(e, f, false); } else if (el.detachEvent) { el.detachEvent( "on" + e, f ); } else if (el['on' + this.capFirst(e)]) { delete(el['on' + this.capFirst(e)]); } }, hasReachedScrollPosition:function(percentage) { var scrollHeight = this.getScrollOffsets()[1]; var pageHeight = this.getPageSize().height; var bodyHeight = document.body.scrollHeight; var eventHeight = bodyHeight * (percentage / 100); if(scrollHeight + pageHeight >= eventHeight) return true; return false; }, remove:function(el) { if (el) el.parentNode.removeChild(el); }, addContainer:function(id) { if (!this.$(id)) { var n = this.build('div',{id:id,style:{display:'none'}}); document.body.appendChild(n); } }, positionFixed:function(el, posFromTop, posFromBottom) { el.style.position = "absolute"; var lastPosition = 0; var index = 0; var pageHeight = this.getPageSize().height; var bodyHeight = document.body.scrollHeight; var scrollTop = QSI.util.scrollTop(); var timer; if(scrollTop > 0) { if(posFromBottom == 'auto') { el.style.top = (scrollTop + parseInt(posFromTop)) + "px"; el.style.bottom = posFromBottom; } else if (posFromTop == 'auto') { el.style.bottom = ((scrollTop + pageHeight) - parseInt(posFromTop)) + 'px'; el.style.top = posFromTop; } } if(typeof(posFromTop) == 'string' && posFromTop.indexOf('px') > -1) { posFromTop = parseInt(posFromTop); } if(typeof(posFromBottom) == 'string' && posFromBottom.indexOf('px') > -1) { posFromBottom = parseInt(posFromBottom); } var scrollToPosition = function(){ clearTimeout(timer); timer = setTimeout(function(){ var scrollTop = QSI.util.scrollTop(); if(scrollTop < 0 || (scrollTop + pageHeight) > bodyHeight) return; var targetPos = scrollTop + posFromTop; var diff = targetPos - lastPosition; var direction = (diff >= 0)?20:-20; if(Math.abs(diff) < 10) direction = diff; var interval; lastPosition = targetPos; if(posFromBottom == 'auto') { interval = setInterval(function(){ var newTop = parseInt(el.style.top) + direction; el.style.top = newTop + "px"; el.style.bottom = posFromBottom; if(direction > 0) { if(newTop >= targetPos) { clearInterval(interval); QSI.util.observe(window, 'scroll', scrollToPosition); } } else { if(newTop <= targetPos) { clearInterval(interval); QSI.util.observe(window, 'scroll', scrollToPosition); } } QSI.util.observe(window, 'scroll', scrollToPosition); }, 15); } else if (posFromTop == 'auto') { interval = setInterval(function(){ var newBottom = parseInt(el.style.bottom) + direction; el.style.bottom = ((scrollTop + pageHeight) - posFromBottom) + 'px'; el.style.top = posFromTop; el.style.bottom = newBottom + "px"; if(direction > 0) { if(newBottom >= targetPos) { clearInterval(interval); QSI.util.observe(window, 'scroll', scrollToPosition); } } else { if(newBottom <= targetPos) { clearInterval(interval); QSI.util.observe(window, 'scroll', scrollToPosition); } } QSI.util.observe(window, 'scroll', scrollToPosition); }, 15); } }, 60); }; QSI.util.observe(window, 'scroll', scrollToPosition); }, watchPage:function() { var that = this; this.Page.onResize(); this.Page.onScroll(); this.observe(window,'resize',function(){that.Page.onResize()}); this.observe(window,'scroll',function(){that.Page.onScroll()}); }, Page:{ viewport:{}, page:{}, scroll:{}, onResize:function() { this.updateViewport(); this.updatePage(); }, onScroll:function() { this.updateScroll(); }, updatePage:function() { var vpw, vph; if (window.innerHeight && window.scrollMaxY) { vpw = document.body.scrollWidth; vph = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight) { vpw = document.body.scrollWidth; vph = document.body.scrollHeight; } else { vpw = document.body.offsetWidth; vph = document.body.offsetHeight; } this.page = { width: vpw, height: vph }; }, updateScroll:function() { var x, y; if (self.pageYOffset) { x = self.pageXOffset; y = self.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop) { x = document.documentElement.scrollLeft; y = document.documentElement.scrollTop; } else if (document.body) { x = document.body.scrollLeft; y = document.body.scrollTop; }; this.scroll = { x: x, y: y }; }, updateViewport:function() { var ww, wh; if (self.innerHeight) { ww = self.innerWidth; wh = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { ww = document.documentElement.clientWidth; wh = document.documentElement.clientHeight; } else if (document.body) { ww = document.body.clientWidth; wh = document.body.clientHeight; } this.viewport = { width: ww, height: wh }; }, getScrollPct:function(bottom) { return { x:Math.round(((this.scroll.x+(bottom?this.viewport.width:0))/this.page.width) * 100), y:Math.round(((this.scroll.y+(bottom?this.viewport.height:0))/this.page.height) * 100) }; } } };/***************** * Cookie Module ****************/ QSI.cookie = { set:function(n,v,d,dm) { var e=""; if(d){ var f=new Date(); f.setTime(f.getTime()+(d*86400000)); var e="; expires="+f.toGMTString(); } var dmn = ''; if (dm && (dm != '')) dmn = "domain="+dm; document.cookie=n+"="+v+e+"; path=/; "+dmn; }, get:function(n) { var e=n+"="; var ca=document.cookie.split(';'); for(var i=0,ilen=ca.length;i limit) { var histArray = val.split('|'); histArray.splice(0,1); val = histArray.join('|'); } return val; }, get:function() { //var hist = window.name; var hist = QSI.profile.get('History','History'); hist = this.limitSize(hist); return hist; }, logCurrentURL:function() { var url = window.location.href; var currentTime = new Date()*1; this.logSite(url,currentTime); }, logSearch:function() { var referrer = document.referrer; if(referrer.search(/(google.com)|(bing.com)|(yahoo.com)/) >= 0) { var search = '' if (referrer.search(/(google.com)|(bing.com)/) >= 0) { var searchRegex = /q=(.*?)\&/; var result = referrer.match(searchRegex); if (result.length && result[1]) search = result[1]; } else if (referrer.search(/yahoo.com/) >= 0) { var searchRegex = /p=(.*?)\&/; var result = referrer.match(searchRegex); if (result.length && result[1]) search = result[1]; } search = unescape(search); QSI.profile.set('History', 'SearchTerm', search); } }, logReferrer:function() { var referrer = document.referrer; if(referrer != "") { var a = QSI.util.build('a',{href:referrer}); if(a.hostname != document.location.host) QSI.profile.set("History", "SiteReferrer", referrer); QSI.profile.set("History", "PageReferrer", referrer); } }, logActionSet:function(asid) { var key = asid; var currentTime = new Date()*1; QSI.profile.set('ActionSetHistory', key, currentTime); QSI.profile.set('ActionSetHistory', key, currentTime,1); }, logSurvey:function(sid,ssid) { QSI.profile.set('QualtricsSurveyHistory', sid, ssid, 1); }, getSiteReferrer:function() { return QSI.profile.get("History",'SiteReferrer'); }, getPageReferrer:function() { return QSI.profile.get('History','PageReferrer'); }, getSearch:function() { var search = QSI.profile.get('History', 'SearchTerm'); if (!search) search = ''; return search; }, getTimeOnSite:function() { var f = this.getFocusTime(); var b = this.getBlurTime(); return f+b+'|'+f ; }, getFocusTime:function() { var time = QSI.profile.get('History','FocusTime'); if (!time) time = 0; return time; }, getBlurTime:function() { var time = QSI.profile.get('History','BlurTime'); if (!time) time = 0; return time; }, getActionSetHistory:function(asid,permanent) { var ts = QSI.profile.get('ActionSetHistory', asid,permanent); if (!ts) ts = 0; return ts; }, getPageCount:function() { var hist = QSI.profile.get("History", "History"); var pageCount = 0; var pages = []; var histArray = hist.split("|"); for(var i = 0, ilen = histArray.length; i < ilen; i++) { pages.push(histArray[i].split("~")[0]); } var uniquePages = {}; for(var i = 0, ilen = pages.length; i < ilen; i++) { if(!uniquePages[pages[i]]) { pageCount++; uniquePages[pages[i]] = true; } } return {unique:pageCount, total: pages.length}; } }; /***************** * Embedded Data Module ****************/ if (!QSI.EmbeddedData) QSI.EmbeddedData = { getHTMLFromDOM:function(id) { var el = QSI.util.$(id); var val = ''; if (el) { switch(el.tagName) { //this may need to be updated case 'TEXTAREA': case 'INPUT': val = el.value; break; default: val = el.innerHTML; break; } } return val; }, getCookieVal:function(name) { var val = ''; var cookie = QSI.cookie.get(name); if (cookie) val = cookie; return val; }, getURLParameter:function(name) { return QSI.util.getQueryParam(window.location.href,name); }, getURLRegexMatch:function(regex) { var regexmatch = /^\/(.*)\/([gim]*)/; regex.match(regexmatch); var val = ''; if (RegExp.$1) { //assume that the slashes are used as delimeters and possible flag on the end window.location.href.match(new RegExp(RegExp.$1,RegExp.$2)); } else { window.location.href.match(new RegExp(regex)); } if (RegExp.$1) return RegExp.$1; else return ''; }, getJavaScriptValue:function(varName) { var qsi_val = ''; try { qsi_val = eval(varName); } catch(e){QSI.dbg.c(e);} return qsi_val; }, getHistory:function() { return QSI.history.get(); }, getTimeOnSite:function() { return QSI.history.getTimeOnSite(); }, getCurrentPage:function() { return window.location; }, getReferer:function() { return QSI.history.getPageReferrer(); }, getSiteReferer:function() { return QSI.history.getSiteReferrer(); }, getSearchTerm:function() { return QSI.history.getSearch(); }, getPageCount:function() { var count = QSI.history.getPageCount(); return count.unique; }, getPercentagePageViewed:function() { var count = QSI.history.getPageCount(); return count.unique; }, generateDynamicEmbeddedData:function(ed) { var val = ''; if(typeof ed == "string") ed = ed.split(""); for (var i=0,ilen=ed.length;i