$(document).ready(function() { BrowserDetect.init(); $(".widget-leftfeatured a.title").click(function() { $(this).next().toggle(); return false }); $("#accordion-middle .title").not($(".opened")).next().hide(); $("#accordion-middle .title-red").click(function() { $("#accordion-middle .title-red").not(this).next().hide("slow"); $(this).toggleClass("title-red-hide"); $(this).next().toggle("slow") }); $("#accordion-middle .title").click(function() { $("#accordion-middle .title").not(this).next().hide("slow"); $(this).toggleClass("title-hide"); $(this).next().toggle("slow") }); $("#simpletabs #tabs .tab").click(function() { var b = $("#simpletabs #tabs > li").index($(this).parent()); $("#simpletabs #tabcontent > li").hide(); $("#simpletabs #tabcontent > div").hide(); $("#simpletabs #tabcontent > li").eq(b).show(); $("#simpletabs #tabcontent > div").eq(b).show(); $("#simpletabs #tabs .tab-on").removeClass("tab-on"); $(this).addClass("tab-on") }); var a = []; $.preLoadImages = function() { var d = arguments.length; for (var c = d; c--; ) { var b = document.createElement("img"); b.src = arguments[c]; a.push(b) } }; GlobalHeaderDropdownInit($(".header-dropdown-trigger"), $(".header-dropdown-wrapper"), $(".ddm-wrapper")) }); function GlobalHeaderDropdownInit(a, c, b) { $(a).mouseenter(function() { $(b).show() }); $(c).mouseleave(function() { $(b).delay(1000).hide() }) } function QuickViewInit(g) { var b = $(g).attr("href"); var d = false; var f = $(g); var h = b.match(/(en|fr)-CA/gi)[0]; var e = b.match(/((M|BDL|B)?[0-9]+)\.\aspx/gi)[0].replace(/\.\aspx/gi, ""); if (h && e && !$(g).attr("onclick") && $(g).attr("rel") != "noqv" && $(g).parent().attr("id") != "languages") { var c; var a, i; f.mouseover(function(j) { if ($("#qv_" + e).length == 0) { $("body").append('<div class="quickview" id="qv_' + e + '"><img src="/images/common/pictures/progress.gif" border="0" class="loading"></div>'); $("#qv_" + e).attr("rel", j.pageX + "," + j.pageY); $("#qv_" + e).load("/" + h + "/quickview/" + e + ".aspx?AllowSecure=True .box", null, function(m, l) { if (l == "success") { $("#qv_" + e).find("a").each(function() { var q = $(this).html(); $(this).replaceWith(q) }); if (navigator.appName == "Microsoft Internet Explorer") { $("#qv_" + e).find(".customerrating").css("margin-bottom", "7px") } $("#qv_" + e).find(".rating img").each(function() { $(this).attr("src", $(this).attr("src").replace(/(\.\.\/)+/gi, "/")); $(this).attr("src", $(this).attr("src").replace(/^(.*)images/gi, "/images")) }); $("#qv_" + e).find(".stdlist3 li:even").addClass("alt"); if ($("#qv_" + e).find(".stdlist3 li").length == 0) { $("#qv_" + e).find(".stdlist3").hide() } $("#qv_" + e).find(".stdlist3 li").each(function() { $(this).html('<span class="name">' + $(this).text().replace(/:( )?/, ':</span><span class="value">') + "</span>"); if (navigator.appName != "Microsoft Internet Explorer") { $(this).append('<div class="clear"></div>') } else { $(this).css("display", "inline-block") } }); $("#qv_" + e).append('<div class="availability"><ul class="stores">'); $("#qv_" + e).find(".availability").prepend('<span class="title">' + $("#qv_" + e).find(".onlineavailability h3").text().match(/(Availability|Disponibilité)/gi) + "</span>"); var o; if ($("#qv_" + e).find(".onlineavailability p span").text().search(/not/gi) > 0) { o = $("<li>").html('<img src="/images/common/pictures/ico-out-of-stock.gif" border="0">futureshop.ca') } else { o = $("<li>").html('<img src="/images/common/pictures/ico-in-stock.gif" border="0">futureshop.ca') } $("#qv_" + e).find(".availability .stores").append(o); $("#qv_" + e).find(".in-store-availability ul li").each(function() { var q; q = $("<li>").html('<img src="' + $(this).find("input").attr("src") + '" border="0">' + $(this).text().trim()); $("#qv_" + e).find(".availability .stores").append(q) }); if ($("#qv_" + e).find("#readreviews").text().search(/\(/g) > 0) { var p; p = $("#qv_" + e).find("#readreviews").text().match(/\([0-9]*\)/g); if (h == "fr") { p = String(p).replace(/\(/g, "").replace(/\)/g, "") + " évaluations des clients" } else { p = String(p).replace(/\(/g, "").replace(/\)/g, "") + " customer reviews" } $("#qv_" + e).find("#ProductImageControlMainContainer").prepend('<span class="customerreview">' + p + "</span>") } $("#qv_" + e).width(250); if ($("#qv_" + e).attr("rel") != "") { a = parseInt($("#qv_" + e).attr("rel").split(",")[0]); i = parseInt($("#qv_" + e).attr("rel").split(",")[1]) } var n, k; if (i - 65 < getScrollY() + 5) { k = getScrollY() + 5 } else { if (i - 65 + $("#qv_" + e).height() > getScrollY() + getViewSize()[1] - 20) { k = getScrollY() + getViewSize()[1] - 20 - $("#qv_" + e).height() } else { k = i - 65 } } n = (a + 75 + $("#qv_" + e).width() > getViewSize()[0]) ? a - 35 - $("#qv_" + e).width() : a + 35; if (parseInt($("#qv_" + e).css("left").replace(/px/gi, "")) > 0) { $("#qv_" + e).animate({ left: n, top: k }, { queue: false, duration: 100 }) } } else { $("#qv_" + e).remove() } }) } c = setTimeout(function() { $("#qv_" + e).css({ opacity: 0 }); $("#qv_" + e).animate({ opacity: 1 }, { queue: false, duration: 500 }) }, 1000) }).mousemove(function(l) { var k, j; if (l.pageY - 65 < getScrollY() + 5) { j = getScrollY() + 5 } else { if (l.pageY - 65 + $("#qv_" + e).height() > getScrollY() + getViewSize()[1] - 20) { j = getScrollY() + getViewSize()[1] - 20 - $("#qv_" + e).height() } else { j = l.pageY - 65 } } k = (l.pageX + 75 + $("#qv_" + e).width() > getViewSize()[0]) ? l.pageX - 35 - $("#qv_" + e).width() : l.pageX + 35; $("#qv_" + e).css({ left: k, top: j }); $("#qv_" + e).attr("rel", l.pageX + "," + l.pageY) }).mouseout(function() { clearTimeout(c); $("#qv_" + e).css({ left: -9999 }).animate({ opacity: 0 }, { queue: false, duration: 20 }) }).click(function() { clearTimeout(c); $("#qv_" + e).css({ left: -9999 }).animate({ opacity: 0 }, { queue: false, duration: 20 }) }) } } function FeatureProductEqualiseBoxesHeight(e) { var b = 144, c = 309, d = 40, a = $("#" + e + " .standard-theme:first").height(); (($("#" + e + " .featureproduct .content").height() < a - d) && ($("#" + e + " .featureproduct .content").height(a - d))) } function simpletabsSelect(a) { $("#simpletabs #tabs .tab").eq(a).click() } $.fn.uilightboxlink = function(b) { var a = 1; return this.each(function() { var c = $(this).attr("href"); $(this).attr("href", "#"); if ($(this).attr("ref")) { a = $(this).attr("ref") } else { $(this).attr("ref", a); a++ } var d = $(this); $(this).click(function() { $(b).find(".ui-viewpanel").uiLoader(true); $(b).show(); var e; if ($(b).find(".ui-loader").attr("ref") == "autorun") { if (c.match(/([^\/\\]+)\.(jpg|jpeg|gif|png)$/i)) { e = function() { LoadImageViwer(b, c, $(d).attr("ref")) } } else { if (c.match(/([^\/\\]+)\.(swf)/i)) { e = function() { var g = c.slice(c.search(/[?]/i) + 1); var j, f = new Array(), h; for (j = 0; j < g.split("&").length; j++) { h = g.split("&")[j]; f[h.split("=")[0]] = h.split("=")[1] } LoadVideoPlayer(b, c, $(d).attr("ref"), { varAutoRun: f.varAutoPlay, width: parseInt(f.width), height: parseInt(f.height), srcFlv: f.varSource }) } } else { if (c.match(/(^#.{1,})/i)) { e = function() { LoadPopoverContent(b, c) } } } } runLoader(b, e) } else { setLoader(b, 0) } $("#ui-lightbox-dim").show(); return false }) }) }; $.fn.uilightboxgallery = function(a) { return this.each(function() { $(a).uiImageViewer(this); $(this).find("li > a").uilightboxlink(a) }) }; function uilightbox(c) { var b = $("<div>").addClass("ui-lightbox").attr("id", c).append('<div class="ui-viewpanel"></div>'); $("BODY").append(b); if (!$("#ui-lightbox-dim").length) { $("BODY").append('<div id="ui-lightbox-dim"></div>'); dimBackground($("#ui-lightbox-dim")); $("#ui-lightbox-dim").click(function() { $(".ui-lightbox").fadeOut(function() { $(this).find(".ui-viewpanel").html("") }); $("#ui-lightbox-dim").hide(); return false }) } var a = $("#" + c); $(a).prepend('<div class="ui-controls"></div>'); $(a).find(".ui-controls").append('<div class="pnlClose"><a href="#" class="btnClose">close</a></div>'); $(a).find(".btnClose").click(function() { $("#ui-lightbox-dim").click(); return false }); positionPanel(a); $(window).bind("resize", function() { if ($(a).css("display") != "none" && $(a).css("opacity") == 1) { dimBackground($("#ui-lightbox-dim")); positionPanel(a, $(a).width(), $(a).height()) } }); return b } $.fn.uiImageViewer = function(a) { return this.each(function() { var c = this; $(this).addClass("ui-imageviewer"); if (a) { $(this).find(".ui-controls").append('<div class="pnlPrevious"><a href="#" class="btnPrevious">previous</a></div>'); $(this).find(".ui-controls").append('<div class="pnlNext"><a href="#" class="btnNext">next</a></div>'); $(this).find(".ui-controls").append('<a href="#" class="btnNext-extend"></a>'); $(this).find(".ui-controls").append('<a href="#" class="btnPrevious-extend"></a>') } positionPanel(c); if (a) { var d = $(a).find("li a").length; var e; $(this).find(".btnNext").css({ opacity: 0 }); $(this).find(".btnNext").click(function() { if ($(c).find(".ui-viewpanel img").attr("ref")) { e = parseInt($(c).find(".ui-viewpanel img").attr("ref")) } else { if ($(c).find(".ui-viewpanel div.phVideo").attr("ref")) { e = parseInt($(c).find(".ui-viewpanel div.phVideo").attr("ref")) } else { e = 0 } } if (e == d) { $(a).find("li:nth-child(1) a").click() } else { $(a).find("li:nth-child(" + (e + 1) + ") a").click() } return false }); $(this).find(".btnNext").hover(function() { $(this).animate({ opacity: 1 }, { queue: false, duration: 250 }) }, function() { $(this).animate({ opacity: 0 }, { queue: false, duration: 250 }) }); $(this).find(".btnPrevious").css({ opacity: 0 }); $(this).find(".btnPrevious").click(function() { if ($(c).find(".ui-viewpanel img").attr("ref")) { e = parseInt($(c).find(".ui-viewpanel img").attr("ref")) } else { if ($(c).find(".ui-viewpanel div.phVideo").attr("ref")) { e = parseInt($(c).find(".ui-viewpanel div.phVideo").attr("ref")) } else { e = 0 } } if (e == 1) { $(a).find("li:nth-child(" + d + ") a").click() } else { $(a).find("li:nth-child(" + (e - 1) + ") a").click() } return false }); $(this).find(".btnPrevious").hover(function() { $(this).animate({ opacity: 1 }, { queue: false, duration: 250 }) }, function() { $(this).animate({ opacity: 0 }, { queue: false, duration: 250 }) }); var f = $(this).find(".btnNext-extend"); $(f).click(function() { $(c).find(".btnNext").click(); return false }); $(f).mouseover(function() { $(c).find(".btnNext").mouseover() }); $(f).mouseout(function() { $(c).find(".btnNext").mouseout() }); var b = $(this).find(".btnPrevious-extend"); $(b).click(function() { $(c).find(".btnPrevious").click(); return false }); $(b).mouseover(function() { $(c).find(".btnPrevious").mouseover() }); $(b).mouseout(function() { $(c).find(".btnPrevious").mouseout() }) } }) }; $.fn.uiLoader = function(a) { $(this).empty().html('<div class="ui-loader"><span class="ui-loader-bar"></span><span class="ui-loader-percentage"></span></div>'); $(this).find(".ui-loader").css("top", $(this).parent().height() / 2 - 10); if (a) { $(this).find(".ui-loader").attr("ref", "autorun") } }; function runLoader(c, b) { var a = $(c).find(".ui-loader"); $(a).find(".ui-loader-bar").css({ backgroundPosition: "-99px 0" }); $(a).find(".ui-loader-bar").animate({ backgroundPosition: "0px 0" }, { duration: 250, complete: b }) } function setLoader(c, d, b) { var a = $(c).find(".ui-loader"); $(a).find(".ui-loader-bar").animate({ backgroundPosition: (-99 * (100 - d) / 100) + "px 0" }, { duration: 500, complete: b }) } function LoadImageViwer(d, c, b) { $(d).find(".ui-viewpanel").empty().html('<img src="' + c + '" border="0" class="gallery-image" ref="' + b + '" style="opacity:0">'); var a = function() { $(d).find(".ui-viewpanel .gallery-image").animate({ opacity: 1 }, { queue: false, duration: 250 }) }; positionPanel(d, $(d).find(".ui-viewpanel .gallery-image").width(), $(d).find(".ui-viewpanel .gallery-image").height(), a) } function LoadPopoverContent(e, c) { $(e).find(".ui-viewpanel").empty().html($(c).html()); var b = function() { $(e).find(".ui-viewpanel").animate({ opacity: 1 }, { queue: false, duration: 250 }) }; var a, d; d = $(e).find(".ui-viewpanel .popcontent").height() + parseInt($(e).find(".ui-viewpanel .popcontent").css("padding-top")) + parseInt($(e).find(".ui-viewpanel .popcontent").css("padding-bottom")); d = (d > (getViewSize()[1] * 0.9)) ? (getViewSize()[1] * 0.9) : d; $(e).find(".ui-viewpanel .popcontent").height(d - parseInt($(e).find(".ui-viewpanel .popcontent").css("padding-top")) - parseInt($(e).find(".ui-viewpanel .popcontent").css("padding-bottom"))); a = (navigator.userAgent.toLowerCase().indexOf("msie 6") != -1) ? $(c).width() + 28 : $(c).width(); positionPanel(e, a, d, b) } function LoadVideoPlayer(f, d, c, g) { var e, b; e = g.width ? g.width : 400; b = g.height ? g.height : 300; $(f).find(".ui-viewpanel").empty().html('<div class="phVideo" ref="' + c + '"><div id="phVideo"></div></div>'); $(f).find(".ui-viewplanel .phVideo").css({ width: e, height: b }); var a = function() { var h = { varAutoPlay: g.varAutoRun, varSource: g.srcFlv }; var j = { wmode: "transparent", allowscriptaccess: "always", base: ".", menu: "false" }; var i = {}; swfobject.embedSWF(d, "phVideo", e, b, "9.0.0", false, h, j, i); $(f).find(".ui-viewpanel .plVideo").animate({ opacity: 1 }, { queue: false, duration: 250 }) }; positionPanel(f, e, b, a) } function dimBackground(a) { $(a).css({ width: getViewSize()[0], height: ($("body").height() + parseInt($("body").css("margin-top").replace("px", "")) + parseInt($("body").css("margin-bottom").replace("px", "")) + parseInt($("body").css("padding-top").replace("px", "")) + parseInt($("body").css("margin-bottom").replace("px", ""))) < getViewSize()[1] ? getViewSize()[1] : ($("body").height() + parseInt($("body").css("margin-top").replace("px", "")) + parseInt($("body").css("margin-bottom").replace("px", "")) + parseInt($("body").css("padding-top").replace("px", "")) + parseInt($("body").css("margin-bottom").replace("px", ""))) }) } function positionPanel(f, d, e, a) { if (d) { var c = 0, b = 0; b = getViewSize()[0]; c = getViewSize()[1]; $(f).stop().animate({ width: (d), height: (e), top: (c - e) / 2 + getScrollY() - 10, left: (b - d) / 2 }, { queue: false, duration: 150, complete: a }).css("overflow", "visible"); $(f).find(".pnlClose").animate({ left: (d - 6), top: (-18) }, { queue: false, duration: 150 }); $(f).find(".pnlNext").animate({ left: (d + 7), top: (e / 2 - 26) }, { queue: false, duration: 150 }); $(f).find(".pnlPrevious").animate({ left: -26 - 7, top: (e / 2 - 26) }, { queue: false, duration: 150 }); $(f).find(".btnNext-extend").animate({ left: (d * 0.5 + 26 + 7), height: e }, { queue: false, duration: 150 }); $(f).find(".btnPrevious-extend").animate({ left: -26 - 7, height: e }, { queue: false, duration: 150 }) } $(f).find(".ui-loader").css({ top: (e / 2 - $(f).find(".ui-loader").height() / 2) }) } function getViewSize() { var b = 0, a = 0; if (typeof ($(window).width()) == "number") { b = $(window).width(); a = $(window).height() } else { if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { b = document.documentElement.clientWidth; a = document.documentElement.clientHeight } } return [b, a] } function getScrollY() { var a = 0; if (typeof (window.pageYOffset) == "number") { a = window.pageYOffset } else { if (document.body && document.body.scrollTop) { a = document.body.scrollTop } else { if (document.documentElement && document.documentElement.scrollTop) { a = document.documentElement.scrollTop } } } return a } var BrowserDetect = { init: function() { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS" }, searchString: function(d) { for (var a = 0; a < d.length; a++) { var b = d[a].string; var c = d[a].prop; this.versionSearchString = d[a].versionSearch || d[a].identity; if (b) { if (b.indexOf(d[a].subString) != -1) { return d[a].identity } } else { if (c) { return d[a].identity } } } }, searchVersion: function(b) { var a = b.indexOf(this.versionSearchString); if (a == -1) { return } return parseFloat(b.substring(a + this.versionSearchString.length + 1)) }, dataBrowser: [{ string: navigator.userAgent, subString: "Chrome", identity: "Chrome" }, { string: navigator.userAgent, subString: "OmniWeb", versionSearch: "OmniWeb/", identity: "OmniWeb" }, { string: navigator.vendor, subString: "Apple", identity: "Safari", versionSearch: "Version" }, { prop: window.opera, identity: "Opera" }, { string: navigator.vendor, subString: "iCab", identity: "iCab" }, { string: navigator.vendor, subString: "KDE", identity: "Konqueror" }, { string: navigator.userAgent, subString: "Firefox", identity: "Firefox" }, { string: navigator.vendor, subString: "Camino", identity: "Camino" }, { string: navigator.userAgent, subString: "Netscape", identity: "Netscape" }, { string: navigator.userAgent, subString: "MSIE", identity: "Explorer", versionSearch: "MSIE" }, { string: navigator.userAgent, subString: "Gecko", identity: "Mozilla", versionSearch: "rv" }, { string: navigator.userAgent, subString: "Mozilla", identity: "Netscape", versionSearch: "Mozilla"}], dataOS: [{ string: navigator.platform, subString: "Win", identity: "Windows" }, { string: navigator.platform, subString: "Mac", identity: "Mac" }, { string: navigator.userAgent, subString: "iPhone", identity: "iPhone/iPod" }, { string: navigator.platform, subString: "Linux", identity: "Linux"}] }; var uiFS = { statusMsg: function(a) { $("#globalStatusMsg").clearQueue().stop().html("").css("height", "auto").hide().html(a).slideDown().animate({ opacity: 1 }, 5000, function() { $(this).slideUp() }) }, accessoriesWidget: function(B, c, t, v, p, d, u, g) { var z = $(c), C = $(p), F = (B.substr(0, 2)).toUpperCase(), m = false, E = null, x = null, l = g ? g : false, n = null, s = null, f = null, h = null, q = null; this.showNumProd = t; var i = { alsoAddThisOn: { EN: "Also Add This", FR: "Ajoutez aussi ce produit" }, alsoAddThisOff: { EN: "Remove", FR: "Retirer" }, showMoreOn: { EN: 'Show more <img src="/images/common/pictures/sortdescending.gif" width="12" height="10" />', FR: 'Montrez-en plus <img src="/images/common/pictures/sortdescending.gif" width="12" height="10" />' }, showMoreOff: { EN: 'Hide <img src="/images/common/pictures/sortascending.gif" width="12" height="10" />', FR: 'Cacher <img src="/images/common/pictures/sortascending.gif" width="12" height="10" />' }, accessories: { EN: "more item(s)<br/>selected", FR: "plus d'article(s)<br/>s&eacute;lectionn&eacute;s"} }; this.init = function() { var H = this; for (var G = 0; G < u.length; G++) { $(c + " " + u[G]).each(function(I, J) { o($(J)) }) } $(c + " " + v).each(function(I, J) { y(J) }); z.find(".removeAll").click(function() { a() }); z.find(".tabLink").each(function(I, J) { $(J).bind("click", function() { H.showItemsFromTab(I) }) }); z.find(d).toggle(function() { H.showMoreProd(); $(this).html(e("showMoreOff")) }, function() { H.hideMoreProd(); $(this).html(e("showMoreOn")) }); z.find(".ui-tabcontrol-content").each(function(J, K) { var I = $(this).find(v); var L = $(K).find(d); (I.length > H.showNumProd) ? L.show() : L.hide(); I.each(function(N, O) { var M = $(O); if (N < H.showNumProd) { M.css("display", "block").addClass("noBottomBorder") } else { if (N >= H.showNumProd) { return false } } if ((N + 1) % H.showNumProd == 0) { M.addClass("noBorder"); M.after('<div class="clear"></div>') } }) }); this.showItemsFromTab(0) }; var o = function(G) { $(G).click(function() { var J = $(this).parentsUntil(v).parent(), I = J.find(".prodImageWrap"), H = J.find(".field-title"), K = J.find(".accessoriesWidgetActionBtn"), L = (H.find("a").attr("href")).match(/((m|M|b|B){1}[0-9]{7}|[0-9]{8})/)[0]; if (w(L) == null) { b(L); K.html(e("alsoAddThisOff")); I.find(".prodStatus").fadeIn(); L = null } else { j(L); I.find(".prodStatus").fadeOut(); K.html(e("alsoAddThisOn")); L = null } trackEvent.event("event.link", { lid: "AccessoryWidget_prodSelect" }) }) }; var b = function(G) { if (!w(G)) { basket.GenericUpdateAccessories(G, true); D() } }; var j = function(G) { if (w(G) >= 0) { basket.GenericUpdateAccessories(G, false); D() } }; var a = function() { var G = z.find(".prodStatus"); basket.Accessories = new Array(1); G.each(function(H, I) { $(I).css("display", "none") }); z.find(".accessoriesWidgetActionBtn").each(function(H, I) { $(I).html(e("alsoAddThisOn")) }); D() }; var w = function(I) { var G = null; for (var H = 0; H < basket.Accessories.length; H++) { if (I == basket.Accessories[H]) { G = H; break } } return G }; var D = function() { if (basket.Accessories.length > 1) { C.addClass("active").html('<span class="quantity">+' + (basket.Accessories.length - 1) + "</span> " + e("accessories") + ' <div class="thumbs"></div>'); C.append('<div class="clear"></div>'); $("#accessoriesBoxStatusBottom").show() } else { C.removeClass("active").html(""); $("#accessoriesBoxStatusBottom").hide() } return false }; var y = function(H) { var G = $(H); $(H).mouseenter(function() { if ((!m) && (E == null)) { m = true; E = G; var I = G; k(x, 500, function() { if (E == G) { I.css({ "z-index": "10" }).find(".product").addClass("hover").find(".product-details").css({ display: "block" }); l && I.find(".field-title").css("display", "block") } }) } }).mouseleave(function() { if (E == G) { A(x); $(this).css({ "z-index": "5" }).find(".product").removeClass("hover").find(".product-details").css({ display: "none" }); l && $(this).find(".field-title").css("display", "none"); m = false; E = null } }) }; var r = function(H, G) { return "http://www.bestbuy.ca/multimedia/products/" + G + "x" + G + "/" + H.substr(0, 3) + "/" + H.substr(0, 5) + "/" + H + ".jpg" }; this.showItemsFromTab = function(G) { f = z.find(".ui-tabcontrol-content").eq(G); h = f.find(v) }; this.showMoreProd = function(G) { var H = this; l && h.removeClass("noBottomBorder"); h.each(function(J, K) { var I = $(K); if (J >= H.showNumProd) { I.css("display", "block"); ((J + 1) >= (Math.floor(h.length / H.showNumProd) * H.showNumProd + 1)) && I.addClass("noBottomBorder") } if ((J + 1) % H.showNumProd == 0) { I.addClass("noBorder"); I.after('<div class="clear"></div>') } }); trackEvent.event("event.link", { lid: "AccessoryWidget_showMore" }) }; this.hideMoreProd = function() { var G = this; h.each(function(I, J) { var H = $(J); (I < G.showNumProd) && H.addClass("noBottomBorder"); (I >= G.showNumProd) && H.css("display", "none") }); trackEvent.event("event.link", { lid: "AccessoryWidget_hideMore" }) }; var e = function(G) { return i[G][F] }; var k = function(H, I, G) { (function J() { if (I <= 0) { G(); clearInterval(H) } else { I -= 30; H = setTimeout(J, 30) } })() }; var A = function(G) { clearInterval(G) }; this.init() }, Variance: function(j, d, f, i) { var j = j ? j : "", d = d ? d : "", f = f ? f : null, i = i ? i : 30, e = null, g = null, c = 0, b = false; var k = function() { h(); if (!b && f != null) { if (c == 0) { for (var m = 0; m < f.length; m++) { c += f[m].weight } } var l = Math.floor(Math.random() * c), n = 0; for (var m = 0; m < f.length; m++) { if (l < (n + f[m].weight)) { g = f[m]; e = f[m].variance; break } else { n += f[m].weight } } a(); trackEvent.event("event.link", { lid: "GUI_Variance_" + j + "_" + d + "_" + e + "_visitor" }) } else { if (f != null) { for (var m = 0; m < f.length; m++) { if (f[m].variance == e) { g = f[m]; break } } } else { if (!b) { e = "unaffected" } } } if (f != null) { trackEvent.event("event.link", { lid: "GUI_Variance_" + j + "_" + d + "_" + e + "_views" }) } !(g == null) && g.init() }; this.entry = function(l) { trackEvent.event("event.link", { lid: "GUI_Variance_" + j + "_" + d + "_" + e + "_" + l + "_entry" }) }; this.goal = function() { if (b) { trackEvent.event("event.link", { lid: "GUI_Variance_" + j + "_" + d + "_" + e + "_goal" }) } }; var a = function() { var l = new Date(); var m = "|"; l.setTime(l.getTime() + (i * 24 * 60 * 60 * 1000)); document.cookie = "gui_v_" + j + "_" + d + "=" + e + "; expires=" + l.toGMTString() + "; path=/" }; var h = function() { var l = document.cookie.split(";"); for (var m = 0; m < l.length; m++) { var n = l[m]; while (n.charAt(0) == " ") { n = n.substring(1, n.length) } if (n.indexOf("gui_v_" + j + "_" + d + "=") == 0) { e = n.substring((6 + j.length + 1 + d.length + 1), n.length); b = true } } }; this.clearCookie = function() { var l = new Date(); l.setTime(l.getTime() + (-1 * 24 * 60 * 60 * 1000)); document.cookie = "gui_v_" + j + "_" + d + "=; expires=" + l.toGMTString() + "; path=/" }; k() } }; var uiFS = { statusMsg: function(a) { $("#globalStatusMsg").clearQueue().stop().html("").css("height", "auto").hide().html(a).slideDown().animate({ opacity: 1 }, 5000, function() { $(this).slideUp() }) }, accessoriesWidget: function(B, c, t, v, p, d, u, g) { var z = $(c), C = $(p), F = (B.substr(0, 2)).toUpperCase(), m = false, E = null, x = null, l = g ? g : false, n = null, s = null, f = null, h = null, q = null; this.showNumProd = t; var i = { alsoAddThisOn: { EN: "Also Add This", FR: "Ajoutez aussi ce produit" }, alsoAddThisOff: { EN: "Remove", FR: "Retirer" }, showMoreOn: { EN: 'Show more <img src="/images/common/pictures/sortdescending.gif" width="12" height="10" />', FR: 'Montrez-en plus <img src="/images/common/pictures/sortdescending.gif" width="12" height="10" />' }, showMoreOff: { EN: 'Hide <img src="/images/common/pictures/sortascending.gif" width="12" height="10" />', FR: 'Cacher <img src="/images/common/pictures/sortascending.gif" width="12" height="10" />' }, accessories: { EN: "more item(s)<br/>selected", FR: "plus d'article(s)<br/>s&eacute;lectionn&eacute;s"} }; this.init = function() { var H = this; for (var G = 0; G < u.length; G++) { $(c + " " + u[G]).each(function(I, J) { o($(J)) }) } $(c + " " + v).each(function(I, J) { y(J) }); z.find(".removeAll").click(function() { a() }); z.find(".tabLink").each(function(I, J) { $(J).bind("click", function() { H.showItemsFromTab(I) }) }); z.find(d).toggle(function() { H.showMoreProd(); $(this).html(e("showMoreOff")) }, function() { H.hideMoreProd(); $(this).html(e("showMoreOn")) }); z.find(".ui-tabcontrol-content").each(function(J, K) { var I = $(this).find(v); var L = $(K).find(d); (I.length > H.showNumProd) ? L.show() : L.hide(); I.each(function(N, O) { var M = $(O); if (N < H.showNumProd) { M.css("display", "block").addClass("noBottomBorder") } else { if (N >= H.showNumProd) { return false } } if ((N + 1) % H.showNumProd == 0) { M.addClass("noBorder"); M.after('<div class="clear"></div>') } }) }); this.showItemsFromTab(0) }; var o = function(G) { $(G).click(function() { var J = $(this).parentsUntil(v).parent(), I = J.find(".prodImageWrap"), H = J.find(".field-title"), K = J.find(".accessoriesWidgetActionBtn"), L = (H.find("a").attr("href")).match(/((m|M|b|B){1}[0-9]{7}|[0-9]{8})/)[0]; if (w(L) == null) { b(L); K.html(e("alsoAddThisOff")); I.find(".prodStatus").fadeIn(); L = null } else { j(L); I.find(".prodStatus").fadeOut(); K.html(e("alsoAddThisOn")); L = null } trackEvent.event("event.link", { lid: "AccessoryWidget_prodSelect" }) }) }; var b = function(G) { if (!w(G)) { basket.GenericUpdateAccessories(G, true); D() } }; var j = function(G) { if (w(G) >= 0) { basket.GenericUpdateAccessories(G, false); D() } }; var a = function() { var G = z.find(".prodStatus"); basket.Accessories = new Array(1); G.each(function(H, I) { $(I).css("display", "none") }); z.find(".accessoriesWidgetActionBtn").each(function(H, I) { $(I).html(e("alsoAddThisOn")) }); D() }; var w = function(I) { var G = null; for (var H = 0; H < basket.Accessories.length; H++) { if (I == basket.Accessories[H]) { G = H; break } } return G }; var D = function() { if (basket.Accessories.length > 1) { C.addClass("active").html('<span class="quantity">+' + (basket.Accessories.length - 1) + "</span> " + e("accessories") + ' <div class="thumbs"></div>'); C.append('<div class="clear"></div>'); $("#accessoriesBoxStatusBottom").show() } else { C.removeClass("active").html(""); $("#accessoriesBoxStatusBottom").hide() } return false }; var y = function(H) { var G = $(H); $(H).mouseenter(function() { if ((!m) && (E == null)) { m = true; E = G; var I = G; k(x, 500, function() { if (E == G) { I.css({ "z-index": "10" }).find(".product").addClass("hover").find(".product-details").css({ display: "block" }); l && I.find(".field-title").css("display", "block") } }) } }).mouseleave(function() { if (E == G) { A(x); $(this).css({ "z-index": "5" }).find(".product").removeClass("hover").find(".product-details").css({ display: "none" }); l && $(this).find(".field-title").css("display", "none"); m = false; E = null } }) }; var r = function(H, G) { return "http://www.bestbuy.ca/multimedia/products/" + G + "x" + G + "/" + H.substr(0, 3) + "/" + H.substr(0, 5) + "/" + H + ".jpg" }; this.showItemsFromTab = function(G) { f = z.find(".ui-tabcontrol-content").eq(G); h = f.find(v) }; this.showMoreProd = function(G) { var H = this; l && h.removeClass("noBottomBorder"); h.each(function(J, K) { var I = $(K); if (J >= H.showNumProd) { I.css("display", "block"); ((J + 1) >= (Math.floor(h.length / H.showNumProd) * H.showNumProd + 1)) && I.addClass("noBottomBorder") } if ((J + 1) % H.showNumProd == 0) { I.addClass("noBorder"); I.after('<div class="clear"></div>') } }); trackEvent.event("event.link", { lid: "AccessoryWidget_showMore" }) }; this.hideMoreProd = function() { var G = this; h.each(function(I, J) { var H = $(J); (I < G.showNumProd) && H.addClass("noBottomBorder"); (I >= G.showNumProd) && H.css("display", "none") }); trackEvent.event("event.link", { lid: "AccessoryWidget_hideMore" }) }; var e = function(G) { return i[G][F] }; var k = function(H, I, G) { (function J() { if (I <= 0) { G(); clearInterval(H) } else { I -= 30; H = setTimeout(J, 30) } })() }; var A = function(G) { clearInterval(G) }; this.init() }, Variance: function(j, d, f, i) { var j = j ? j : "", d = d ? d : "", f = f ? f : null, i = i ? i : 30, e = null, g = null, c = 0, b = false; var k = function() { h(); if (!b && f != null) { if (c == 0) { for (var m = 0; m < f.length; m++) { c += f[m].weight } } var l = Math.floor(Math.random() * c), n = 0; for (var m = 0; m < f.length; m++) { if (l < (n + f[m].weight)) { g = f[m]; e = f[m].variance; break } else { n += f[m].weight } } a(); trackEvent.event("event.link", { lid: "GUI_Variance_" + j + "_" + d + "_" + e + "_visitor" }) } else { if (f != null) { for (var m = 0; m < f.length; m++) { if (f[m].variance == e) { g = f[m]; break } } } else { if (!b) { e = "unaffected" } } } if (f != null) { trackEvent.event("event.link", { lid: "GUI_Variance_" + j + "_" + d + "_" + e + "_views" }) } !(g == null) && g.init() }; this.entry = function(l) { trackEvent.event("event.link", { lid: "GUI_Variance_" + j + "_" + d + "_" + e + "_" + l + "_entry" }) }; this.goal = function() { if (b) { trackEvent.event("event.link", { lid: "GUI_Variance_" + j + "_" + d + "_" + e + "_goal" }) } }; var a = function() { var l = new Date(); var m = "|"; l.setTime(l.getTime() + (i * 24 * 60 * 60 * 1000)); document.cookie = "gui_v_" + j + "_" + d + "=" + e + "; expires=" + l.toGMTString() + "; path=/" }; var h = function() { var l = document.cookie.split(";"); for (var m = 0; m < l.length; m++) { var n = l[m]; while (n.charAt(0) == " ") { n = n.substring(1, n.length) } if (n.indexOf("gui_v_" + j + "_" + d + "=") == 0) { e = n.substring((6 + j.length + 1 + d.length + 1), n.length); b = true } } }; this.clearCookie = function() { var l = new Date(); l.setTime(l.getTime() + (-1 * 24 * 60 * 60 * 1000)); document.cookie = "gui_v_" + j + "_" + d + "=; expires=" + l.toGMTString() + "; path=/" }; k() } };
