var CMGlobal = function(siteType, brandType, category, countryCode) { var self = this; self.GetCookie = function(name) { if (document.cookie.length > 0) { var cookieStart = document.cookie.indexOf(name + "="); if (cookieStart != -1) { cookieStart = cookieStart + name.length + 1; var cookieEnd = document.cookie.indexOf(";", cookieStart); if (cookieEnd == -1) cookieEnd = document.cookie.length; return unescape(document.cookie.substring(cookieStart, cookieEnd)); } } return null; } /** * Contains Country of origin results COOResults. * Utility method for getting a request parameter from a URL. * @param URL to be parsed * @member GetURLParam * @returns value of request parameter * @link http://www.netlobo.com/url_query_string_javascript.html */ self.GetURLParam = function(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regexS = "[\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.href.toLowerCase()); if (results === null) { return ""; } else { return results[1]; } } self.RenameCategory = function(pageCategoryId) { /// Rename 'brandhome' to 'brand' var category = pageCategoryId; if(category.toLowerCase().indexOf("brandhome/") == 0 || category.toLowerCase().indexOf("/brandhome/") == 0) { if(category.indexOf("/") == 0) /// If the category begins with /, which normally it should not be the case but lets check anyway category = category.slice(11,category.length); else category = category.slice(10,category.length); category = "brand/" + category; } return category; } self.category = category; self.siteType = siteType; // BRAND or SHOP self.brandType = brandType; // Originals, Styles self.countryCode = countryCode; }; var globalHelper = new CMGlobal(); var adidasGlobal = new CMGlobal("BR","P","WT","" + ((globalHelper.GetCookie("country") == null ? "COM":globalHelper.GetCookie("country"))) + "");