///<reference path="jquery-1.4.2.min.js"/>
///<reference path="dep.js"/>

var dep = {
    settings: [],
    eventHandlers: [],
    pageParts: [],
    queryStrings: [],
    pageLoadFns: [],
    depInitFns: [],

    addConfigSetting: function (name, value) {
        dep.settings[name] = value;
    },

    addQueryString: function (name, value) {
        dep.queryStrings[name] = value;
    },

    addEventHandler: function (id, handlerFunction) {
        dep.eventHandlers[id] = handlerFunction;
    },

    addModule: function (id, fn) {
        dep.pageParts[id] = fn;
    },

    addTemplate: function (id, fn) {
        dep.pageParts[id] = fn;
    },

    onPageLoad: function (fn) {
        dep.pageLoadFns.push(fn);
    },

    addDEPInit: function (fn) {
        dep.depInitFns.push(fn);
    },

    depEvent: function (handlerId, argString, sender) {
        this.sender = sender;

        // extract arguments from string and set up arguments collection
        var args = argString.split("|");
        this.arguments = []
        for (var i = 0; i < args.length; i += 2) {
            this.arguments[args[i]] = args[i + 1];
        }

        // method for firing the event
        this.fire = function () {
            return dep.eventHandlers[handlerId](this);
        }

        return this;
    },

    click: function (e) {
        //var sender = this;
        var result = true;

        // check for events
        if (this.attributes.getNamedItem("depevents")) {
            result = dep.fireEvents(this.attributes.getNamedItem("depevents").value, this);
        }

        // run WebTrends tracking on the click directly
        e.which = 1;
        if (typeof (_tag) != "undefined" & (typeof (gTrackEvents) != "undefined" && gTrackEvents == "0"))
            dep.clearTagVars();
        _tag.dcsMSLinkTrack(e);

        // prevent navigation in nonIE browsers if last event returns false
        if (e.target != null & result == false)
            e.preventDefault();

        return result;
    },

    fireEvents: function (eventsString, sender) {
        if (eventsString.length > 0) {
            var events = [];
            var tagEvents = tagEvents = eventsString.split(";");

            for (var i = 0; i < tagEvents.length; i++) {
                var handlerId = tagEvents[i].substring(0, tagEvents[i].indexOf("["));
                var argString = tagEvents[i].substring(tagEvents[i].indexOf("[") + 1, tagEvents[i].indexOf("]"));

                if (dep.eventHandlers[handlerId]) {
                    events.push(new dep.depEvent(handlerId, argString, sender));
                }
            }

            for (var evt in events) {
                result = events[evt].fire();
            }

            return result;

        }

    },

    getFragment: function (url, fn) {

        url = dep.utils.makeUrlUnique(url);

        $.get(url, function (data) {
            fn(data);
        });

        //dep.initJS();

    },

    initJS: function () {
        $("textarea.onload").each(function (index) {
            eval(this.value);
            $(this).remove();
        });

        var total = dep.pageLoadFns.length;
        for (var i = 0; i < total; i++) {
            dep.pageLoadFns.pop()();
        }
    },

    pageLoad: function (e) {
        $("a").live("click", dep.click);

        for (var i in dep.depInitFns) {
            dep.depInitFns[i]();
        }

        for (var id in dep.pageParts) {
            if ($("." + id).length > 0)
                dep.pageParts[id]();
        }

        dep.initJS();

        //$("body").css("visibility", "visible");

        document.onkeyup = function (e) {
            if (!e) var e = window.event;
            if (e.keyCode == 78)
                dep.nkey = false;
        }
        document.onkeydown = function (e) {
            if (!e) var e = window.event;
            if (e.keyCode == 78)
                dep.nkey = true;
        }
    },

    utils: {

        getUrlHash: function () {
            if (window.location.hash && window.location.hash.length > 1) {
                return escape(window.location.hash.substring(1));
            }
            return "";
        },

        makeUrlUnique: function (url) {
            if (url.indexOf("?") > -1)
                url += "&depuid=";
            else
                url += "?depuid=";

            var stamp = new Date().getTime();
            return url + stamp;
        },

        appendQueryString: function (url, qs) {
            if (url.indexOf("?") > -1)
                url += "&" + qs;
            else
                url += "?" + qs;

            return url;
        },

        cookie: {
            write: function (name, value, days) {
                if (days) {
                    var date = new Date();
                    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
                    var expires = "; expires=" + date.toGMTString();
                }
                else var expires = "";
                document.cookie = name + "=" + value + expires + "; path=/";
            },

            read: function (name) {
                var nameEQ = name + "=";
                var ca = document.cookie.split(';');
                for (var i = 0; i < ca.length; i++) {
                    var c = ca[i];
                    while (c.charAt(0) == ' ') c = c.substring(1, c.length);
                    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
                }
                return null;
            },

            clear: function (name) {
                createC(name, "", -1);
            }
        }

    },

    browser: {

        ieOld: false,
        ie6: false,
        ie7: false,
        ie8: false
    },

    user: {
        osType: { windows: "windows", windowsphone: "windowsphone", macos: "macos", ios: "ios", android: "android" },
        browserType: { ie: "ie", firefox: "firefox", chrome: "chrome", safari: "safari" },
        deviceType: { ipad: "ipad", iphone: "iphone", ipod: "ipod" },
        ua: navigator.userAgent.toLowerCase(),
        os: null,
        device: null,
        browser: null,

        init: function () {
            // set OS
            if (dep.user.ua.contains("windows nt"))
                dep.user.os = dep.user.osType.windows;
            else if (dep.user.ua.contains("windows phone os"))
                dep.user.os = dep.user.osType.windowsphone;
            else if (dep.user.ua.contains("ipad") | dep.user.ua.contains("iphone"))
                dep.user.os = dep.user.osType.ios;
            else if (dep.user.ua.contains("mac os x"))
                dep.user.os = dep.user.osType.macos;
            else if (dep.user.ua.contains("android"))
                dep.user.os = dep.user.osType.android;

            //set device
            if (dep.user.ua.contains("ipad"))
                dep.user.device = dep.user.deviceType.ipad;
            else if (dep.user.ua.contains("iphone"))
                dep.user.device = dep.user.deviceType.iphone;
            else if (dep.user.ua.contains("ipod"))
                dep.user.device = dep.user.deviceType.ipod;

            // set browser
            if (dep.user.ua.contains("msie"))
                dep.user.browser = dep.user.browserType.ie;
            else if (dep.user.ua.contains("firefox"))
                dep.user.browser = dep.user.browserType.firefox;
            else if (dep.user.os == dep.user.osType.android & dep.user.ua.contains("safari"))
                dep.user.browser = dep.user.browserType.chrome;
            else if (dep.user.ua.contains("chrome"))
                dep.user.browser = dep.user.browserType.chrome;
            else if (dep.user.ua.contains("safari"))
                dep.user.browser = dep.user.browserType.safari;

        }
    },

    debug: function (s) {

        var ta = document.getElementById("dep-debug");

        if (!ta) {
            ta = document.createElement("textarea");
            ta.id = "dep-debug";
            document.body.appendChild(ta);
        }

        ta.value = s + "\n" + ta.value;
    },

    nkey: false
}

//set up dep page load event listener
if (window.addEventListener) {
    window.addEventListener("load", dep.pageLoad, true);
}
else if (window.attachEvent) {
    window.attachEvent("onload", dep.pageLoad);
}

///<reference path="jquery/jquery-1.4.2.min.js"/>
///<reference path="dep.js"/>

