var config = {"loginType":"3","loginID":"2","loginName":" ","loginEmail":"","StoreDesc":"Good Friend Electric","clientDB":"goodfriendelectric","clientID":"323","loginAccess":false,"isSuperuser":"false","groupTitle":"Room","accountType":"12","quoteRequestsActivated":"0","quoteReqPricingActivated":"0","isPunchoutUser":0,"signin":"","cogsVisible":"","viiVisible":"1","versionnumber":"release_5.2.81","page":"HeadContent","currentPage":"CatalogBrowse"}; function getXOParent() { var xoParent; try { xoParent = (window.location != window.parent.location && window.frameElement && window.frameElement.id === 'bodyFrame') ? window.parent.document : window.document; } catch(err) { xoParent = window.document; } return xoParent; } function headerActions(inFrame,title) { if (title == null) { title = document.title; } var url = document.location.href; if ( config.signin && !url.match(/login.php/) && !url.match(/index.php/) && !url.match(/Page-QuotedItems/) ) { if ( !url.match(/(\?|\&)ut=/) ) { url += url.match(/\?/) ? '&ut=' : '?ut='; url += config.signin; document.location.replace(url); } } if (inFrame) //if we found parent frame { parent.document.title = HTMLDecode(title); } function HTMLDecode(str) { var textArea = document.createElement('textarea'); textArea.innerHTML = str; return textArea.value; } } function checkIfInsideFrame() { var inFrame = 0; try { inFrame = (window.location != window.parent.location && window.frameElement && window.frameElement.id === 'bodyFrame') ? 1 : 0; } catch(err) { inFrame = 0; } return inFrame; } function actionIfInsideFrame(inFrame,where) { var xoParent = window.parent.document; var url = document.location.href; if (!url.match(/showFrame=0/)) { var title = (document.title).split('|'); var page = window.location.href; if ( inFrame ) { parent.history.replaceState(null,null,window.location.href); $xo('#pageTitle',parent.document).text(title[0]); } else { xoParent = window.document; if (where == 'HeadContent') { top.location.replace('/Page-AddHeaderFooter?FrameTitle='+ encodeURIComponent(title[0].trim()) +'&FrameURL='+ encodeURIComponent(page.trim())); } else { window.location.replace('/Page-AddHeaderFooter?FrameTitle='+ encodeURIComponent(title[0].trim()) +'&FrameURL='+ encodeURIComponent(page.trim())); } } } return xoParent; } function verifyClickJack() { var removeClickJack = false; if (self === top) //if we have no frame //TODO: add exceptions in for ariba here. { removeClickJack = true; } return removeClickJack; } function clickJackAction(remove) { if ($xo('#antiClickjack').length > 0) { if (remove) { var antiClickjack = document.getElementById("antiClickjack"); antiClickjack.parentNode.removeChild(antiClickjack); } else { top.location = self.location; } } } function shoppingCartAnalytics(UACode,id,affiliation,revenue,shipping,tax) { //Case#9597 Place Shopping Cart Tracking Code (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create',UACode, 'auto'); ga('send', 'pageview'); // Enable ecommerce tracking functions. ga('require', 'ecommerce'); // Create a transaction. ga('ecommerce:addTransaction', { 'id': id, // Transaction ID. String. *|* REQUIRED *|* 'affiliation': affiliation, // Affiliation or store name. String. 'revenue': revenue, // Grand Total. String. 'shipping': shipping, // Shipping. String. 'tax': tax // Tax. String. }); } function addItem_analytics(id,vendor,name,sku,category,price,quantity) { ga('ecommerce:addItem', { 'id': id, // Same as above addTransaction section ID 'vendor': vendor, // Vendor Name 'name': name, // Product name. String. 'sku': sku, // Product SKU. String. 'category': category, // Product top level category. String. 'price': price, // Product price. String. 'quantity': quantity, // Product quantity. String. 'currency': 'USD' // Currency code. String. }); } function addGoogleAnalytics(UACode,Domain) { if(UACode != ""){ var _gaq = _gaq || []; _gaq.push( ['_setAccount',UACode], ['_setDomainName',Domain], ['_setAllowLinker',true], ['_trackPageview'] ); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); } } function ieAlerts() { var ie9 = /MSIE 9/i.test(navigator.userAgent) ? 1 : 0; var ie10 = /MSIE 10/i.test(navigator.userAgent) ? 1 : 0; var ie11 = /rv:11.0/i.test(navigator.userAgent) ? 1 : 0; var isIE = (ie9 || ie10 || ie11) ? 1 : 0; var win7 = /(Windows 7|Windows NT 6.1)/i.test(navigator.userAgent) ? 1 : 0; var msg = "Windows 7 Internet Explorer 11 requires that you add this site to your list of trusted sites to ensure full site functionality."; msg += " Click here for instructions."; // $ variable used because of headContent.html file and Ariba. Was not working correct when using $xo if (win7 && isIE && loginType == 3 && !readCookie('hasSeenIEMessage') && self != top) { $xo('#headerErrorMsg .errorMsgTitle').text('Error:'); $xo('#headerErrorMsg .errorMsgDetails').html(msg); $xo('#headerErrorMsg').removeClass('hiddenBox'); } return 1; } function cogVISetup() { if (config.cogsVisible == 1) $xo('.cogs').css('visibility', 'visible'); else if (config.cogsVisible == 0) $xo('.cogs').css('visibility', 'hidden'); if (config.viiVisible == 1) $xo('.vii').css('visibility', 'visible'); else if (config.viiVisible == 0) $xo('.vii').css('visibility', 'hidden'); $xo('.cogs').toggle().toggle(); $xo('.vii').toggle().toggle(); } var xoParent = window.document; var inFrame = checkIfInsideFrame(); var removeClickJack = verifyClickJack(); var versionnumber = config.versionnumber; var loginType = config.loginType; var loginID = config.loginID; var loginName = config.loginName; var loginEmail = config.loginEmail; var StoreDesc = config.StoreDesc; var clientDB = config.clientDB; var clientID = config.clientID; var loginAccess = config.loginAccess; var isSuperuser = config.isSuperuser; var groupTitle = config.groupTitle; var accountType = config.accountType; var quoteRequestsActivated = config.quoteRequestsActivated; var quoteReqPricingActivated = config.quoteReqPricingActivated; var adminLoginPermission = 'false'; var accountLoginPermission = 'false'; var customerLoginPermission = 'false'; var accountContactLogin = 'false'; var accountEdit = 'false'; var customerContactLogin = 'false'; if (config.page !== 'AddHeaderFooter') { // If logged in as Admin/Salesrep/Superuser if (config.loginType == 1 && config.currentPage != "Logout") { var xoParent = actionIfInsideFrame(inFrame,'HeadContent'); if (inFrame && window.parent === top){ removeClickJack = true; } //if we found parent frame & if we have no additional frame //TODO: add exceptions in for ariba here. } headerActions(inFrame); cogVISetup(); if ( top != self && typeof ieAlerts == 'function' ){ ieAlerts(); } //Make sure users are using a current version of Internet Explorer } if (config.page == 'AddHeaderFooter' || config.page == 'HeadContent') { // Anti Click Jack if (config.isPunchoutUser == 1) { removeClickJack = true; } clickJackAction(removeClickJack); }