$(function() { //startup function on EVERY page $("#btnViewTheStore").click(btnViewTheStore_Click); $("#btnBrowseByCategory").click(btnBrowseByCategory_Click); $("#MenuContainer a").hover(menuItemOver, menuItemOut); initializeMenu(); //hook up the hide store action $("#ViewTheStore").click(hideTheStore); $("#StoreCloseButton").click(hideTheStore); }); function ResolveUrl(url) { //resolves a url with ~/ //relies on the baseUrl variable set in the Global.master. if (url.indexOf("~/") == 0) { url = baseUrl + url.substring(2); } return url; } function initializeMenu() { //initialize the menu hover states //take off the ~/en-ca/ var startingUrl = appRelativeCurrentExecutionFilePath.substring(("~/en-ca/").length).toLowerCase(); if (startingUrl.indexOf("/") != -1 && startingUrl.indexOf("/") < startingUrl.indexOf(".aspx")) { startingUrl = startingUrl.substring(0, startingUrl.indexOf("/")); } else if (startingUrl.indexOf(".aspx") != -1) { startingUrl = startingUrl.substring(0, startingUrl.indexOf(".aspx")); } var miElem = $("#mi" + startingUrl); if (miElem.size() > 0) { var className = miElem.attr("className"); if (className.indexOf("-sel") == -1) { miElem.attr("className", className + "-sel") } } } function btnViewTheStore_Click() { var url = ResolveUrl("~/ecms.ashx/images/ViewTheStore.jpg"); var img = new Image(); $("#TopLevelContainer").hide(); $("#ViewTheStore").show(); $(img).load(function() { $("#ViewTheStore img").attr("src", url).show(); setTimeout(function() { $("#StoreCloseButton").fadeIn("normal"); }, 2000); }).attr("src", url); return false; } function hideTheStore() { $("#ViewTheStore").hide(); $("#StoreCloseButton").hide(); $("#TopLevelContainer").show(); } function NewsletterSignup() { btnNewLetterSignup_Click(); } function btnNewLetterSignup_Click() { var url = "https://www.formdesk.com/shoppersdrugmart/murale_optin"; if (languageCode == "en-fr") { url = "https://www.formdesk.com/shoppersdrugmart/murale_fr_optin"; } var returnUrl = ResolveUrl("~/Dialogs/DialogCloser.aspx"); returnUrl = "http://" + location.hostname + returnUrl; url += "?nobutton&returnUrl=" + escape(returnUrl); showIFrameDialog(url, 600, 650); return false; } function btnBrowseByCategory_Click() { var className = $("#btnBrowseByCategory").attr("className"); className = className.replace("Unselected", "Selected"); $("#btnBrowseByCategory").attr("className", className); showCategoryPopup(); } function hideCategoryPopup() { $("#CategoryPopup").slideUp("fast", function() { var className = $("#btnBrowseByCategory").attr("className"); className = className.replace("Selected", "Unselected"); $("#btnBrowseByCategory").attr("className", className); $(document).unbind("click", hideCategoryPopup); }); } function showCategoryPopup() { var pos = $("#btnBrowseByCategory").position(); var width1 = $("#btnBrowseByCategory").width(); var width2 = $("#CategoryPopup").width(); var offset = width2 - width1 - 3; $("#CategoryPopup").css("top", (pos.top + 22) + "px"); $("#CategoryPopup").css("left", (pos.left - offset) + "px"); $("#CategoryPopup").slideDown("fast", function() { $(document).bind("click", hideCategoryPopup); }); } function menuItemOver(e) { var className = $(this).attr("className"); $(this).attr("origClassName", className) if (className.indexOf("-sel") == -1) { $(this).attr("className", className + "-sel") } } function menuItemOut(e) { var className = $(this).attr("origClassName"); $(this).attr("className", className); } /* BRAND DETAILS */ function initializeBrandDetails() { //set up the promo rotator $("#pnlFeatureBoxItems").data("rotatorIndex", 0); $("#pnlFeatureBoxItems .LeftArrow").click(function() { rotateBrandDetailsPromo(1, false); }); $("#pnlFeatureBoxItems .RightArrow").click(function() { rotateBrandDetailsPromo(-1, false); }); var timeoutVar = setTimeout(function() {rotateBrandDetailsPromo(1, true);}, imageRotationSpeedSeconds * 1000); $("#pnlFeatureBoxItems").data("timeoutVar", timeoutVar); $("#pnlFeatureBoxItems").hover( function() { //over //cancel rotation... var toVar = $("#pnlFeatureBoxItems").data("timeoutVar"); if (toVar != -1) clearTimeout(toVar); $("#pnlFeatureBoxItems").data("timeoutVar", -1); //show the arrow $("#pnlFeatureBoxItems .LeftArrow").show(); $("#pnlFeatureBoxItems .RightArrow").show(); }, function() { //out - restart the rotation var timeoutVar = setTimeout(function() {rotateBrandDetailsPromo(1, true);}, imageRotationSpeedSeconds * 1000); $("#pnlFeatureBoxItems").data("timeoutVar", timeoutVar); //hide the arrows $("#pnlFeatureBoxItems .LeftArrow").hide(); $("#pnlFeatureBoxItems .RightArrow").hide(); }); } function rotateBrandDetailsPromo(plusMinus, isRotating) { $("#pnlFeatureBoxItems").data("timeoutVar", -1); if (isNaN(plusMinus) || plusMinus < 1) plusMinus = 1; var index = $("#pnlFeatureBoxItems").data("rotatorIndex"); var size = $("#pnlFeatureBoxItems .BrandPromo").size(); if (isNaN(index)) index = 0; var nextIndex = index + plusMinus; if (nextIndex > size - 1) nextIndex = 0; //check for image or video var pnlVideo = $("#pnlBrandPromo_" + nextIndex + " .pnlVideo"); if (pnlVideo.size() == 0) { //*********** IMAGE **************/ //preload the next image if we have to... var src2 = $("#pnlBrandPromo_" + nextIndex + " img").attr("src2"); var img = new Image(); $(img).load(function() { //set the src of the next image... $("#pnlBrandPromo_" + nextIndex + " img").attr("src", src2); //hide the rotator at this index... $("#pnlBrandPromo_" + index).fadeOut("normal", function() { //show the rotator at the next index (loop) index = nextIndex; $("#pnlFeatureBoxItems").data("rotatorIndex", index); $("#pnlBrandPromo_" + index).fadeIn("normal", function() { if (isRotating == true) { var timeoutVar = setTimeout(function() {rotateBrandDetailsPromo(1, true);}, imageRotationSpeedSeconds * 1000); $("#pnlFeatureBoxItems").data("timeoutVar", timeoutVar); } }); }); }).attr("src", src2); } else { //*********** VIDEO **************/ var flvUrl = pnlVideo.attr("url"); var flashvars = { autostart: "true", file: flvUrl }; var params = { wmode: "transparent", allowfullscreen: "true" }; var attributes = { id: "videoPlayer_" + nextIndex }; var swfUrl = ResolveUrl("~/swf/player.swf"); var expressInstallUrl = ResolveUrl("~/swf/expressInstall.swf"); var expressInstallRequiredVersion = "6.0.65"; var versionStr = "9.0.0"; if (swfobject.hasFlashPlayerVersion(expressInstallRequiredVersion)) { pnlVideo.html("
"); swfobject.embedSWF(swfUrl, "pnlVideo_" + nextIndex, "620", "308", versionStr, "/swf/expressInstall.swf", flashvars, params, attributes); } else { pnlVideo.html("