/* Prevents accidental console.log errors in IE */
(function (a) { function b() { } for (var c = "assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","), d; !!(d = c.pop()); ) { a[d] = a[d] || b; } })
(function () { try { console.log(); return window.console; } catch (a) { return (window.console = {}); } } ());


/* Script Click Handler */
dep.addEventHandler("ScriptClick", function (e) {
    eval(e.arguments["script"]);
    return true;
});

dep.addEventHandler("NoNavigation", function (e) {
    return false;
});

dep.addEventHandler("WebTrendsSetVar", function (e) {
    dep.clearTagVars();

    var s = "dcsSetVar(";
    for (var arg in e.arguments) {
        s += "'" + arg + "',";
        s += "'" + e.arguments[arg] + "',";
    }

    s = s.substring(0, s.lastIndexOf(","));
    s += ");";

    e.sender.setAttribute("onclick", s);

    eval(s);

    //Add an argument to specify whether it should navigate or not after the click.

    if (e.arguments["noNav"] == "true") {
        return false;
    }

    return true;


});


/* Webtrends Page View Handler */
dep.addEventHandler("WebTrendsPageView", function (e) {
    dep.clearTagVars();
    dcsMultiTrack("DCS.dcssip", "www.microsoft.com", "DCS.dcsuri", dep.settings["site_root"] + e.arguments["dcsuri"], "WT.dl", "0");
});


/* Rio Click Handler */
dep.addEventHandler("RioClick", function (e) {
    RioTracking.click(e.arguments["cellCode"], e.arguments["actionTag"]);
    return true;
});

/* Rio Page View Handler */
dep.addEventHandler("RioPageView", function (e) {
    RioTracking.guestCellCode = e.arguments["cellCode"];
    RioTracking.uniqueActionTagCode = e.arguments["actionTag"];
});


/* Generic Tracking Click Handler */
dep.addEventHandler("GenericTrackingClick", function (e) {
    dep.clearTagVars();
    var img = new Image();
    img.src = dep.utils.makeUrlUnique(e.arguments["url"]);
    return true;
});

dep.addEventHandler("FormSubmitByName", function (e) {
    $("form[name=" + e.arguments["formName"] + "]").submit();
    return false;
});

// Function to clear end actions values of a previous click before invoking the next click
dep.clearTagVars = function () {
    if (window._tag && _tag.WT) {
        _tag.WT.setvar_ti = '';
        _tag.WT.setvar_dl = '';
        _tag.WT.z_ea_name = '';
        _tag.WT.z_ea_actionoffer = '';
        _tag.WT.ti = '';
        _tag.WT.dl = '';
        _tag.WT.cg_n = '';
        _tag.WT.cg_s = '';
    }
}

dep.wtOptimize = {};
dep.wtOptimize.placeContent = function (url, sel) {

    url = dep.utils.makeUrlUnique(url);

    $.get(url, function (data) {
        $(sel).html(data);
    });

}

///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: artist-edition */

dep.addModule("artist-edition", function () {

	dep.artistEdition = {};
	$(".anchor", ".lightbox_content").remove();

	var isRTL = false;
	if ($(".artist-edition .current_artists[data-rtl='true']")[0]) {
		isRTL = true;
	}

	dep.addEventHandler("AeShowContent", function (e) {
		showLightboxPane($("#" + e.arguments["id"], ".lightbox"));
		return false;
	});

	dep.addEventHandler("PageThumbClick", function (e) {
		var type = e.arguments["type"];
		var artist = e.arguments["artist"];
		var pane = $(".pane." + type, "#zbox-lightbox-" + artist).get(0);
		if (type === "product") {
			pane = $(".pane." + type, "#zbox-lightbox-" + artist).get(1);
		}
		showLightboxPane(pane);
	});

	dep.forceAeVideoQuit = function () {
		$(".pane", ".lightbox").children(":visible").hide();
	}

	function showLightboxPane(pane) {
		if ($(".pane", ".lightbox").not(pane).children(":visible").length > 0) {
			$(".pane", ".lightbox").not(pane).children(":visible").fadeOut("fast", function () {
				if ($(".pane", ".lightbox").not(pane).children(":visible").length == 0) {
					$(pane).children().fadeIn("fast", function () {
						//babysiteJScrollPane(pane);
					});
				}
			});
		} else {
			$(pane).children().fadeIn("fast", function () {
				//babysiteJScrollPane(pane);
			});
		}
	}

	//	function babysiteJScrollPane(pane) {
	//		var container = $(".content", pane);
	//		if (container.height() < $("p", container).height()) {
	//			container.data('jsp').reinitialise();
	//		}

	//		// Counteract IE bug where scrollbar occassionally shows up uninvited
	//		if (container.data('jsp') && container.data('jsp').getIsScrollableV() && container.height() >= $("p", container).height()) {
	//			container.data('jsp').destroy();
	//		}
	//	}

	// Carousel shows approximately 3.5 containers at a time.
	// Navigation is always three at a time, but the last item in the list must 
	//	never pass further back than position 3 and the first item in the list
	//	must never pass further forward than position 1.
	var strip = $(".current_artists>ul", ".artist-edition"),
		buttonNext = $(".carousel_nav>.next", ".artist-edition"),
		buttonPrev = $(".carousel_nav>.prev", ".artist-edition"),
		pageSize = 3,
		itemWidth = 250,
		curPos = 0,
		slideAmount = pageSize * itemWidth,
		numItems = strip.children("li").length,
		maxPos = 0,
		minPos = -(itemWidth * (numItems - pageSize));
	minPos = minPos > 0 ? 0 : minPos;

	if (isRTL) {
		curPos = -11750;
		minPos = -11750 + (itemWidth * (numItems - pageSize));
		maxPos = -11750;
		maxPos = maxPos > curPos ? curPos : maxPos;
	}



	if ($(".current_artists>ul", ".artist-edition").children("li").length > 3) {
		$(".carousel_nav div.next").show();
	}

	dep.addEventHandler("AeCarouselNavigate", function (e) {
		var direction = e.arguments["direction"];
		carouselMove(direction);
	});

	// back/forward button event handlers
	$(".carousel_nav>div", ".artist-edition").bind("click", function () {
		carouselMove($(this).attr("class"));
	});

	// Load iframe src here so rest of page does not have to wait for FB
	$("#artist-series-fb-iframe").attr("src", dep.pageParts["artist-edition"].facebookIframeSrc);

	function carouselMove(direction) {
		if (isRTL) {
			var newPos = (direction == "next") ? curPos + slideAmount : curPos - slideAmount;
			if (newPos < maxPos) { newPos = maxPos; }
			if (newPos > minPos) { newPos = minPos; }
		}
		else {
			var newPos = (direction == "next") ? curPos - slideAmount : curPos + slideAmount;
			if (newPos > maxPos) { newPos = maxPos; }
			if (newPos < minPos) { newPos = minPos; }
		}
		strip.animate(
				{ left: newPos + "px" },
				{
					duration: 800,
					easing: "swing",
					complete: function () {
						updateNavButtons();
					}
				}
			);
		curPos = newPos;
	}

	function updateNavButtons() {
		if (curPos == maxPos) {
			buttonPrev.fadeOut("fast");
		} else {
			buttonPrev.fadeIn("fast");
		}
		if (curPos == minPos) {
			buttonNext.fadeOut("fast", function () {
				buttonPrev.addClass("alone");
			});
		} else {
			buttonPrev.removeClass("alone");
			buttonNext.fadeIn("fast", function () {

			});
		}
	}

	// Load and implement jScrollPane
	//	$.getScript(dep.settings["base_root"] + "/modules/artist-edition/jquery.jscrollpane.min.js", function () {
	//		$.getScript(dep.settings["base_root"] + "/modules/artist-edition/jquery.mousewheel.js", function () {
	//			dep.artistEdition.scrollable = $('.pane>.content').jScrollPane({
	//				showArrows: true,
	//				verticalArrowPositions: 'split',
	//				horizontalArrowPositions: 'split'
	//			});
	//		});
	//	});


});
///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: button



/*

dep.addModule("button", function () {
$(function () {
$(".button").live("mouseenter", function (e) {
$(this).toggleClass("over", true);
});

$(".button").live("mouseleave", function (e) {
$(this).toggleClass("over", false);
});
});
});
*////<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
////module id: campaign-hero
dep.addModule("campaign-hero", function () {

	var over = {};
	var tid = {};

	// button fading is buggy in IE8
	var ie8 = ($.browser.msie && $.browser.version.slice(0, 1) == "8");

	$(".rollover, .hero_tooltip", "#campaign_hero_content").bind("mouseenter", function (e) {
		var referenceId = $(this).attr("referenceid");

		over[referenceId] = true;
		clearTimeout(tid[referenceId]);

		// Hide any other open tooltips
		if (ie8) { $(".button", "#campaign_hero_content #" + referenceId + "-tooltip").hide(); }
		$(".hero_tooltip:not(#" + referenceId + "-tooltip)", "#campaign_hero_content").stop().fadeOut("fast");

		// Show this tooltip
		$("#" + referenceId + "-tooltip", "#campaign_hero_content").fadeIn("fast", function () {
			$(this).css({ display: "block", opacity: 1 });
			if (ie8) { $(".button", "#campaign_hero_content #" + referenceId + "-tooltip").show(); }
		});

		// Highlight the label text
		$("#" + referenceId + "-label").addClass("active");
	});

	$(".rollover, .hero_tooltip", "#campaign_hero_content").bind("mouseleave", function (e) {
		var referenceId = $(this).attr("referenceid");

		// delay 500 milliseconds, then hide the tooltip UNLESS over === true
		over[referenceId] = false;
		tid[referenceId] = setTimeout(hideTooltip, 500);

		// Un-highlight the label text
		$("#" + referenceId + "-label").removeClass("active");

		function hideTooltip() {
			if (!over[referenceId]) {
				if (ie8) { $(".button", "#campaign_hero_content #" + referenceId + "-tooltip").hide(); }
				$("#" + referenceId + "-tooltip", "#campaign_hero_content").stop().fadeOut("normal");
			}
		}
	});

	// Persist any querystring values to AoT button
	// ONLY for en-us
	if (window.location.pathname.indexOf("en-us") > 0 && window.location.search.length > 1) {
		var cta = $("#aot-hero-cta-button");
		cta.attr("href", cta.attr("href") + "/en-us/" + window.location.search);
	}

});
///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: link-dropdown



dep.addModule("compatibility-matrix", function () {
	$(".compat_col select").change(function () {
		var selectedVal = $(this).val();
		var selectedCat = $(this).attr("id");
		if (selectedVal.length > 0) {
			$("a.submit_arrow." + selectedCat).removeClass("disabled").attr("id", selectedCat + "_" + selectedVal);
		}

	});

	$("a.submit_arrow").bind("click", function () {
		var $currLink = $(this);

		var currCat = $currLink.attr("id").split("_")[0];
		var currId = $currLink.attr("id").split("_")[1];
		if (!$currLink.hasClass("disabled")) {
			var resultUrl = dep.settings["site_root"] + "/support/compatibility-results?type=" + currCat + "&id=" + currId + "&mode=fragment";
			dep.getFragment(resultUrl, function (data) {
				$("#result-container").html(data, function () {
					dep.initJS();

				});
				dcsMultiTrack('DCS.dcsuri', dep.settings["site_root"] + '/support/compatibility-results/' + currCat, 'WT.dl', '0');
				$(".columns.base_header").hide();
				$(".columns.itemized_features").hide();
			});
		}
		return false;
	});


});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: link-dropdown



dep.addModule("compatibility-results", function () {
	
});
dep.addModule("cookie-message", function () {

    // this can be used to clear the cookie
    //dep.utils.cookie.write("euCookie", "", -1);

    if (!dep.utils.cookie.read("euCookie")) {
        // if we don't have a cookie, then show the message
        $('.module.cookie-message').delay(2000).slideDown();

        $('.cookie-msg-close').click(function (e) {
            // Hide the notification
            $('.module.cookie-message').slideUp();

            // Set cookie for 6 months
            dep.utils.cookie.write("euCookie", "true", 365 / 2);

            // Prevent a link click
            return false;
        });
    }
});
///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
//module id: culture-dropdown

dep.addModule("culture-dropdown", function () {

    $(".culture-dropdown").mouseenter(function (e) {
        var source = $(this).find(".arrow").attr("src").replace("off", "over");
        $(this).find(".arrow").attr("src", source);
        $(this).find(".culture_selected_link").toggleClass("over", true);
        $(".culture_drop_down", this).delay(300).slideDown("fast");
    });

    $(".culture-dropdown").mouseleave(function (e) {
        $(this).find(".culture_selected_link").toggleClass("over", false);
        $(".culture_drop_down").stop(true, true);
        $(".culture_drop_down", this).slideUp("fast");
    });

});



///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
//module id: culture-dropdown2

dep.addModule("culture-dropdown2", function () {

    $(".culture_selected_link").bind("click", function (e) {
        e.stopPropagation();

        //Check if culture drop down is already showing.
        //if ($(this).hasClass("over")) {
        if ($("#CultureFlyoutTarget").hasClass("animated")) {
            hideCultureDropdown();
        }
        else {
            showCultureDropdown();
        }
    });

    $(".close_button").bind("click", function () {
        $(".culture_selected_link").toggleClass("over", false);
        //Hide the culture drop down.
        hideCultureDropdown();
    });

    /* Body click. */
    $("body").bind("click", function () {
        //Check to see if the culture drop down is expanded, and if yes, close it upon body click.
        if ($("#CultureFlyoutTarget").hasClass("animated")) {
            hideCultureDropdown();
        }
    });

    function showCultureDropdown() {
        $(".footer2 .footer_background").fadeIn("fast", function () {
            $("#CultureFlyoutTarget").css("display", "block").addClass("animated").animate({ 'top': '-375px', 'height': '375px' }, cultureDropdown.duration, 'swing', function () {
                cultureDropdown.animating = false;
            });
        });

    }

    //Hide language list.
    function hideCultureDropdown() {
        if ($("#CultureFlyoutTarget").hasClass("animated")) {

            // Don't animating if already animating
            if (cultureDropdown.animating) {
                return;
            }

            cultureDropdown.animating = true;

            // reset language list to original position
            $("#CultureFlyoutTarget").animate({ 'top': '0', 'height': '0' }, cultureDropdown.duration, 'swing', function () {
                $(".footer2 .footer_background").fadeOut("fast");
                $(this).hide();
                $(this).removeClass("animated");
                cultureDropdown.animating = false;
            });
        }
    }

    var cultureDropdown = {
        animating: false,
        duration: 300
    }

});
///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: Expando

dep.addModule("expando", function () {

    dep.addEventHandler("ExpandoClick", function (e) {
        if ($(e.sender).parent().hasClass("clicked")) {
            $(".content", e.sender.parentNode).first().slideToggle("fast", function () {
                $(e.sender).parent().toggleClass("clicked");
            });
        } else {
            $(".content", e.sender.parentNode).first().slideToggle("fast");
            $(e.sender).parent().toggleClass("clicked");
        }
           $(e.sender).find(".trigger_icon").toggle();
        return false;
    });

    dep.addEventHandler("ExpandoClickExternal", function (e) {
    	//Arg1: event handler, arg2: arguments to the event (in this case, none), arg3: sender (in this case, the link).
    	$(".module.expando .content:visible").slideUp("fast", function () {
    		$(this).siblings(".trigger_link").find(".trigger_icon").toggle();
			$(this).parent(".expando").toggleClass("clicked", false);
    	});
		var depEvent = new dep.depEvent("ExpandoClick", "", $("#" + e.arguments["linkId"] + ".trigger_link")[0]);
        dep.eventHandlers["ExpandoClick"](depEvent);
        //Remove this so that it will navigate down to the correct section of the page.
        //return false;
       });

    dep.onPageLoad(function () {
        var hash = dep.utils.getUrlHash();

        if (hash != "") {
            var depEvent = new dep.depEvent("ExpandoClick", "", $("#" + hash + ".trigger_link")[0]);
            dep.eventHandlers["ExpandoClick"](depEvent);
        }
    });

});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: facebook-open-graph */


dep.addModule("facebook-open-graph", function () {

	// Wait to load the Facebook iframe src so that the entire page doesn't have to wait for FB
    $(".facebook-open-graph iframe").attr("src", dep.pageParts["facebook-open-graph"].src);

    if(dep.settings["metro_styles"] && dep.settings["metro_styles"] == "true")
        dep.facebookLikeUpper();

    

});


// Moves the Facebook "Like" iframe from the footer to the top nav
dep.facebookLikeUpper = function () {
    var primaryNav = $(".module.primary_nav2").addClass("facebook_variant");

    // Create FB button
    var fbButton = $("<div/>")
                    .addClass("facebook_button")
                    .append("Like us");

    // Create container for FB icon and iframe in drawer
    var fbNav = $("<li/>")
                    .addClass("item dropdown facebook")
                    .attr("id", "facebook")
                    .append(fbButton)
                    .appendTo(primaryNav);

    // Reposition the FB iframe
    var fb = $(".facebook-open-graph")
                .addClass("primary_nav_dropdown")
                .attr("id", "subnav_wrapper_facebook")
                .appendTo(fbNav)
                .hide();

    // move dropdown to secondary nav area
    $(".facebook-open-graph.primary_nav_dropdown", primaryNav).addClass("subnav_wrapper").appendTo(".module.nav-secondary");
}///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: product-download-detail

dep.addModule("firmware-download-detail", function () {

	
	//on language selection
	$('.language_dropdown').change(function () {
		var newCulture = $(this, 'option:selected').attr("value");
		var path = location.href;
		var pos = path.indexOf("/firmware-update/");
		var start = path.substring(0, pos-5);
		var end = path.substring(pos);
		//alert(start + newCulture + end);
		location.href = start + newCulture + end;
	});

	
});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: form

dep.addModule("form", function () {
    dep.addEventHandler("FormSubmit", function (e) {

        $("#" + e.arguments["formId"]).submit();

        return false;
    });
});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* MODULE: HEADER-SEARCH */

dep.addModule("header-search", function () {
	var defaultValue;
	defaultValue = $("#search-box").attr("value");

	$(function () {
		$("#search-box").focus(function (e) { //user clicks search box
			if (!$(this).hasClass("user_text")) { //if user hasn't previously entered text
				this.value = ""; //remove default text
				$(this).toggleClass("user_text", true);
			}
		});
		$("#search-box").blur(function (e) { //when user clicks outside of search box
			if (this.value == "") { //if they didn't type anything
				this.value = defaultValue; //reset value to default
				$(this).toggleClass("user_text", false);
			}
		});
	});

	//to handle click
	dep.addEventHandler("HeaderSearchSubmit", function (e) {
		$("#form-header-search")[0].onsubmit();
		$("#form-header-search")[0].submit();
		return false;
	});

	// form submit
	$("#form-header-search")[0].onsubmit = function (e) {
		var q = $("#search-box").get(0).value;

		dep.clearTagVars();
		dcsMultiTrack("DCS.dcsuri", "/windowsembedded/searchresults", "WT.ti", "SearchButton: OnSite", "WT.dl", "2", "WT.z_srch_t", q, "DCSext.wtNavigation", "Onsite Search");

		q += " site:microsoft.com" + dep.settings["site_root"];
		$("#search-box-submit").get(0).value = q;

		return true;
	};
});


///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: healthy-computing-tool */

dep.addModule("healthy-computing-tool", function () {

	$("#hctool-begin-keyboards").click(function () {
	    hctool.resetQuestionaireTo("keyboard");
	    setHeading("keyboard");
	});

	$("#hctool-begin-mouse").click(function () {
	    hctool.resetQuestionaireTo("mouse");
	    setHeading("mouse");
	});

	$("#hctool-continue").click(function () {
		hctool.toggleQuestion(false);
	});

	$("#hctool-back").click(function () {
		hctool.toggleQuestion(true);
	});

	$("#hctool-keyboards-start-over").click(function () {
		hctool.resetQuestionaireTo("keyboard");
	});

	$("#hctool-mouse-start-over").click(function () {
		hctool.resetQuestionaireTo("mouse");
	});

	$("#back-to-start").click(function () {
		hctool.backToStartScreen();
	});


	function setHeading(type) {

	    var $h1 = $(".hctool-questions-header h1");
	    var headingText = $h1.attr("data-keyboard-text");

	    if (type == "mouse")
	        headingText = $h1.attr("data-mouse-text");

	    $h1.html(headingText);
	}

	// tab click
	$(".hctool-tabs .header_list .item a").click(function () {


	    var type = $(this).attr("href").substring(1);

	    setHeading(type);
	    

	    // get the new tab's index (not the one that was clicked on)
		var newTabIndex = ($(".hctool-tabs-wrapper .header.selected").index() + 1) == 1 ? 2 : 1;
		var cssPathToTab = ".hctool-tabs-wrapper .tab" + newTabIndex;
		
		// get question that is active in new tab
		var $curQuestion = $(cssPathToTab + " .question.hctool-active-question");
		var $curQuestionIndex = $curQuestion.index();

		// if no question is active, set it to 1st q
		if($curQuestionIndex == -1) {
			hctool.setFirstQuestionActive(cssPathToTab);
		}
		
		// show / hide back button
		// this is important if user switches from keyboard to mice tab
		// the back button needs to be hidden if other tab is still on question one
		// and needs to be shown if on question > 1
		if ($curQuestionIndex > 1)
			hctool.showBackButton();
		else {
			hctool.hideBackButton();
		}

	});

	var hctool = {
		fadeTimePane: "2000",
		fadeTimeObj: "1000",

		saveQuestion: function($question) {

			var $questionsWrapper = $question.parent();

			// get saved answer question delim
			var aqDelim = $($questionsWrapper).attr("data-delim");
			if (typeof aqDelim == 'undefined') {
				aqDelim = "";
			}

			// get list of answers
			var $answers = $("input[type='radio']", $question);
			var answered = false;
			$answers.each(function(i, answer) {
				if (answer.checked) {

					answered = true;

					// save their answer
					aqDelim += $question.attr("id") + "|" + (i + 1);
					if ($question.index() < $(".question", $questionsWrapper).length) {
						aqDelim += "|";
					}

					// append and save to global "variable"
					$($questionsWrapper).attr("data-delim", aqDelim);
				}
			});

			return answered;
		},

		resetQuestionaireTo: function($type) {

			// show / hide some divs
			$(".hctool-tabs-wrapper").fadeIn(hctool.fadeTimePane);
			$(".hctool-columns").hide();
			$(".hctool-utils").fadeIn(hctool.fadeTimePane);
			$(".hctool-results").hide();

			// clear out data from last questionaire
			$(".hctool-tabs-wrapper .questions").attr("data-delim", "");

			// highlight correct tab header
			$(".hctool-tabs-wrapper .tabs .header").removeClass("selected");
			var $tab = $(".hctool-tabs-wrapper .tabs #tab-" + $type).parent().parent();
			$tab.addClass("selected");

			// display correct tab content
			var indexOfContent = $tab.index() + 1;
			$(".hctool-tabs-wrapper .tabs .content").hide();
			var cssPathToTab = ".hctool-tabs-wrapper .tabs .tab" + indexOfContent;
			$(cssPathToTab).show();

			hctool.setFirstQuestionActive(cssPathToTab);

			// reset all the products divs to show
			$(".hctool-product").show();

		},

		toggleQuestion: function(back) {

			// get the current tab's index
			var currTabIndex = $(".hctool-tabs-wrapper .header.selected").index() + 1;
			var cssPathToTab = ".hctool-tabs-wrapper .tab" + currTabIndex;

			var $curQuestion = $(cssPathToTab + " .question.hctool-active-question");

			// is question answered?
			if (!back && hctool.saveQuestion($curQuestion) == false) {
				$(".hctool-error").fadeIn(hctool.fadeTimeObj);
				return false;
			} else {
				$(".hctool-error").fadeOut(hctool.fadeTimeObj);
			}

			// show or hide the next or prev question
			$curQuestion.toggleClass("hctool-active-question");
			if (back) { // back button?

				$curQuestion = $curQuestion.prev();
				hctool.removeQuestionFromDelim($curQuestion);

			} else { // or continue button?

				$curQuestion = $curQuestion.next();

			}
			$curQuestion.toggleClass("hctool-active-question");
			$curQuestionIndex = $curQuestion.index();

			// show / hide back button
			if ($curQuestionIndex > 1) {
				hctool.showBackButton();
			} else {
				hctool.hideBackButton();
			}

			// show or hide the next or prev question's nav item
			var $curQuestionNavItem = $(cssPathToTab + " .question_nav .question_nav_active");
			$curQuestionNavItem.toggleClass("question_nav_active");
			if (back) { // back button?
				$curQuestionNavItem.prev().toggleClass("question_nav_active");
			} else { // or continue button?
				$curQuestionNavItem.next().toggleClass("question_nav_active");
			}

			// curQuestionIndex of -1 means we're at the last question
			if ($curQuestionIndex == -1) {

				var $questions = $(cssPathToTab + " .questions");
				var type = $questions.attr("data-type");

				$(".hctool-tabs-wrapper").hide();
				$(".hctool-utils").hide();
				$(".hctool-results").fadeIn(hctool.fadeTimePane);
				$(".hctool-results-count").text("");

				// need to hide/ show mouse/ keyboard products
				if (type == "keyboard") {
					$(".hctool-results .hctool-product.hctool-mouse").hide();
					$(".hctool-results .hctool-product.hctool-keyboard").show();
				} else {
					$(".hctool-results .hctool-product.hctool-keyboard").hide();
					$(".hctool-results .hctool-product.hctool-mouse").show();
				}

				// make call to tool handler.
				// the handler takes a pipe delimited string => [question id]|[answer_id]
				// and returns a JSON object of product id's to HIDE
				var handlerUrl = "//" + dep.settings["host"] + dep.settings["base_root"] + '/data/healthy-computing-tool.ashx?site_root=' +
					dep.settings["site_root"] + '&delim=' + $questions.attr("data-delim") +
					'&type=' + type;

				var resultsCount = 0;

				handlerUrl = dep.utils.makeUrlUnique(handlerUrl);

				$.getJSON(handlerUrl, function(data) {
					// hide the fids returned
					resultsCount = data["fids"].length;
					$.each(data["fids"], function(i, fid) {
						$(".hctool-results-list #" + fid + ".hctool-product").hide();
					});

				}).done(function() {

					$(".hctool-utils").hide();

					//if (resultsCount == 0) {
					//	hctool.showDefaultProducts(type);
					//	return false;
					//}

					// determine total products showing
					var totalProductsShown = 0;
					$(".hctool-results-list .hctool-product.hctool-" + type).each(function() {
						if ($(this).css('display') != 'none') {
							totalProductsShown++;
						}
					});

					// handle product count messaging
					if (totalProductsShown >= 1) {
						$(".hctool-results-no-results").hide();
						$(".hctool-results-count").text(totalProductsShown);
						$(".hctool-results-count-wrapper").show();
					} else {
						hctool.showDefaultProducts(type);
					}

				});
			}
			return false;
		},

		showDefaultProducts: function (type) {
			//show default products
			$(".hctool-results-list .hctool-product").hide();
			$(".hctool-results-list .hctool-product.default-product.hctool-" + type).show();
			$(".hctool-results-count-wrapper").hide();
			$(".hctool-results-no-results").show();
		},

		removeQuestionFromDelim: function($question) {

			// because the user clicked the back button 
			// we need to remove the previous answer from the data-delim
			var id = $question.attr("id");
			var aqDelim = $($question.parent()).attr("data-delim");

			if (typeof aqDelim != 'undefined') {
				var indexOfId = aqDelim.indexOf(id);
				var aqDelimBefore = aqDelim.substr(0, indexOfId);
				var aqDelimAfter = aqDelim.substr(indexOfId + id.length + 3);

				$($question.parent()).attr("data-delim", aqDelimBefore + aqDelimAfter);
			}
		},

		hideBackButton: function() {
			$("#hctool-back").fadeOut(hctool.fadeTimeObj);
		},

		showBackButton: function() {
			$("#hctool-back").fadeIn(hctool.fadeTimeObj);
		},

		setFirstQuestionActive: function(cssPathToTab) {
			// remove active classes
			$(cssPathToTab + " .question_nav li").removeClass("question_nav_active");
			$(cssPathToTab + " .question").removeClass("hctool-active-question");

			// display first question
			$(cssPathToTab + " .question_nav li:first-child").toggleClass("question_nav_active");
			$(cssPathToTab + " .question_1").toggleClass("hctool-active-question");
		},

		backToStartScreen: function () {
			$(".hctool-tabs-wrapper").fadeOut(hctool.fadeTimePane, function () {
				$(".hctool-utils").fadeOut(hctool.fadeTimePane, function () {
					$(".hctool-columns").fadeIn(hctool.fadeTimePane);
				});
			});
		}
	};
});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
////module id: hero-selector
dep.addModule("hero-rotator", function () {

    // commented out because whole hero click doesn't work when there are two CTAs.
    // turn this back on when Windows 8 video hero is over.
    //$(".module.hero-rotator .hero").click(function (e) {
    //    window.location = $(this).attr("data-url");
    //});


    dep.addEventHandler("HeroRotatorArrowClick", function (e) {
        try{
            if (!hr.animating) {
                hr.animating = true;
                hr.reset();

                var q = ".hero-rotator .hero.current";

                // get current
                var current = $(q).get(0);
                var next = null;

                // get next
                if ($(e.sender).is(".left")) {
                    next = $(q).prev().get(0);
                    if ($(q).prev().length == 0)
                        next = $(".hero-rotator div.hero:last-child").get(0);
                }
                else {
                    next = $(q).next().get(0);
                    if ($(q).next().length == 0)
                        next = $(".hero-rotator div.hero:first-child").get(0);
                }

                // play animations
                hr.playOut(current);
                hr.playIn(next);
            }
        } catch(er){}

        return false;

    });

    dep.addEventHandler("HeroRotatorDotClick", function (e) {
        if (!hr.animating) {
            hr.animating = true;
            hr.reset();

            var current = $(".hero-rotator .hero.current").get(0);
            var next = $(".hero-rotator div." + e.arguments["class"]).get(0);

            if (current != next) {
                hr.playOut(current);
                hr.playIn(next);
            }
        }

        return false;
    });

    dep.addEventHandler("HeroRotatorPause", function (e) {
        if (!hr.animating) {
            var q = ".hero-rotator .controls .toggle";
            if ($(q).attr("src").indexOf("pause") > 0) {
                $(q).attr("src", $(q).attr("src").replace("pause", "play"));
                hr.pause();
            }
            else {
                $(q).attr("src", $(q).attr("src").replace("play", "pause"));
                dep.eventHandlers['HeroRotatorArrowClick']($('.hero-rotator .arrow.left').get(0));
                hr.start();
            }
        }
        return false;
    });

    $(".hero-rotator").live("mouseenter", function () {
        $(".arrow", this).fadeIn("fast");

    });

    $(".hero-rotator").live("mouseleave", function () {
        $(".arrow", this).fadeOut("fast");
    });

    if ($(".module.hero-rotator .hero").length > 1)
        hr.start();


});


var hr = {
    resetLeft: "935px",
    interval: null,
    animating: false,
    paused: false,

    start: function () {
        hr.interval = setInterval("dep.eventHandlers['HeroRotatorArrowClick']($('.hero-rotator .arrow.left').get(0));", 8000);
        hr.paused = false;
    },

    reset: function () {
        clearInterval(hr.interval);
        if(!hr.paused)
            hr.start();
    },

    pause: function () {
        clearInterval(hr.interval);
        hr.paused = true;
    },

    updateDots: function (index) {
        var q = null;
        q = ".hero-rotator .controls > a img[class!='toggle']'";
        $(q).attr("src", $(q).attr("src").replace("red", "grey"));

        q = ".hero-rotator .controls > a";
        $(q).toggleClass("current", false);

        $($(q)[index]).toggleClass("current", true);

        $("img", $(q)[index]).attr("src", $("img", $(q)[index]).attr("src").replace("grey", "red"));

    },

    playIn: function (hero) {

        $(hero).show();

        var index = $(hero).index();

        $(".background", hero).delay(100).animate({
            left: "-=25px",
            opacity: "show"
        }, 1500, "swing", function () {

        });

        var contentPos = $(".content", hero).position().left - $(".content", hero).attr("position");

        $(".content", hero).delay(300).animate({
            left: "-=" + contentPos + "px"
        }, 800, "swing", function () {

        });

        var ctaPos = $(".cta", hero).position().left - $(".cta", hero).attr("position");
        $(".cta", hero).delay(400).animate({
            left: "-=" + ctaPos + "px"
        }, 800, "swing", function () {

            hr.updateDots(index);
            $(hero).toggleClass("current", true);
            hr.animating = false;

        });
    },

    playOut: function (hero) {
        var contentPos = $(".content", hero).width() + $(".content", hero).position().left;
        $(".content", hero).animate({
            left: "-=" + contentPos + "px"
        }, 1000, "swing", function () {
            $(".content", hero).css("left", hr.resetLeft);
        });

        var ctaPos = $(".cta", hero).width() + $(".cta", hero).position().left;
        $(".cta", hero).delay(100).animate({
            left: "-=" + ctaPos + "px"
        }, 1000, "swing", function () {
            $(".cta", hero).css("left", hr.resetLeft);

        });

        $(".background", hero).delay(0).animate({
            left: "-=25px",
            opacity: "hide"
        }, 1500, "swing", function () {
            $(".background", hero).css("left", "0px");
            $(hero).hide();
        });
        $(hero).toggleClass("current", false);

    }

}///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: iframe



dep.addModule("iframe", function () {
	$(document).ready(function () {
		$('.module.iframe a#open').click(function () {
			var currId = $(this).parent().attr("id");
			iframeBuild(currId);
		});
		$('.module.iframe a#close').click(function () {
			var currId = $(this).parent().attr("id");
			iframeRemove(currId);
		});
	});

	function iframeBuild(iframeId) {
		var frameloc = $('.module.iframe#' + iframeId);
		var iframesrc = frameloc.children('#iframe-src').attr('class');
		var iframeidentifier = frameloc.children('#iframe-id').attr('class');
		var iframename = frameloc.children('#iframe-name').attr('class');
		var iframeclass = frameloc.children('#iframe-class').attr('class');
		var iframeframeborder = frameloc.children('#iframe-frameborder').attr('class');
		var iframescrolling = frameloc.children('#iframe-scrolling').attr('class');
		var iframeheight = frameloc.children('#iframe-height').attr('class');
		var iframewidth = frameloc.children('#iframe-width').attr('class');
		$('.module.iframe#' + iframeId).append('<iframe width="' + iframewidth + '" height="' + iframeheight + '" scrolling="' + iframescrolling + '" frameborder="' + iframeframeborder + '" class="' + iframeclass + '" id="' + iframeidentifier + '" name="' + iframename + '" src="' + iframesrc + '" />');
	}

	function iframeRemove(iframeId) {
		$('.module.iframe#' + iframeId + ' iframe').remove();
	}
});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: iframe-static

dep.iframeStatic = {};

/// This function expects that there is only one iframe on the page.
dep.iframeStatic.changeSrc = function () {
	if (location.search) {
		var qs = location.search.substr(1).split("&");
		$.each(qs, function () {
			var nvp = this.split("=");
			if (nvp[0] == "iframesrc" && nvp[1] && nvp[1].length > 0) {
				dep.iframeStatic.src = nvp[1];

				// Hide the iframe until the dep.settings object is available
				$(".iframe-static iframe").attr("src", "about:blank").css("visibility", "hidden");
			}
		});
	}
}

dep.addModule("iframe-static", function () {
	$(document).ready(function () {
		if (dep.iframeStatic.src) {
			var host = dep.iframeStatic.host || dep.settings["host"];
			var src = "//" + host + dep.iframeStatic.src;
			$(".iframe-static iframe").attr("src", src).css("visibility", "visible");
		}
	});
});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: lightbox */


dep.addModule("lightbox", function () {

    dep.addEventHandler("LightboxClose", function (e) {
    	dep.clearTagVars();
		zbox.getVisibleBox().hide();
        return false;
    });

    dep.addEventHandler("ShowLightbox", function (e) {
        
        var lightboxId = e.arguments["lightboxId"];

        // check if it already exists. if it doesn't then go get it.
        if (typeof (zbox.getBox(lightboxId)) == "undefined") {
            var url = dep.utils.appendQueryString(e.sender.href, "mode=fragment");

            dep.getFragment(url, function () {
                if (e.arguments["fragmentId"] != null)
                    $("#" + e.arguments["fragmentId"]).html(data);
                else
                    $("#lightbox-content").html(data);
            });
        }

        zbox.getBox(lightboxId).show();     

        return false;
    });

});



var zbox = {
    boxes: [],
    tagsToHide: ["select", "embed"],
    backgroundDivId: "zBox_bg",
    iE6BackgroundOpacity: "80",
    boxDelay: 150,

    createBox: function (id, show) {
        if (typeof (show) == "undefined")
            show = false;

        if (id != "" & typeof (zbox.getBox(id)) == "undefined") {
            zbox.boxes.push(new zbox.box(id, show));
        }

        return zbox.getBox(id);
    },

    getBox: function (id) {
        for (var i = 0; i < zbox.boxes.length; i++) {
            if (zbox.boxes[i].id == id)
                return zbox.boxes[i];
        }

        //return null;
    },

    getVisibleBox: function () {
        for (var i = 0; i < zbox.boxes.length; i++) {
            if (zbox.boxes[i].state == "visible")
                return zbox.boxes[i];
        }
    },

    hideAll: function (box) {
        for (var i = 0; i < zbox.boxes.length; i++) {
            if (zbox.boxes[i].id != box.id)
                zbox.boxes[i].hide();
        }
    },

    toggleTags: function (tagName, hide, box) {
        var tags = document.getElementsByTagName(tagName);
        for (var i = 0; i < tags.length; i++) {
            if (!zbox.isInsideBox(tags[i], box)) {
                if (hide)
                    tags[i].style.visibility = 'hidden';
                else
                    tags[i].style.visibility = 'visible';
            }
        }
    },

    restorePage: function () {
        for (var i = 0; i < zbox.tagsToHide.length; i++) {
            zbox.toggleTags(zbox.tagsToHide[i], false, null);
        }

        $(zbox.getBackground()).delay(zbox.boxDelay).fadeOut();
    },


    preparePage: function (box, nobg) {
        // hide any box that might be showing
        zbox.hideAll(box);

        // hide incompatible tags
        for (var i = 0; i < zbox.tagsToHide.length; i++) {
            zbox.toggleTags(zbox.tagsToHide[i], true, box);
        }

        // set up and position the background
        var bg = zbox.getBackground();
        var bgHeight = 0;
        var bgWidth = 0;

        if (window.innerHeight) {
            bgHeight = window.innerHeight;
            bgWidth = window.innerWidth;
        }
        else {
            bgHeight = document.documentElement.clientHeight;
            bgWidth = document.documentElement.clientWidth;
        }

        if (zbox.isIE6) {
            bg.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + zbox.iE6BackgroundOpacity + ")";

            if (bgHeight < document.documentElement.scrollHeight)
                bgHeight = document.documentElement.scrollHeight;

            bgWidth = document.documentElement.scrollWidth;
        }

        bg.style.height = Math.round(bgHeight) + "px";
        bg.style.width = Math.round(bgWidth) + "px";

        if (typeof (nobg) == "undefined" || nobg == false)
            $(bg).fadeIn("fast");

    },

    getBackground: function () {
        var bg = document.getElementById(zbox.backgroundDivId);

        if (!bg) {
            bg = document.createElement("div");
            bg.id = zbox.backgroundDivId;

            bg.style.display = "none";
            document.body.appendChild(bg);
        }

        return bg;
    },

    isInsideBox: function (node, box) {
        if (node.tagName != "BODY") {
            if (box && (node.id == box.ID))
                return true;
            else
                return zbox.isInsideBox(node.parentNode, box);
        }

        return false;
    },


    resetVisibleBox: function () {
        var box = zbox.getVisibleBox();
        if (box) {
            box.positionBox();
            zbox.preparePage(box);
        }
    },

    utils: {
        getScrollPos: function () {
            var docElem = document.documentElement;
            return {
                scrollX: document.body.scrollLeft || window.pageXOffset || (docElem && docElem.scrollLeft),
                scrollY: document.body.scrollTop || window.pageYOffset || (docElem && docElem.scrollTop)
            };
        },

        getPageSize: function () {
            return {
                width: window.innerWidth || (document.documentElement && document.documentElement.clientWidth) || document.body.clientWidth,
                height: window.innerHeight || (document.documentElement && document.documentElement.clientHeight) || document.body.clientHeight
            };
        },

        getElementSize: function (obj) {
            return {
                width: obj.offsetWidth || obj.style.pixelWidth,
                height: obj.offsetHeight || obj.style.pixelHeight
            };
        }
    },


    isIE6: /msie|MSIE 6/.test(navigator.userAgent),

    setEvents: function (enable) {
        if (enable) {
            if (zbox.isIE6) {
                window.onscroll = zbox.resetVisibleBox;
            }
            else {
                window.onresize = zbox.resetVisibleBox;
            }

            document.onkeydown = zbox.keyPress;
            document.onclick = zbox.bodyClick;
        }
    },

    keyPress: function (e) {
        if (!e) var e = window.event;

        if (e.keyCode == 27)
            zbox.getVisibleBox().hide();

    },

    bodyClick: function (e) {
        if (!e) {
            var e = window.event;
            if (e.srcElement.id == zbox.backgroundDivId)
                zbox.getVisibleBox().hide();
        }
        else if (e.originalTarget) {
            if (e.originalTarget.id == zbox.backgroundDivId)
                zbox.getVisibleBox().hide();
        }
        else {
            if (e.target.id == zbox.backgroundDivId)
                zbox.getVisibleBox().hide();
        }
    },

    event: function () {
        this.handlers = [];

        this.addHandler = function (handler) {
            this.handlers.push(handler);
        }

        this.execute = function (args) {
            for (var i = 0; i < this.handlers.length; i++)
            { this.handlers[i](args); }
        }
    },


    //box object
    box: function (id, show) {
        this.id = id;
        this.div = document.body.appendChild(document.getElementById("zbox-" + this.id));
        this.state = "";
        this.top = 0;
        this.left = 0;
        this.onBeforeShow = new zbox.event();
        this.onShow = new zbox.event();
        this.onBeforeHide = new zbox.event();
        this.onHide = new zbox.event();
        this.div.style.display = "block";
        if (show)
            this.show();


        this.show = function () {
            this.onBeforeShow.execute();           
            
            zbox.setEvents(true);
            zbox.preparePage(this);

            this.positionBox();

            this.div.style.display = "none";
            this.div.style.visibility = "visible";
            $(this.div).delay(zbox.boxDelay).fadeIn("fast", function () {
            	$(':focus').blur();
            	$(" a.lightbox_close", this).focus();
            });

            this.state = "visible";
            this.onShow.execute();

            //this.div.id = "";

            //this.div.attributes.removeNamedItem("id");
            
            window.location.hash = this.id;
        }

        this.positionBox = function () {

            var pageSize = zbox.utils.getPageSize();
            var scrollPos = zbox.utils.getScrollPos();
            var emSize = zbox.utils.getElementSize(this.div);

            this.left = Math.round((pageSize.width - emSize.width) / 2);
            this.top = Math.round(((pageSize.height - emSize.height) / 2) + scrollPos.scrollY);

            if (zbox.isIE6) {
                var temp = document.documentElement.clientHeight - emSize.height;
                this.top = scrollPos.scrollY + (temp / 2);
            }

            if (this.top < 0)
                this.top = 5;

            if (this.left < 0)
                this.left = 5;

            this.div.style.left = this.left + 'px';
            this.div.style.top = this.top + 'px';
           
        }

        this.prepareBox = function () {

        }

        this.hide = function () {
            //only attempt to hide the box if it's already visible
            if (this.state == "visible") {
                this.onBeforeHide.execute();
                if ("pushState" in history) history.pushState("", document.title, window.location.pathname); else window.location.hash = "n";
                //this.div.id = this.id;
                var test = $(this.div);
                $(this.div).fadeOut("fast", function () { $(test).css("visibility", "hidden"); $(test).css("display", "block"); })
                this.state = "hidden";
                zbox.restorePage();
                this.onHide.execute();                
            }
        }

        this.getChildDiv = function (id) {
            var divs = this.div.getElementsByTagName("div");
            for (var i = 0; i < divs.length; i++) {
                if (divs[i].id == id)
                    return divs[i];
            }

            return null;
        }

    }

}///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: link-dropdown



dep.addModule("link-dropdown", function () {
    $('.link-dropdown select').live("change", function () {

        var item = this.options[this.options.selectedIndex];
        if (item.attributes.getNamedItem("depevents")) {
            dep.fireEvents(item.attributes.getNamedItem("depevents").value);
        }

        if (item.attributes.getNamedItem("href").value.length > 0) {
            window.location = item.attributes.getNamedItem("href").value;
        }


    });



    //    function expandAndNavigate(currLinkID, loc) {
    //        location = loc;
    //        window.scrollBy(0, -30);
    //        $(".module.expando .content:visible").slideUp("fast", function () {
    //            $(this).siblings(".trigger_link").find(".trigger_icon").toggle();
    //            $(this).parent(".expando").toggleClass("clicked", false);
    //        });

    //        var depEvent = new dep.depEvent("ExpandoClick", "", $(".module.expando#" + currLinkID + " .trigger_link")[0]);
    //        dep.eventHandlers["ExpandoClick"](depEvent);
    //    }
});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: nav-primary */

//nav item mouse events
dep.addModule("nav-primary", function () {

	var currentParent;
	var focusedItem = false;

	$(".item").bind("mouseenter", function (e) {
		var thisItem = addUniqueClass($(this));
		if (thisItem.attr("class").indexOf("selected") < 0 | thisItem.find(".primary_nav_dropdown").length > 0) {
			menuDown(thisItem);
		}
	});

	$(".item").bind("mouseleave", menuUp);

	$("a", ".primary_nav").bind("focusin", function (e) {
		var thisParent = addUniqueClass($(e.target).parents(".item").get());
		focusedItem = true;

		if (currentParent) {
			if (thisParent.data("uniqueClass") != currentParent.data("uniqueClass")) {
				menuUp();
				menuDown(thisParent);
			}
		} else {
			menuDown(thisParent);
		}
	});

	/// Wait a short time; if focus has left the nav entirely, hide any active menus
	$("a", ".primary_nav").bind("focusout", function (e) {
		focusedItem = false;
		setTimeout(function () {
			if (!focusedItem) {
				menuUp();
				currentParent = null;
			}
		}, 100);
	});

	/// Raises the currently active menu
	function menuUp() {
		var dropdown = currentParent.find(".primary_nav_dropdown");
		dropdown.stop(true, true);
		dropdown.slideUp("fast");
		currentParent.removeClass("over", false);
	}

	/// Expects a jQuery object of the parent LI with addUniqueClass applied
	function menuDown(elm) {
		currentParent = elm;
		elm.addClass("over", true);
		elm.find(".primary_nav_dropdown").delay(180).slideDown("fast");
	}

	/// Adds a data item uniquely identifying the item on the nav
	function addUniqueClass(elm) {
		elm = $(elm);
		var uniqueClass = elm.clone().removeClass("over selected item dropdown").attr("class");
		return elm.data("uniqueClass", uniqueClass);
	}
});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: nav-primary2 */

//nav item mouse events
dep.addModule("nav-primary2", function () {
    var currentSubnav;

    $(".module.primary_nav2 li.item").bind("click", function (e) {
        e.stopPropagation();

        var $itemClicked = $(this);
        //Remove clicked class from all unclicked items.
        $(".module.primary_nav2 li.item").each(function () {
            if ($(this).get(0) != $itemClicked.get(0)) {
                $(this).removeClass("clicked");
            }
        });
        //Toggle clicked class for current item clicked.
        $itemClicked.toggleClass("clicked");

        var $subnavUsing = $("#subnav_wrapper_" + $itemClicked.attr("id"));
        //Hide all the other subnavs.
        $(".module.nav-secondary .subnav_wrapper").each(function () {
            if ($(this).get(0) != $subnavUsing.get(0) || $subnavUsing.hasClass("over")) {
                menuUp($(this));
            }
            else {
                menuDown($subnavUsing);
            }
        });
    });

    /* Body click. */
    $("body").bind("click", function () {
        //Check to see if any subnavs are expanded, and if yes, close them upon body click.
        if ($(".nav-secondary .subnav_wrapper").hasClass("over")) {
            menuUp($(".nav-secondary .subnav_wrapper"), function () {
                $(".module.primary_nav2 li.item").each(function () {
                    $(this).removeClass("clicked");
                });
            });            
        }
    });

    /// Expects a jQuery object of the subnav to show.
    function menuDown(elm, fn) {
        currentSubnav = elm;
        elm.addClass("over", true);
        elm.stop(true, true);
        elm.slideDown("fast", fn);
    }

    /// Raises the currently active menu
    function menuUp(elmt, fn) {
        elmt.removeClass("over");
        elmt.stop(true, true);
        elmt.slideUp("fast", fn);
    }

    /// Adds a data item uniquely identifying the item on the nav
    function addUniqueClass(elm) {
        elm = $(elm);
        var uniqueClass = elm.clone().removeClass("over selected item dropdown").attr("class");
        return elm.data("uniqueClass", uniqueClass);
    }
});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: product-business-detail-details */


dep.addModule("product-business-detail-details", function () {

	$('a.hideshowlink').click(function (e) {
		e.preventDefault();
		//$('a.hideshowlink').fadeToggle('fast'); could replace the if/else, but has graphical bug
		$('.features_additional').slideToggle("slow");
		if ($(this).parent().attr("id") == "button-hide-features") {
			$('#button-hide-features').fadeOut('fast', function () {
				$('#button-show-features').fadeIn('fast');
			});
		} else {
			$('#button-show-features').fadeOut('fast', function () {
				$('#button-hide-features').fadeIn('fast');
			});
		}
	});

	$('a.toggle_os_link').click(function (e) {
		e.preventDefault();
		if (!$(this).hasClass("selected")) {
			var currOS = $(this).attr("id");
			$('.requirements .operating_system').hide(1, function () {
				$('.requirements .operating_system.' + currOS).show(1);
			});
			$('a.toggle_os_link').attr("class", "toggle_os_link");
			$(this).addClass("selected");
		}
	});
});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: product-business-detail-hero */

dep.addModule("product-business-detail-hero", function () {
    $('.product-business-detail-hero .color_selector img').click(function (event) {
        var colorID = $(this).parent().attr('id');
        $('#color-selector .color_select#' + colorID).click(); //change lightbox image       
    });
});
///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: product-business-detail-overview */

///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: product-business-image-gallery */

dep.addModule("product-business-image-gallery", function () {

	//click event for thumbnails
	$('.product-business-image-gallery #thumbNailSelector img').click(function (event) {
		$('#thumbNailSelector img').toggleClass("selected", false);
		$(this).toggleClass("selected", true);
		$('.product-business-image-gallery .primary_display img').attr('src', $(this).attr('src').replace('_sm.', '.')); //replace main image with clicked thumbnail
	});

	// click for PDP hero thumbnails
	$('.product-business-image-gallery #imageGalleryLinkContainer img').click(function (event) {
		//dep.fireEvents("WebTrendsSetVar[WT.z_ea_name|wireless-mobile-mouse-4000-limited-edition|WT.z_ea_actionoffer|" + $(this).attr("data-product-type") + "]", this);
		dep.fireEvents("ShowLightbox[lightboxId|product-image-gallery]", this);
		var num = $(this).attr("class").replace("thumbnails", "").replace("selected", "").trim();
		$("." + num, "#thumbNailSelector").trigger("click");
	});


	//click event for color icons
	$('.product-business-image-gallery #color-selector .color_select').click(function (event) {

		var currSku = $('.color_data', this).attr("id");
		var imgs = getSKUImages(currSku);

		//find view index from selected thumbnail
		var currentViewIndex = "01";
		if ($('.product-business-image-gallery #thumbNailSelector img').hasClass('selected')) {
			currentViewIndex = $('.product-business-image-gallery #thumbNailSelector img.selected').attr('class').replace(" selected", "").replace("thumbnails ", "").trim();
			if (parseInt(currentViewIndex, 10) > parseInt(imgs.otherViewsCount, 10)) {
				//if view index D.N.E. for new color, default to view index 01
				currentViewIndex = "01";
			}
		}

		//replaces main image with new color, same view as before
		$('.product-business-image-gallery #mainImage').attr('src', imgs.otherviews + "_otherviews" + currentViewIndex + ".jpg");

		// Update thumbnails to be the current color
		$("img", "#thumbNailSelector, #imageGalleryLinkContainer").each(function (i) {
			var idx = $(this).clone().removeClass("thumbnails selected").attr("class");
			var src = imgs.otherviews + "_otherviews" + idx + "_sm.jpg";
			$(this).attr("src", src);
		});

		//call bind() method for new dom element click event on thumbnail list
		$('.product-business-image-gallery #thumbNailSelector img').bind('click', function () {
			$('.product-business-image-gallery #thumbNailSelector img').toggleClass("selected", false);
			$(this).toggleClass("selected", true);
			$('#mainImage').attr('src', $(this).attr('src').replace('_sm', ''));
		});

		//persisting color change on rest of page
		$('.product-business-detail-details .figure img').attr('src', imgs.feature);
		$('.product-business-detail-overview .figure img').attr('src', imgs.detail);

		// Update the Shop Now button per color as necessary
		var isComingSoon = ($("img", this).attr("comingSoon") == "true"); // show coming soon button
		var isDisabled = ($("img", this).attr("disableShopUrl") == "true"); // hide button
		var changeUrl = $("img", this).attr("shopUrl"); // update URL per color
		//dep.UpdateShopNowButton(isComingSoon, isDisabled, changeUrl);

		$('#defaultImage').attr('src', imgs.large);

		$('.sku span').html(currSku);

	});


});

function getSKUImages(sku) {

	for (var i in skuImages) {

		if (skuImages[i].sku == sku)
			return skuImages[i];

	}


}///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>

dep.addModule("product-business-quick-view", function () {

    var temp = "";

    $(".color_icon").live("mouseover", function () {
    	temp = $(".figure img", $(this).parents(".product-business-quick-view")).attr("src");
    	$(".figure img", $(this).parents(".product-business-quick-view")).attr("src", this.id);
    });

    $(".color_icon").live("mouseout", function () {
    	$(".figure img", $(this).parents(".product-business-quick-view")).attr("src", temp);
    });

});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: product-compare */

dep.addModule("product-compare", function () {
    $(function () {

        $(".features tr:odd").addClass("oddrow");

        $("img[class='info_icon']").mouseenter(function (event) {
            var oPos = $(this).position();
            var oTitle = "<div class='bold'>" + $(this).siblings('.detail_title').html() + "</div>";
            var oString = oTitle + $(this).siblings('.detail_content').html();
            $('.details').html(oString).fadeIn(500).css({ top: (oPos.top + 20), left: (oPos.left + 25), display: 'block' });
        });

        $("img[class='info_icon']").mouseleave(function (event) {
            $(".details").hide();
        });
    });
});
 
 

///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: product-detail-details */


dep.addModule("product-detail-details", function () {

	$('a.hideshowlink').click(function (e) {
		e.preventDefault();
		var $button = $(this).parent();

		$button.parents(".features_toggle").siblings('.features_additional').slideToggle("slow", function () {
		    
		    $button.hide();

		    if ($button.attr("id") == "button-hide-features")
		        $button.siblings('#button-show-features').show();
		    else
		        $button.siblings('#button-hide-features').show();
		});
	});

	$('a.toggle_os_link').click(function (e) {
		e.preventDefault();
		if (!$(this).hasClass("selected")) {
			var currOS = $(this).attr("id");
			$('.requirements .operating_system').hide(1, function () {
				$('.requirements .operating_system.' + currOS).show(1);
			});
			$('a.toggle_os_link').attr("class", "toggle_os_link");
			$(this).addClass("selected");
		}
	});

	$("#paragraphLinkToDetails").click(function (event) {
		$("#tab-details").trigger("click");
	});
});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: product-detail-hero */

dep.addModule("product-detail-hero", function () {
	$('.product-detail-hero .color_selector img').click(function (event) {
		var colorID = $(this).parent().attr('id').substr("color-icon-container-".length);
		$('#color-selector #' + colorID).click(); //change lightbox image       
	});
});
///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: product-detail-overview */

///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: product-download-detail

dep.addModule("product-download-detail", function () {

    //reset selections on page refresh
    $('.product-download-detail select option[selected]').removeAttr("selected");
    $(".product-download-detail select option.default_select").attr('selected', 'selected');


    //on language selection - documents
    $('.product-download-detail .documents .language_dropdown').change(function () {
        var newCulture = $(this, 'option:selected').attr("value");
        $('.product-download-detail .documents .item_set').fadeOut("fast");
        $('.product-download-detail .documents .item_set#' + newCulture).delay("fast").fadeIn("fast");
    });

    //on language selection - software
    $('.product-download-detail .software .language_dropdown').change(function () {
        var newCulture = $(this, 'option:selected').attr("value");
        $('.software .file_download').fadeOut("fast");
        $(this).closest('.software').find('.file_download.' + newCulture).delay("fast").fadeIn("fast");
    });

    //on operating system selection
    $('.product-download-detail .os_selection').change(function () {
        var newSystem = $(this, 'option:selected').attr("value");
        $('.product-download-detail .software').fadeOut("fast");
        if (newSystem != 'selectText') {
            $('.product-download-detail .software#' + newSystem).delay("fast").fadeIn("fast");
        }
    });

    $(document).ready(function () {

        function is64bit(ua) {
            if (ua.indexOf("win64") != -1 | ua.indexOf("x64") != -1 | ua.indexOf("wow64") != -1)
                return true;
            else
                return false;
        }

        var ua = navigator.userAgent.toLowerCase();
        var os = "";

        if (ua.indexOf("mac os x") != -1) {
            os = "mac104x57";
        }
        else if (ua.indexOf("windows nt 6.0") != -1) {
            //vista
            if (is64bit(ua)) {
                os = "WVista_64";
            }
            else {
                os = "WVista_32";
            }
        } else if (ua.indexOf("windows nt 6.1") != -1) {
            //windows 7
            if (is64bit(ua)) {
                os = "Win7_64";
            }
            else {
                os = "Win7_32";
            }
        } else if (ua.indexOf("windows nt 6.2") != -1 | ua.indexOf("windows nt 6.3") != -1) {
            //windows 8
            if (is64bit(ua)) {
                os = "Win8_64"
            }
            else {
                os = "Win8_32"
            }
        } else if (ua.indexOf("windows nt 5.1") != -1) {
            //windows XP
            if (is64bit(ua)) {
                os = "XP_64"
            }
            else {
                os = "XP_32"
            }
        }

        // a couple exeptions...some products have 32/64 combined
        if ((os == "Win8_64" | os == "Win8_32") & $(".os_selection option[value='Win8_3264']").length > 0)
            os = "Win8_3264";

        if ((os == "Win7_64" | os == "Win7_32") & $(".os_selection option[value='Win7_3264']").length > 0)
            os = "Win7_3264";

        if ((os == "WVista_64" | os == "WVista_32") & $(".os_selection option[value='WVista_3264']").length > 0)
            os = "WVista_3264";


        if ($(".os_selection option[value='" + os + "']").length > 0) {
            $(".os_selection").val(os);
            $(".os_selection").addClass("default_select");
            $('.product-download-detail .os_selection').trigger("change");
        }

    });


});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: product-download-landing

dep.addModule("product-download-filter", function () {

	///PAGE SETUP
	var products = [];
	var catContainers = {};
	var searchText = $(".current_searchText");
	var selectedCat = "";
	var inputText = $("#download-filter-text").val("");
	var inputCat = $("#download-filter-category").val("");

	//	Create a global JSON object to hold all items
	//		Properties:
	//			.productText	For plain-text lookups
	//			.productCat		For category filtering
	//			.elm			The actual DOM element
	$(".product_type").each(function () {
		var me = $(this);
		var cat = me.attr("data-category");

		catContainers[cat] = me;

		me.find(".support_link").each(function () {
			p = $(this);
			products.push({
				productText: p.text(),
				productCat: cat,
				elm: p
			});
		});
	});

	///KEYUP HANDLER
	inputText.bind("keyup", textSearch);
	function textSearch() {
		var txt = inputText.val().trim().toLowerCase();

		// Search Text display
		if (txt.length > 0) {
			searchText.show();
			$(".current_searchTextQuery").text(txt);
		} else {
			searchText.hide();
		}

		// Reset category visibility
		$.each(catContainers, function () {
			this.hide();
		});

		// Show/hide individual products
		$.each(products, function () {
			var productText = this.productText.toLowerCase();
			if (
				(txt.length == 0 || productText.indexOf(txt) > -1) &&
				(selectedCat == "" || selectedCat == this.productCat)
			) {
				this.elm.show();
				catContainers[this.productCat].show();
			} else {
				this.elm.hide();
			}
		});
	}

	///CATEGORY CHANGE HANDLER
	inputCat.bind("change", function () {
		var selected = $("option:selected", this);
		selectedCat = selected.val();
		$(".current_filter").text(selected.text());
		textSearch();
	});
});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: product-download-landing

dep.addModule("product-download-landing", function () {

	var hash = window.location.hash;
	if (hash.length > 0) {
		hash = hash.substring(1).toLowerCase();
		if (hash.indexOf("keyboard") > -1) {
			hash = "keyboard";
		} else if (hash.indexOf("desktop") > -1) {
			hash = "desktop";
		} else if (hash.indexOf("gaming") > -1) {
			hash = "gaming";
		} else if (hash.indexOf("webcam") > -1) {
			hash = "webcam";
		} else if (hash.indexOf("headset") > -1) {
			hash = "headset";
		} else if (hash.indexOf("other") > -1) {
			hash = "other";
		} else {
			hash = "mouse";
		}
	} else {
		hash = "mouse";
	}
	setActiveTab(hash, true);

	$('.product-download-landing .category a').click(function (e) {
		if (!$(this).hasClass("selected")) {
			$('.product-download-landing .category a').toggleClass("selected", false);
			setActiveTab($(this).attr('class'), false);
			$(this).toggleClass("selected", true);
		}
		return false;
	});

	function setActiveTab(tabID, pageLoad) {
		var tabContentID = "product-" + tabID;
		if (pageLoad) {
			$(".product-download-landing .category a").toggleClass("selected", false);
			$('.product-download-landing .product_type#' + tabContentID).show();
			$('.product-download-landing .category a.' + tabID).toggleClass("selected", true);
		} else {
			$('.product-download-landing .product_type:visible').fadeOut('fast', function () {
				$('.product-download-landing .product_type#' + tabContentID).fadeIn('fast');
			});

			window.location.hash = "#" + tabID;
		}
	}
});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>

/* module: product-feature-selector */

dep.addModule("product-filter", function () {

	//does not run when fragment is loaded with AJAX
	$(".product-filter input[type=checkbox]").removeAttr('checked');
	$(".product-filter input[type=radio]").removeAttr("checked");
	$(".product-filter a.selected input[type=radio]").attr("checked", true);
	$(".product-filter a.selected input[type=checkbox]").attr("checked", true);

	onLoadOfContent(true);

	function onLoadOfFilter() {
		var productType = $('#filter-input').attr("class");

		$(".filtergroup .features_header").click(function (e) {
			var filterType = $(this).parent().attr('id');
			if ($('#' + filterType + ' .feature_items').is(':visible')) {
				$(this).removeClass('open').addClass('closed');
				$('#' + filterType + ' .feature_items').fadeOut();
			}
			else {
				$(this).removeClass('closed').addClass('open');
				$('#' + filterType + ' .feature_items').fadeIn();
			}
		});
		$(".item_link span[class='count_total']").filter(function (e) {
			if ($(this).text() == "0") {
				$(this).parent().addClass("zero_product_items").unbind('click').removeAttr('depevents'); //kill <a> click and depEvent filterClick[] events           
				$(this).prev().attr('disabled', 'disabled').css('cursor', 'default'); //disable <input> tag
			}
			else {
				$(this).prev().attr('disabled', false).css('cursor', 'pointer'); // else enable <input> tag (fix for manual page refresh bug)
				if ($(this).parent().hasClass('selected')) {
					$(this).prev().attr('checked', 'checked');
				}
			}
		});
	}

	function onLoadOfContent(firstLoad) {
		var productType = $('#filter-input').attr("class");
		$('.compare_view input:checkbox').click(function (e) {
			var checkedCount = $('.compare_view').find('input:checkbox').filter(':checked').length;
			var msg1 = $('#compareMessageOne').text();
			var msg2 = $('#compareMessageTwo').text();
			var msg3 = $('#compareMessageThree').text();
			var fList = "";
			$('.compare_view input:checkbox').filter(':checked').each(function (index) {
				if (fList.length > 0) {
					fList += "|";
				}
				fList += (this.id);
			});
			switch (checkedCount) {
				case 1:
					$('.compare_buttons .button-link').addClass('disabled');
					$('.compare_buttons .button-link').removeClass('red');
					$('#compare-message').text(msg1);
					$('.compare_view input:checkbox:not(:checked)').attr('disabled', false);
					$('.compare_buttons .module.button a').removeAttr('href');
					break;

				case 2:
					$('.compare_buttons .button-link').addClass('red');
					$('.compare_buttons .button-link').removeClass('disabled');
					$('#compare-message').text(msg2);
					$('.compare_view input:checkbox:not(:checked)').attr('disabled', false);
					$('.compare_buttons .module.button a').attr('href', dep.settings["site_root"] + "/compare/" + productType + "/" + fList);
					$('.compare_buttons .module.button a').click(function () {
						$('input').removeAttr('checked');
					});
					break;

				case 3:
					$('.compare_buttons .button-link').addClass('red');
					$('.compare_buttons .button-link').removeClass('disabled');
					$('#compare-message').text(msg3);
					$('.compare_view input:checkbox:not(:checked)').attr('disabled', true);
					$('.compare_buttons .module.button a').attr('href', dep.settings["site_root"] + "/compare/" + productType + "/" + fList);
					$('.compare_buttons .module.button a').click(function () {
						$('.compare_view input:checkbox:not(:checked)').attr('disabled', false);
						$('input').removeAttr('checked');
					});
					break;
			}
		});

		/* color swatches -- switching product images based on what color is clicked */
		$('.product_details .swatch_icon').bind("click", function (e) {
			var $parentProduct = $(this).parents(".product_details");
			var newSource = $(this).attr("data-imgsrc");
			$(".product_image", $parentProduct).attr("src", newSource);
			$("#zbox-quick-view-" + $parentProduct.attr("data-id") + " #default-image").attr("src", newSource);

			// Keep the PDP link up to date
			var pdpUrl = $(this).attr("data-pdpurl");
			$(".product_link, .product_header", $parentProduct).attr("href", pdpUrl);
			$(".pdp_link", "#zbox-quick-view-" + $parentProduct.attr("data-id")).attr("href", pdpUrl);

			// Update the Shop Now button per color as necessary
			var isComingSoon = ($(this).attr("comingSoon") == "true"); // show coming soon button
			var isDisabled = ($(this).attr("disableShopUrl") == "true"); // hide button
			var changeUrl = $(this).attr("shopUrl"); // update URL per color
			var sku = $(this).attr("data-sku"); // update SKU per color
			var fid = $(this).attr("data-fid"); // fid of current product
			var context = $parentProduct.add($("#zbox-quick-view-" + $parentProduct.attr("data-id"))); // Shop now button is found in two places
			dep.UpdateShopNowButton(isComingSoon, isDisabled, changeUrl, sku, fid, context);
		});

		// Trigger a color swatch click to keep buttons and quick-views up to date
		// Only for filter loads, not for the initial page load
		if (!firstLoad) {
			$(".product_details").each(function () {
				var sku = $(this).attr("data-sku");
				if (sku) {
					$("#swatch-" + sku, this).trigger("click");
				}
			});
		}
	}

	dep.addEventHandler("ClearFilterClick", function (e) { //clear filter button
		var productType = $('#filter-input').attr("class");
		var filterUrl = dep.settings["site_root"] + e.arguments["filterPage"] + "?type=" + productType + "&mode=fragment";
		//filterUrl = dep.utils.makeUrlUnique(filterUrl);
		var listUrl = dep.settings["site_root"] + e.arguments["listPage"] + "?type=" + productType + "&mode=fragment";
		//listUrl = dep.utils.makeUrlUnique(listUrl);
		callFragmentUrls(filterUrl, listUrl, true);
	});

	dep.addEventHandler("FilterClick", function (e) {

		var clickedFilter = $(e.sender);
		var querystringPrice = "";
		var querystringSubtype = "";
		var querystringColor = "";
		var querystringFeature = "";
		var querystringPricesort = "";
		var productType = $('#filter-input').attr("class");
		var querystringComplete = "?type=" + productType;
		var clickedFilterID = clickedFilter.attr("id"); //grab id of the filter <a>
		var clickedFilterType = clickedFilter.parent().parent().attr("id"); //grab type of filter (price/color/features)
		var newFilter = !clickedFilter.hasClass('selected'); //is this a new filter (true), or a previously clicked filter (false)?
		if (newFilter) { //if it's new
			if (clickedFilterType == "filtergroup-pricesort") { //extra logic for ascending/descending price sorting, b/c they don't get reset on ajax call
				$('#filtergroup-pricesort input').removeAttr('checked');
				$('#filtergroup-pricesort a').removeClass('selected');
			}
			$('input', clickedFilter).attr('checked', 'checked'); //check it
			clickedFilter.addClass('selected');
		} else {
			if (clickedFilterType == "filtergroup-pricesort") { //extra logic for ascending/descending price sorting, b/c they don't get reset on ajax call
				$('#filtergroup-pricesort a').each(function () {
					if (!$(this).hasClass("selected")) {
						$('input', this).attr('checked', 'checked');
						$(this).addClass('selected');
					}
				});
			}
			$('input', clickedFilter).removeAttr('checked'); //else uncheck it
			clickedFilter.removeClass('selected');

		}

		switch (clickedFilterType) {
			case "filtergroup-price":
				if (newFilter) { //if it's new, change the price query to it
					querystringComplete += "&pricerangeid=" + clickedFilterID;
				}
				filterOnSubtype();
				filterOnColor();
				filterOnFeature();
				filterOnPricesort();
				break;
			case "filtergroup-pricesort":
				//if (newFilter) { //if it's new, change the price query to it
				querystringComplete += "&sort=" + clickedFilterID;
				//}
				filterOnPrice();
				filterOnSubtype();
				filterOnColor();
				filterOnFeature();
				break;
			case "filtergroup-subtype":
				if (newFilter) { //if it's new, change the subtype query to it
					querystringComplete += "&subtype=" + clickedFilterID;
				}
				filterOnPrice();
				filterOnColor();
				filterOnFeature();
				filterOnPricesort();
				break;
			case "filtergroup-color":
				if (newFilter) { //if it's new, change the color query to it
					querystringComplete += "&color=" + clickedFilterID;
				}
				filterOnPrice();
				filterOnSubtype();
				filterOnFeature();
				filterOnPricesort();
				break;
			default:
				filterOnPrice();
				filterOnSubtype();
				filterOnColor();
				filterOnFeature();
				filterOnPricesort();
				break;
		}

		function filterOnPrice() {
			$('#filtergroup-price a').each(function (e) { //assumes there's only 1 'selected' price
				if ($(this).hasClass('selected')) {
					querystringComplete += "&pricerangeid=" + $(this).attr("id");
				}
			});
		}

		function filterOnSubtype() {
			$('#filtergroup-subtype a').each(function (e) { //assumes there's only 1 'selected' subtype
				if ($(this).hasClass('selected')) {
					querystringComplete += "&subtype=" + $(this).attr("id");
				}
			});
		}

		function filterOnColor() {
			$('#filtergroup-color a').each(function (e) { //assumes there's only 1 'selected' color
				if ($(this).hasClass('selected')) {
					querystringComplete += "&color=" + $(this).attr("id");
				}
			});
		}

		function filterOnFeature() {
			var numFeaturesFiltered = 0;
			$('#filtergroup-feature a').each(function (e) {
				if ($(this).hasClass('selected')) { //for every checked/selected feature, add to the querystring
					if (numFeaturesFiltered > 0) { //if more than 1 feature, pipe delimited
						querystringComplete += "|";
					}
					else {
						querystringComplete += "&features=";
					}
					querystringComplete += $(this).attr("id");
					numFeaturesFiltered++;
				}
			});
		}

		function filterOnPricesort() {
			$('#filtergroup-pricesort a').each(function (e) { //assumes there's only 1 'selected' sorting method
				if ($(this).hasClass('selected')) {
					querystringComplete += "&sort=" + $(this).attr("id");
				}
			});
		}

		querystringComplete += "&mode=fragment";

		var filterUrl = dep.settings["site_root"] + e.arguments["filterPage"] + querystringComplete;
		//filterUrl = dep.utils.makeUrlUnique(filterUrl);
		var listUrl = dep.settings["site_root"] + e.arguments["listPage"] + querystringComplete;
		//listUrl = dep.utils.makeUrlUnique(listUrl);
		callFragmentUrls(filterUrl, listUrl, false);
		return false;
	});

	function callFragmentUrls(filterUrl, listUrl, clearFilters) {

		dep.getFragment(filterUrl, function (data) {
			$("#filter-content").html(data);
		});

		if (dep.browser.ieOld) {
			dep.getFragment(listUrl, function (data) {
				$("#list-content").html(data, function () {
					onLoadOfContent();
					dep.initJS();
				});
			});
		}
		else {
			//quicksand
			dep.getFragment(listUrl, function (data) {
				$("#list-content .product-list").fadeOut(function () {
					$("#list-content").html(data);
					$("#list-content").fadeIn("slow", function () {
						onLoadOfContent();
						dep.initJS();
					});

				});

				//$("#list-content .product-list").quicksand($(data).find(".product_details"), function () { onLoadOfContent(); dep.initJS(); });
			});
		}

	}

});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: product image-gallery lightbox */

dep.addModule("product-image-gallery", function () {

	//click event for thumbnails
	$('#thumbNailSelector img').click(function (event) {
		$('#thumbNailSelector img').toggleClass("selected", false);
		$(this).toggleClass("selected", true);
		$('.product-image-gallery .primary_display img').attr('src', $(this).attr('src').replace('_sm.', '.')); //replace main image with clicked thumbnail
	});

	// click for PDP hero thumbnails
	$('#imageGalleryLinkContainer > img').click(function (event) {
		//dep.fireEvents("WebTrendsSetVar[WT.z_ea_name|wireless-mobile-mouse-4000-limited-edition|WT.z_ea_actionoffer|" + $(this).attr("data-product-type") + "]", this);
		dep.fireEvents("ShowLightbox[lightboxId|product-image-gallery]", this);
		var num = $(this).attr("class").replace("thumbnails", "").replace("selected", "").trim();
		$("." + num, "#thumbNailSelector").trigger("click");
	});


	//click event for color icons
	$('#color-selector .color_select').click(function (event) {

		var currSku = $('.color_data', this).attr("id");
		var imgs = getSKUImages(currSku);

		//find view index from selected thumbnail
		var currentViewIndex = "01";
		if ($('#thumbNailSelector > img').hasClass('selected')) {
			currentViewIndex = $('#thumbNailSelector img.selected').attr('class').replace(" selected", "").replace("thumbnails ", "").trim();
			if (parseInt(currentViewIndex, 10) > parseInt(imgs.otherViewsCount, 10)) {
				//if view index D.N.E. for new color, default to view index 01
				currentViewIndex = "01";
			}
		}

		//replaces main image with new color, same view as before
		$('#mainImage').attr('src', imgs.otherviews + "_otherviews" + currentViewIndex + ".jpg");

		// Update thumbnails to be the current color
		$("img.thumbnails", "#thumbNailSelector, #imageGalleryLinkContainer").each(function (i) {
			var idx = $(this).clone().removeClass("thumbnails selected").attr("class");
			var src = imgs.otherviews + "_otherviews" + idx + "_sm.jpg";
			$(this).attr("src", src);
		});

		//call bind() method for new dom element click event on thumbnail list
		$('#thumbNailSelector img').bind('click', function () {
			$('#thumbNailSelector img').toggleClass("selected", false);
			$(this).toggleClass("selected", true);
			$('#mainImage').attr('src', $(this).attr('src').replace('_sm', ''));
		});

		//persisting color change on rest of page
		$('.product-detail-details .figure img').attr('src', imgs.feature);
		$('.product-detail-overview .figure img').attr('src', imgs.detail);

		// Update the Shop Now button per color as necessary
		var isComingSoon = ($("img", this).attr("comingSoon") == "true"); // show coming soon button
		var isDisabled = ($("img", this).attr("disableShopUrl") == "true"); // hide button
		var changeUrl = $("img", this).attr("shopUrl"); // update URL per color
		dep.UpdateShopNowButton(isComingSoon, isDisabled, changeUrl);

		$('#defaultImage').attr('src', imgs.large);

		$('.sku span').html(currSku);

	});

});

function getSKUImages(sku) {
	
	for (var i in skuImages) {

		if (skuImages[i].sku == sku)
			return skuImages[i];

	}


}///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>

/* module: product-feature-selector */

dep.addModule("product-price-sort", function () {

	$("#filtergroup-pricesort a").bind("click", function () {
		if ($("input", this).is(":checked")) {
			return false;
		}
	});

});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>

dep.addModule("product-quick-view", function () {

	$(".color_icon").live("click", function () {
		// Trigger the corresponding swatch in the main page
		var sku = $(this).attr("data-sku");
		$("#swatch-" + sku).trigger("click");
	});

});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>

/* module: product-tour */

dep.addModule("product-tour", function () {

	$(".module.product-tour .slide_toc a").bind("click", function () {
		if (!$(this).hasClass("active")) {
			showSlide(this.id.split("-")[1]);
		}
		return false;
	});


	function showSlide(index) {
		$(".module.product-tour .slide_toc .active").removeClass("active");
		$(".module.product-tour #slidelink-" + index).addClass("active");
		$(".module.product-tour .slides .active").fadeOut(300, function () {
			$(this).removeClass("active");
			$(".module.product-tour .slides #slide-" + index).fadeIn(300).addClass("active");

		});

	}
	$(".module.product-tour #slidelink-1").addClass("active");
	$(".module.product-tour #slide-1").addClass("active");

});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: shop-button

dep.currentSku = [];

dep.addModule("shop-button", function () {

    dep.UpdateShopNowButton = function (isComingSoon, isDisabled, changeUrl, sku, fid, context) {

        var buttonContainer = context ? context : ".shop_button_container";
        dep.currentSku[fid] = sku;

        if (isComingSoon) {
            disableShopNow({ fn: showComingSoon, bc: buttonContainer });
        } else {
            if (isDisabled) {
                disableShopNow({ bc: buttonContainer });
            } else if (changeUrl) {
                hideComingSoon({ fn: updateShopNowUrl, url: changeUrl, bc: buttonContainer });
            } else {
                hideComingSoon({ fn: showShopNow, bc: buttonContainer });
            }
            hideComingSoon({ bc: buttonContainer });
        }

        // hack for nasty ie10 layout bug
        if ($.browser.msie && $.browser.version == 10) {

            var $cont = $(".product_price", buttonContainer);

            var html = $cont.html();
            $cont.html("");
            $cont.html(html);
        }

    };

    function showShopNow(args) {
        $(".product_shop_link", args.bc).show();
    }

    function updateShopNowUrl(args) {
        $(".product_shop_link", args.bc).show().find("a").attr("href", args.url);
    }

    function disableShopNow(args) {
        $(".product_shop_link", args.bc).hide();

        if (args.fn) {
            args.fn.call(this, { bc: args.bc });
        }

    }

    function showComingSoon(args) {
        $(".comingSoon", args.bc).show();
    }

    function hideComingSoon(args) {
        $(".comingSoon", args.bc).hide();
        if (args.fn) {
            args.fn.call(this, { bc: args.bc, url: args.url });
        }
    }

});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: showcase-player */

dep.addModule("showcase-player", function () {

});

var showcasePlayerModule = {
	play: function (id) {
		// Give Silverlight a second to load the plugin 
		setTimeout(function () {
			var player = showcasePlayerModule.getPlayer(id);
			if (player) {
				player.Play();
			}
		}, 1000);
	},
	stop: function (id) {
		var player = showcasePlayerModule.getPlayer(id);
		if (player) { player.Stop(); }
	},
	getPlayer: function (id) {
		var slObject = $("#" + id).get(0);
		var player;

		if (slObject && slObject.Content) {
			player = slObject.Content.MediaPlayer;
		}

		return player;
	}
}///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
// module id: link-dropdown



dep.addModule("social-links", function () {

});///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: table */

dep.addModule("table", function () {

        $(".child_row").addClass("hidden");


    dep.addEventHandler("TableRowExpand", function (e) {
        $("." + e.Arguments["id"] + "_group_child_row").toggleClass("hidden");

        if ($(e.sender).find(".table_plus").length > 0) {
            var plus = $(e.sender).find(".table_plus").get(0);

            if (plus.src.indexOf("plus") > -1)
                plus.src = plus.src.replace("plus", "minus");
            else
                plus.src = plus.src.replace("minus", "plus");
        }
    }, false );

});///<reference path="../../../script/jquery/jquery-1.4.4.min.js"/>
///<reference path="../../../script/dep.js"/>
/* module: tabs */

dep.addModule("tabs", function () {

	var selectedTab = "";
	var activeTabPassed = false;
	var tabChangeCallback;

	selectedTab = dep.utils.getUrlHash().toLowerCase();
	if (selectedTab.length > 0) {
		selectedTab = "tab-" + jQuery.trim(selectedTab);
	}

	$('.tabs .header a').each(function () {
		var currentTabName = $(this).attr('id').toLowerCase();
		currentTabName = jQuery.trim(currentTabName);
		if (currentTabName == selectedTab) {
			setActiveTab($(this).attr('class'), true);
			activeTabPassed = true;
		}
	});

	if (!activeTabPassed) { //if the passed in tab wasn't found, or there was no passed tab, select first tab
		setActiveTab($('.tabs .header a').first().attr('class'), true);
	}

	$('.tabs .header a').click(function (e) {
		tabSelect(this);
	});

	$('.tabs .header a').bind("silentSelect", function (e) {
		tabSelect(this, true);
	});

	function tabSelect(me, silent) {
		if ($(".tabs .selected a").attr('class') != $(me).attr('class')) {
			$(".tabs .header").toggleClass("selected", false);
			$(me).parent().parent().toggleClass("selected", true);
			setActiveTab($(me).attr('class'), false);
			window.location.hash = $(me).attr("id").replace("tab-", "");

			if (!silent) {
				// analytics
				var uri = location.pathname;
				var url = location.hostname + location.pathname;
				dcsMultiTrack(
					"DCS.dcsuri", uri,
					"WT.ti", "Link:" + $(me).text(),
					"WT.dl", "1",
					"WT.nv", "PDP Tab",
					"WT.EvtSrc", url
				);
			}
		} else {
			if (tabChangeCallback) {
				tabChangeCallback.call();
				tabChangeCallback = null;
			}
		}
		return false;
	}

	function setActiveTab(tabID, pageLoad) {
		var tabContentID = tabID.replace("tab-link-", "tab");
		if (pageLoad) {
			$(".tabs .header").toggleClass("selected", false);
			$('.tabs .content.' + tabContentID).show();
			$('.tabs .' + tabID).parent().parent().toggleClass("selected", true);
		} else {
			$('.tabs .content:visible').fadeOut('fast', function () {
				$('.tabs .content.' + tabContentID).fadeIn('fast', function () {
					if (tabChangeCallback) {
						tabChangeCallback.call();
						tabChangeCallback = null;
					}
				});
			});
		}
	}

	// Expose the setActiveTab method
	function tabClick(id, fn) {
		if (fn) { tabChangeCallback = fn; }
		$('#tab-' + id).trigger("click");
	}
	dep.pageParts.tabs.tabClick = tabClick;

});

///<reference path="../../../script/jquery/jquery-1.4.4.min.js"/>
///<reference path="../../../script/dep.js"/>
/* module: tabs */

dep.addModule("video-gallery", function () {

    $('.vg-image').hover(function () {
        $("#play-btn", this).toggleClass("play-rollover");
    });

    $('.video-gallery-filter input[type=checkbox]').click(function () {

        $('.vg-item').each(function () {

            var show = false;
            var classList = $(this).attr('class').split(' ');
            for (i = 0; i < classList.length; i++) {

                var currClass = $.trim(classList[i]);
                if (classList[i].length == 0 || classList[i] == "vg-item")
                    continue;

                if ($("#" + currClass).attr("checked") == true) {
                    show = true;
                }
            }

            if (show)
                $(this).show();
            else
                $(this).hide();
        });
    });

    dep.onPageLoad(function () {
        $('.video-gallery-filter input[type=checkbox]').each(function () {
            $(this).attr("checked", "checked");
        })
    });


});



    function changeLanguage(lang) {
        window.location.href = dep.settings["site_root"] + "/privacy/" + lang + "/default.mspx";
    }

    function changeIntellitypeLanguage(lang) {
        window.location.href = dep.settings["site_root"] + "/intellitype/" + lang + "/default.mspx";
    }

    function changeIntellipointLanguage(lang) {
        window.location.href = dep.settings["site_root"] + "/intellipoint/" + lang + "/default.mspx";
    }

    function changeLifecamLanguage(lang) {
        window.location.href = dep.settings["site_root"] + "/lifecam/" + lang + "/default.mspx";
    }

    function changeBluetoothLanguage(lang) {
        window.location.href = dep.settings["site_root"] + "/bluetooth/" + lang + "/default.mspx";
    }

    function changeLifecamStudioLanguage(lang) {
        window.location.href = dep.settings["site_root"] + "/lifecamstudio/" + lang + "/default.mspx";
    }

(function ($) {

	dep.topSellers = [
		{
			"name": "Wireless Mobile Mouse 4000",
			"url": "/hardware/en-us/p/wireless-mobile-mouse-4000/D5D-00001",
			"img": "/hardware/_base_v1/products/wireless-mobile-mouse-4000/mk_wmm4000blk_sm.png",
			"category": "mouse"
		},
		{
			"name": "Natural Ergonomic Keyboard 4000",
			"url": "/hardware/en-us/p/natural-ergonomic-keyboard-4000/B2M-00012",
			"img": "/hardware/_base_v1/products/natural-ergonomic-keyboard-4000/mk_nek4000_sm.png",
			"category": "keyboard"
		},
		{
			"name": "Xbox 360 controller",
			"url": "/hardware/en-us/p/xbox-360-controller-for-windows/52A-00004",
			"img": "/hardware/_base_v1/products/xbox-360-controller-for-windows/gm_xboxc_blk_sm.png",
			"category": "gaming"
		},
		{
			"name": "LifeCam Studio",
			"url": "/hardware/en-us/p/lifecam-studio/Q2F-00001",
			"img": "/hardware/_base_v1/products/lifecam-studio/ic_lcst_sm.png",
			"category": "webcam"
		},
		{
			"name": "LifeChat LX-2000",
			"url": "/hardware/en-us/p/lifechat-lx-2000/2AA-00001",
			"img": "/hardware/_base_v1/products/lifechat-lx-2000/ic_lx2000_sm.png",
			"category": "headset"
		}
    ];

	try {

		// Alters the "Buy Now" button on the PDP to use the MS Store treatment
		dep.wtOptimize.buyNowButtonVariant = function (num) {

			$("#wtOptimizeBuyNow").removeClass("ms_store");
			$("#wtOptimizeBuyNow").removeClass("new");
			$("#wtOptimizeBuyNow").addClass("test");

			$("#wtOptimizeBuyNow span").unbind();
			$("#wtOptimizeBuyNow").unbind();

			var html = $("#buyButtonVarient" + num).val();
			$("#wtOptimizeBuyNow").html(html);

		}



	} catch (e) { }

	try {

		// Alters the "Learn More" buttons in the related products section of the PDP
		dep.wtOptimize.relatedProductButtonVariant = function () {

			$(".product-related-products .button-link").addClass("testactive");
		}



	} catch (e) { }

	try {
		// Alters the related products section of the PDP to use new design
		dep.wtOptimize.relatedProductThreeVariant = function () {

			$(".product-related-products .related_products_container").hide();
			$(".product-related-products .related_products_wrapper").show();

		}



	} catch (e) { }

	try {
		// Alters the home page hero All In One Media Keyboard to display differing text
		dep.wtOptimize.homepageAIOMKVariant = function () {

			$("#media-keyboard-hero .control").hide();
			$("#media-keyboard-hero .variant").show();
			$(".hero-rotator #media-keyboard-hero .content").css("top", "20px")
		}



	} catch (e) { }
	// Injects a CTA to a top-selling item into the Download Detail page
	dep.downloadDetailVariant = function () {
		var curCategory = $("meta[name='WT.cg_s']", "head").attr("value");
		var product = getRandomProduct(dep.topSellers, curCategory);
		var depevents = $("#wtOptimizeDownloadCta").find("a").first().attr("depevents");

		$("#wtOptimizeDownloadCta")
			.find("img")
				.attr("src", product.img)
			.end()
			.find("p")
				.append("You may be interested in")
				.append("<span>" + product.name + "</span>")
			.end()
			.find("a")
				.attr("href", product.url)
				.attr("depevents", "WebTrendsSetVar[WT.z_ea_name|" + product.name + "|WT.z_ea_actionoffer|DDP-PDP Test]")
			.end()
			.show();
	}

	$(function () {
		// Attach WT Optimize event handler to the Buy Now button, if it's currently active
		//$("a", "#wtOptimizeBuyNow").click(function (e) {
		//	WTOptimize.conversion('ta_MicrosoftHardwarePDPDetails', { beacon: true, conversionPoint: 'pdpBuyNowClick' });
		//});

		dep.downloadDetailVariant();
	});

	function getRandomProduct(prodList, excludeCategory) {
		// Remove any product that matches excludeCategory
		var cleanedProdList = [];
		$.each(prodList, function (i) {
			if (prodList[i].category != excludeCategory) {
				cleanedProdList.push(prodList[i]);
			}
		});

		// Choose one of the remaining at random
		var index = Math.floor(Math.random() * cleanedProdList.length);

		return cleanedProdList[index];
	}



	//preload the background image for the keyboard animation hero
	//disable once keyboard-animation-hero is no longer active.
	//$(document).ready(function () { 
	//	try {
	//		var bgimg = $("#keyboard-animation-hero .background").css("background-image");
	//		if (bgimg != undefined && bgimg != "none") {
	//			bgimg = bgimg.replace('url(', '').replace('"', '').replace('"', '').replace(')', '');
	//			var tempImage = new Image();
	//			tempImage.src = bgimg;
	//		}
	//	}
	//	catch (err) { }
	//});
})(jQuery);

$(document).ready(function () {


});