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 signin = "";
var url = document.location.href;
if ( signin && !url.match(/login.php/) && !url.match(/index.php/) && !url.match(/Page-QuotedItems/) ) {
if ( !url.match(/(\?|\&)ut=/) ) {
url += url.match(/\?/) ? '&ut=' : '?ut=';
url += 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/))
{
if ( inFrame )
{
parent.history.replaceState(null,null,window.location.href);
$xo('#pageTitle',parent.document).html(title[0]);
}
else
{
xoParent = window.document;
if (where == 'HeadContent')
{
top.location.replace('/Page-AddHeaderFooter?FrameTitle='+ decodeURIComponent(encodeURIComponent(title[0])).trim() +'&FrameURL='+ encodeURIComponent(page).trim());
}
else
{
window.location.replace('/Page-AddHeaderFooter?FrameTitle='+ decodeURIComponent(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()
{
// Try to force the cogs and vii style^M
var cogsVisible = "";
var viiVisible = "";
if(cogsVisible == 1)
{
$xo('.cogs').css('visibility', 'visible');
}
else if(cogsVisible == 0)
{
$xo('.cogs').css('visibility', 'hidden');
}
if(viiVisible == 1)
{
$xo('.vii').css('visibility', 'visible');
}
else if(viiVisible == 0)
{
$xo('.vii').css('visibility', 'hidden');
}
$xo('.cogs').toggle().toggle();
$xo('.vii').toggle().toggle();
}
/* GLOBAL VARIABLES */
var xoParent = window.document;
var inFrame = checkIfInsideFrame();
var removeClickJack = verifyClickJack();
var versionnumber = "release_5.2.47c";
var loginType = "";
var loginID = "";
var loginName = " ";
var loginEmail = "";
var StoreDesc = "";
var clientDB = "xolights";
var clientID = "";
var loginAccess = "";
var isSuperuser = "false";
var groupTitle = "";
var accountType = ""; //
var quoteRequestsActivated = "0";
var quoteReqPricingActivated = "0";
var adminLoginPermission = 'false';
var accountLoginPermission = 'false';
var customerLoginPermission = 'false';
var accountContactLogin = 'false';
var accountEdit = 'false';
var customerContactLogin = 'false';
if ("HeadContent" != 'AddHeaderFooter')
{
// If logged in as Admin/Salesrep/Superuser
var currentPage = "";
if (loginType == 1 && currentPage != "Logout")
{
xoParent = getXOParent();
var page = window.location.href;
var title = (document.title).split('|');
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 ("HeadContent" == 'AddHeaderFooter' || "HeadContent" == 'HeadContent')
{
// Anti Click Jack
var isPunchoutUser = "0";
if (isPunchoutUser == 1)
{
removeClickJack = true;
}
clickJackAction(removeClickJack);
}