var TertiaryNavSolutionsClickHandler = new DEPClickEventHandler("TertiaryNavSolutionsClick");

TertiaryNavSolutionsClickHandler.HandlerFunction = function (e) {

    var nav = $("#nav-tertiary-solutions");

    //If an indented item is selected, make it not selected.
    nav.find("div.tertiary_nav_item_indented_selected").removeClass("tertiary_nav_item_indented_selected").addClass("tertiary_nav_item_indented");

    //This is for non-indented items.
    nav.find("div.tertiary_nav_item_divider").css("border-width", "1px").css("height", "0");
    var icon = nav.children(".tertiary_nav_item_selected").find(".tertiary_nav_item_icon")[0];
    if (icon != null) {
        icon.src = icon.src.replace("nav_active", "nav_inactive");
    }
    else {
        icon = nav.children(".tertiary_nav_item_indented_selected").find(".tertiary_nav_item_indented_icon")[0];
        if (icon == null) {
            icon = nav.children(".tertiary_nav_item_indented_selected").find(".tertiary_nav_item_indented_icon_long")[0];
        }
        if (icon != null) {
            icon.src = icon.src.replace("subnav_arrow_up", "subnav_arrow_down");
        }
    }
    nav.children(".tertiary_nav_item_selected").removeClass("tertiary_nav_item_selected").addClass("tertiary_nav_item");
    if (e.Arguments["indented"] == "true") {
        $(e.sender).parent().removeClass("tertiary_nav_item_indented").addClass("tertiary_nav_item_indented_selected");
    }
    else {
        $(e.sender).parent().removeClass("tertiary_nav_item").addClass("tertiary_nav_item_selected");
        var newItem = nav.children(".tertiary_nav_item_selected");
        icon = newItem.find(".tertiary_nav_item_icon")[0];
        if (icon != null) {
            icon.src = icon.src.replace("nav_inactive", "nav_active");
        }
        newItem.prev().css("border-width", "1px").css("height", "1px");
    }

    var success = false;
    var url = MakeUrlUnique(e.Arguments["url"]);

    $.get(url, function (data) {
        success = true;
        $("#tab-content").html(data);
        dcsSetVar('WT.dl', '0');
        //This needs to be an event instead.
        //lpAddMonitorTag();
    });

    //    if (!success)
    //        this.AllowNavigation = true;
}

DEP.AddClickEventHandler(TertiaryNavSolutionsClickHandler);var zBoxes = [];
var zBox_TagsToHide = ["select", "embed"];
var zBox_BackgroundDivId = "zBox_bg";
var zBox_IE6BackgroundOpacity = "80";

//This is the full URL of the current page (to be used for video refreshing).
var pageUrl;
//Check to see if it's a video lightbox, otherwise, don't refresh on close.
var isVideoLightbox;

function zBox_CreateBox(id, show)
{
    if (typeof (show) == "undefined")
        show = false;
    
    if (id != "" & typeof (zBox_GetBox(id)) == "undefined")
    {
        zBoxes.push(new zBox(id, show));
    }
}

function zBox_GetBox(id)
{
    for(var i=0;i<zBoxes.length;i++)
    {
        if(zBoxes[i].ID == id)
            return  zBoxes[i];
    }
}

function zBox_GetVisibleBox()
{
    for(var i=0;i<zBoxes.length;i++)
    {
        if(zBoxes[i].State == "visible")
            return  zBoxes[i];
    }
}

function zBox_HideAll(box)
{
    for(var i=0;i<zBoxes.length;i++)
    {
        if(zBoxes[i].ID != box.ID)
            zBoxes[i].Hide();
    }
}

function zBox_ToggleTags(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';                        
        }
    }
}

function zBox_RestorePage()
{
    for(var i=0;i<zBox_TagsToHide.length;i++)
    {
        zBox_ToggleTags(zBox_TagsToHide[i],false,null);
    }
    
    var zBox_bg = zBox_GetBackground();
    zBox_bg.style.display = 'none';
}


function zBox_PreparePage(box)
{
    // 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 zBox_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 (isIE6)
    {
        zBox_bg.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + zBox_IE6BackgroundOpacity + ")";

        if (bgHeight < document.documentElement.scrollHeight)
            bgHeight = document.documentElement.scrollHeight;

        bgWidth = document.documentElement.scrollWidth;
    }

    zBox_bg.style.height = Math.round(bgHeight) + "px";
    zBox_bg.style.width = Math.round(bgWidth) + "px";
    zBox_bg.style.display = 'block';

}

function zBox_GetBackground()
{
    var bg = document.getElementById('zBox_bg');
    
    if(!bg)
    {                
        bg = document.createElement("div");
        bg.id = zBox_BackgroundDivId;
        
        bg.style.display = "none";        
        document.body.appendChild(bg);                
    }
    
    return bg;
}
        
function zBox_IsInsideBox(node,box)
{
    if(node.tagName != "BODY")
    {
        if(box && (node.id == box.ID))        
            return true;
        else
            return zBox_IsInsideBox(node.parentNode,box);
    }
    
    return false;
}


function zBox_ResetVisibleBox()
{
    var box = zBox_GetVisibleBox();    
    if(box)
    {
        box.PositionBox();
        zBox_PreparePage(box);
    }
}

var 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
      };
    }
         
}
        
//Box Object
function zBox(id, show)
{
    this.ID = id;
    this.Div = document.body.appendChild(document.getElementById(this.ID));
    this.PostShowScripts = [];
    this.PostHideScripts = [];
    this.State = "";
    this.Top = 0;
    this.Left = 0;
    this.OnShow = new zBox_Event();
    this.OnHide = new zBox_Event();
    if (show)
        this.Show();
}

zBox.prototype.Show = function()
{       
    zBox_SetEvents(true);    
    this.Div.style.display = "block";
    this.PositionBox();
    zBox_PreparePage(this);
    this.Div.style.visibility = "visible";   
    
    
    this.State = "visible";
    this.OnShow.Execute();                
}


zBox.prototype.PositionBox = function () {
    var pageSize = Utils.getPageSize();
    var scrollPos = Utils.getScrollPos();
    var emSize = 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 (isIE6) {
        var temp = document.documentElement.clientHeight - emSize.height;
        this.Top = scrollPos.scrollY + (temp / 2);
    }
    this.Div.style.left = this.Left + 'px';
    this.Div.style.top = this.Top + 'px';
}



//zBox.prototype.PositionBox = function()
//{
//    //this.Div.style.display = "block";
//    
//    var pageSize = Utils.getPageSize();
//    var scrollPos = Utils.getScrollPos();
//    var emSize = Utils.getElementSize(this.Div);

//    this.Left = Math.round((pageSize.width - emSize.width) / 2 );
//    this.Top = Math.round((pageSize.height - emSize.height) / 2  );

//    if (isIE6)
//    {
//        var temp = document.documentElement.clientHeight - emSize.height;
//        this.Top = scrollPos.scrollY + (temp / 2);
//    }
//    this.Div.style.left = this.Left + 'px';
//    //if (this.Top < scrollPos.scrollY) this.Top = scrollPos.scrollY;
//    this.Div.style.top = this.Top + 'px';
//}


zBox.prototype.Hide = function () {
	var lightboxId = zBox_GetVisibleBox();
	if (lightboxId != null) {
		lightboxId = lightboxId.ID;
		//alert(lightboxId);
		closeRedirection(lightboxId);
	}
	this.Div.style.visibility = "hidden";
	this.Div.style.display = "none";
	this.State = "hidden";
	zBox_RestorePage();
	this.OnHide.Execute();
}

zBox.prototype.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;     
}

var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
var isIE = /msie|MSIE /.test(navigator.userAgent);

function zBox_SetEvents(enable)
{
    if(enable)
    {
        window.onresize = zBox_ResetVisibleBox;

        if (isIE6)
            window.onscroll = zBox_ResetVisibleBox;

        document.onkeydown = zBox_KeyPress;
        document.onclick = zBox_BodyClick;   
    }
}

function zBox_KeyPress(e)
{
    if (!e) var e = window.event;
    
    if(e.keyCode == 27)
      zBox_GetVisibleBox().Hide();  	        
    
}

function zBox_BodyClick(e)
{
    if (!e)
    {
        var e = window.event;
        if (e.srcElement.id == zBox_BackgroundDivId) {
            zBox_GetVisibleBox().Hide();
            //Make it refresh the current page so that the video will stop.
            if (isVideoLightbox && isIE) {
                window.location = pageUrl;
            }

            stopAllSLVideos();
        }
    }
    else
    {
        if (e.originalTarget.id == zBox_BackgroundDivId) {
            zBox_GetVisibleBox().Hide();
            //Make it refresh the current page so that the video will stop.
            if (isVideoLightbox) {
                window.location = pageUrl;
            }

            stopAllSLVideos();
        }
    }    
}

function zBox_Event(){this.eventHandlers = [];}

zBox_Event.prototype.AddHandler = function(eventHandler){
    this.eventHandlers.push(eventHandler);
}

zBox_Event.prototype.Execute = function(args)
{
    for(var i = 0; i < this.eventHandlers.length; i++)
    { this.eventHandlers[i](args);}
}


/* Begin - Lightbox Close Handler */
var ShowLightBoxCloseHandler = new DEPClickEventHandler("LightBoxClose");
ShowLightBoxCloseHandler.AllowNavigation = false;

ShowLightBoxCloseHandler.HandlerFunction = function (e) {
    // hide the lightbox
    zBox_GetVisibleBox().Hide();

    //Make it refresh the current page so that the video will stop.
    if (isVideoLightbox) {
        window.location = pageUrl;
    }

    stopAllSLVideos();

}

DEP.AddClickEventHandler(ShowLightBoxCloseHandler);
/* End - Lightbox Close Handler */


/* Lightbox Click Handler */
var ShowLightBoxClickHandler = new DEPClickEventHandler("ShowLightBoxClick");
ShowLightBoxClickHandler.HandlerFunction = function (e) {
    stopAllSLVideos();

    //    SLPlugin.Content.Player.Play();
    //    SLPlugin.Content.Player.Pause();
    //    SLPlugin.Content.Player.Stop();

    // get light box id / url
    var lightboxId = e.Arguments["lighboxId"];
    var url = DEP.Settings["site_root"] + e.Arguments["lighboxUrl"] + "?mode=fragment";

    //Set the URL so that page can refresh back to that page and video will stop playing when user closes lightbox.
   // closeRedirection(lightboxId);
   
    if (typeof (zBox_GetBox(lightboxId)) == "undefined") {
        $.ajax({
            url: MakeUrlUnique(url),
            success: function (data) {
                $("#lightbox-content").html(data);
            },
            async: false
        });
    }


    //zBox_CreateBox(lightboxId);
    zBox_GetBox(lightboxId).Show();
}
DEP.AddClickEventHandler(ShowLightBoxClickHandler);




/* Inline Lightbox Click Handler */
var ShowInlineLightBoxClickHandler = new DEPClickEventHandler("ShowInlineLightBoxClick");
ShowInlineLightBoxClickHandler.AllowNavigation = false;
ShowInlineLightBoxClickHandler.HandlerFunction = function(e) {

    stopAllSLVideos();

    // get light box id / url
    var lightboxId = e.Arguments["lightboxId"];
    
    // and show it
    zBox_GetBox(lightboxId).Show();
}
DEP.AddClickEventHandler(ShowInlineLightBoxClickHandler);

function stopAllSLVideos() {
    try {
        var objects = $("object")
        for (var i = 0; i < objects.length; i++) {
            try { objects[i].Content.Player.Pause(); }
            catch (ex) { }
        }
    }
    catch (ex) { }
}


function closeRedirection(lightboxId) {

	if (lightboxId == "alm-process-management-video-lightbox") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/solutions/management/alm-defined/alm-process-management";
		isVideoLightbox = true;
	}
	else if (lightboxId == "alm-team-dev-video-lightbox") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/solutions/management/alm-defined/alm-team-dev";
		isVideoLightbox = true;
	}
	else if (lightboxId == "alm-test-qa-video-lightbox") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/solutions/management/alm-defined/alm-test-qa";
		isVideoLightbox = true;
	}
	else if (lightboxId == "alm-maintenance-video-lightbox") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/solutions/management/alm-defined/alm-maintenance";
		isVideoLightbox = true;
	}
	else if (lightboxId == "alm-heterogeneous-dev-video-lightbox") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/solutions/management/alm-defined/alm-heterogeneous-dev";
		isVideoLightbox = true;
	}
	else if (lightboxId == "testing-bp-manual-testing-video-lightbox") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/solutions/software-quality/best-practices/manual-testing";
		isVideoLightbox = true;
	}
	else if (lightboxId == "testing-bp-perf-testing-video-lightbox") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/solutions/software-quality/best-practices/perf-testing";
		isVideoLightbox = true;
	}
	else if (lightboxId == "visual-sourcesafe-upgrade-how-video-lightbox") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/upgrade-visual-sourcesafe";
		isVideoLightbox = true;
	}
	else if (lightboxId == "visual-sourcesafe-upgrade-why-video-lightbox") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/upgrade-visual-sourcesafe";
		isVideoLightbox = true;
	}
	else if (lightboxId == "test-professional-tour-get-started-video-carousel-lightbox") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/try/test-professional-2010-tour/get-started";
		isVideoLightbox = true;
	}
	else if (lightboxId == "test-professional-tour-dive-deeper-video-carousel-lightbox") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/try/test-professional-2010-tour/dive-deeper";
		isVideoLightbox = true;
	}
	else if (lightboxId == "cloud-development-overview-video-carousel-lightbox") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/scenarios/cloud-development";
		isVideoLightbox = true;
	}
	/* This is to stop the showcase videos on the "Day I" page. */
	else if (lightboxId == "lightbox-community") {
		pageUrl = "http://" + location.host + "/visualstudio/thedayi/" + DEP.Settings["culture"];
		isVideoLightbox = true;
	}
	else if (lightboxId == "lightbox-family") {
		pageUrl = "http://" + location.host + "/visualstudio/thedayi/" + DEP.Settings["culture"];
		isVideoLightbox = true;
	}
	else if (lightboxId == "lightbox-stage") {
		pageUrl = "http://" + location.host + "/visualstudio/thedayi/" + DEP.Settings["culture"];
		isVideoLightbox = true;
	}
	else if (lightboxId == "lightbox-vs-action") {
		pageUrl = "http://" + location.host + "/visualstudio/thedayi/" + DEP.Settings["culture"];
		isVideoLightbox = true;
	}
	else if (lightboxId == "pre-release-thank-you-lightbox") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/prerelease-products";
		isVideoLightbox = true;
	}
	else if (lightboxId == "trial-thank-you-lightbox-professional-sweepstakes") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/products/2010-editions/professional/overview";
		isVideoLightbox = true;
	}
	else if (lightboxId == "trial-thank-you-lightbox-premium") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/products/2010-editions/premium/overview";
		isVideoLightbox = true;
	}
	else if (lightboxId == "trial-thank-you-lightbox-ultimate") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/products/2010-editions/ultimate/overview";
		isVideoLightbox = true;
	}
	else if (lightboxId == "express-thank-you-lightbox-phone") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/products/2010-editions/windows-phone-developer-tools";
		isVideoLightbox = true;
	}
	else if (lightboxId == "express-thank-you-lightbox-web-dev") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/products/2010-editions/visual-web-developer-express";
		isVideoLightbox = true;
	}
	else if (lightboxId == "express-thank-you-lightbox-vb") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/products/2010-editions/visual-basic-express";
		isVideoLightbox = true;
	}
	else if (lightboxId == "express-thank-you-lightbox-cs") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/products/2010-editions/visual-csharp-express";
		isVideoLightbox = true;
	}
	else if (lightboxId == "express-thank-you-lightbox-cpp") {
		pageUrl = "http://" + location.host + DEP.Settings["site_root"] + "/products/2010-editions/visual-cpp-express";
		isVideoLightbox = true;
	}
	else {
		isVideoLightbox = false;
	}
}

/* Click Handler */
var HeroDynamicVideoEndHandler = new DEPEventHandler("HeroDynamicVideoEnd");
HeroDynamicVideoEndHandler.AllowNavigation = false;
HeroDynamicVideoEndHandler.HandlerFunction = function(e) {
    // animate video disappearing.
    $("#" + e.Arguments["videoId"]).slideUp(1000);
}
DEP.AddEventHandler(HeroDynamicVideoEndHandler);

$(function()
{
    // Dialog			
    $('#search_dialog').dialog({
        autoOpen: false,
        height: 70,
        width: 426,
        minHeight: 70,
        minWidth: 426,
        dialogClass: 'ui_search_dialog'
    });

    // Dialog Link
    $('#search_dialog_link').click(function()
    {

        var x = $("#search_dialog_link").offset().left - 333;
        var y = $("#search_dialog_link").offset().top - 3;

        jQuery("#search_dialog").dialog('option', 'position', [x, y]);

        $('#search_dialog').dialog('open');
        // for IE6 pngfix
        if (typeof (IEPNGFix) !== 'undefined') { IEPNGFix.update(); }
        return false;
    });
});

$(window).bind('resize', function () {

    try {
        
        var x = $("#search_dialog_link").offset().left - 333;
        var y = $("#search_dialog_link").offset().top - 3;

        jQuery("#search_dialog").dialog('option', 'position', [x, y]);

    }
    catch (err)
    { }
});


var HeaderSearchCloseClick = new DEPClickEventHandler("HeaderSearchClose");
HeaderSearchCloseClick.HandlerFunction = function(e)
{
    $('#search_dialog').dialog('close');
}
DEP.AddClickEventHandler(HeaderSearchCloseClick);

var HeaderSearchSubmitClick = new DEPClickEventHandler("HeaderSearchSubmit");
HeaderSearchSubmitClick.HandlerFunction = function(e)
{
    if (document.msviSearchForm.onsubmit())
        document.msviSearchForm.submit();
}
DEP.AddClickEventHandler(HeaderSearchSubmitClick);


// set up the form submit event
$(function() {
    $("#msviSearchForm").each(function(){
        $(this).get(0).onsubmit = function() {
            var q = $("#msviSearchBox").get(0).value + " site:microsoft.com" + DEP.Settings["site_root"];
            $("#msviSearchBox-q").get(0).value = q;
            return true;
        };
    });
});
function Show(divfilterid) {
    var el = document.getElementById(divfilterid);
    if (el)
        el.className = divfilterid;
}

var isRedirect = true;

function cancelRedirection() {
    isRedirect = false
}

function Hide(divfilterid, element) {
    var el = document.getElementById(divfilterid);
    if (el)
        el.className = "hide";
}

function clearSelection(childnodes) {
    for (var i = 0; i < childnodes.length; i++) {
        var node = childnodes[i];
        if (node && node.nodeName == "LI") node.className = "";
        }
}

function setSearchBoxFormCode1(cmCode, inputhiddenid) {
    var input = getObjectById(inputhiddenid);
    if (input) input.value = cmCode;
    }
    function getTargetFromEvent(e) {
        if (!e) e = window.event;
        if (e.target) var tg = e.target;
        else if (e.srcElement) tg = e.srcElement;
            tg = tg.parentNode;
        return tg;
}

var target, isWebSelected = false;

function SelectLink(e, divfilterid, inputhiddenid, cmCode, mkt) {
    target = getTargetFromEvent(e);
    clearSelection(target.parentNode.childNodes);
    target.className = "selected";
    var el = document.getElementById(divfilterid);
    el.className = "hide";
}

function getObjectById(elid) {
    if (document.getElementById) return document.getElementById(elid);
    else if (document.all) return document.all[elid];
    else if (document.layers) return document.layers[elid];
}

function trim(str, chars) {
    var trimmedstr; if (str) { chars = chars || "\\s"; trimmedstr = str.replace(new RegExp("^[" + chars + "]+", "g"), "") } return trimmedstr
}

$(function() {
    $(".primary_nav_dropdown_item").hover(function(event) {
        // update left class name
        var className = $(this).attr("class") + " over_nav_dropdown_item";
        $(this).attr("class", className);
    },
    function(event) {
        // update left class name
        var className = $(this).attr("class").replace(/ over_nav_dropdown_item/ig, "");
        $(this).attr("class", className);
    });
});

$(function() {
    $(".primary_nav_item").hover(function(e) {

        // update left class name
        var className = $(".primary_nav_item_left", this).attr("class") + " over_nav_item_left";
        $(".primary_nav_item_left", this).attr("class", className);

        var className = $(".primary_nav_item_link", this).attr("class") + " over_nav_item_link";
        $(".primary_nav_item_link", this).attr("class", className);
        // update middle class name
        var className = $(".primary_nav_item_middle", this).attr("class") + " over_nav_item_middle";
        $(".primary_nav_item_middle", this).attr("class", className);

        // update right class name
        var className = $(".primary_nav_item_right", this).attr("class") + " over_nav_item_right";
        $(".primary_nav_item_right", this).attr("class", className);

        $(".primary_nav_dropdown", this).css("display", "block");
        $(".primary_nav_dropdown", this).stop().animate({ "height": "400px" }, 300, function() {
        });

    },
    function(e) {

        // update left class name
        var className = $(".primary_nav_item_left", this).attr("class").replace(/ over_nav_item_left/ig, "");
        $(".primary_nav_item_left", this).attr("class", className);

        var className = $(".primary_nav_item_link", this).attr("class").replace(/ over_nav_item_link/ig, "");
        $(".primary_nav_item_link", this).attr("class", className);

        // update middle class name
        var className = $(".primary_nav_item_middle", this).attr("class").replace(/ over_nav_item_middle/ig, "");
        $(".primary_nav_item_middle", this).attr("class", className);

        // update right class name
        var className = $(".primary_nav_item_right", this).attr("class").replace(/ over_nav_item_right/ig, "");
        $(".primary_nav_item_right", this).attr("class", className);


        $(".primary_nav_dropdown", this).stop().animate({ "height": "0px" }, 100, function() {
            $(this).attr("style", "display:none");
        });

    });
});


$(function() {
$(".primary_nav_item_selected").hover( function(e) {

            // update left class name
            var className = $(".primary_nav_item_left_selected", this).attr("class") + " over_nav_item_left";
            $(".primary_nav_item_left_selected", this).attr("class", className);

            var className = $(".primary_nav_item_link_selected", this).attr("class") + " over_nav_item_link";
            $(".primary_nav_item_link_selected", this).attr("class", className);

            // update middle class name
            var className = $(".primary_nav_item_middle_selected", this).attr("class") + " over_nav_item_middle";
            $(".primary_nav_item_middle_selected", this).attr("class", className);

            // update right class name
            var className = $(".primary_nav_item_right_selected", this).attr("class") + " over_nav_item_right";
            $(".primary_nav_item_right_selected", this).attr("class", className);


            $(".primary_nav_dropdown", this).attr("style", "display:block");
            $(".primary_nav_dropdown", this).stop().animate({ "height": "400px" }, 300, function() {
            });
  
    }, 
    function(e) {
            // update left class name
            var className = $(".primary_nav_item_left_selected", this).attr("class").replace(/ over_nav_item_left/ig, "");
            $(".primary_nav_item_left_selected", this).attr("class", className);

            var className = $(".primary_nav_item_link_selected", this).attr("class").replace(/ over_nav_item_link/ig, "");
            $(".primary_nav_item_link_selected", this).attr("class", className);

            // update middle class name
            var className = $(".primary_nav_item_middle_selected", this).attr("class").replace(/ over_nav_item_middle/ig, "");
            $(".primary_nav_item_middle_selected", this).attr("class", className);

            // update right class name
            var className = $(".primary_nav_item_right_selected", this).attr("class").replace(/ over_nav_item_right/ig, "");
            $(".primary_nav_item_right_selected", this).attr("class", className);

            
            $(".primary_nav_dropdown", this).stop().animate({ "height": "0px" }, 200, function() {
            $( this).attr("style", "display:none");
        });

    });
});
$(document).ready(function () {
	twitterFeed();
});

function twitterFeed() {

    //var twitterBaseURL = 'http://twitter.com/status/user_timeline/visualstudio.json?count=2&callback=?';

    //var twitterBaseURL = "http://api.twitter.com/1/statuses/user_timeline.json?user_id=16913772&count=2&callback=?";
    var twitterBaseURL = "http://" + location.host + "/visualstudio/twitter/default.aspx?feedURL=http%3a%2f%2fapi.twitter.com%2f1%2fstatuses%2fuser_timeline.json%3fuser_id%3d16913772%26count%3d2";
	var html = '';
	var timeoutMessage = $('.twitter-feed p.timeout').html();
	var timer = window.setTimeout(function () {
		$('#twitter-feed-content').html("<p>" + timeoutMessage + "</p>");
	}, 7000);

	$.ajax({
	    url: twitterBaseURL,
	    dataType: 'json',
	    success:
		function (json) {
			$.each(json, function (i, item) {
				var text = parseHashtag(parseUsername(parseURL($.toLink(item.text))));
				//var text = $.toLink(item.text);
				var time = $.TwitterDateConverter(item.created_at);
				html += "<p>" + text + "<br/>" + "<span class='time'>" + time + "</span>" + "</p>";
				window.clearTimeout(timer);
			});
			$('#twitter-feed-content').html(html);
		}
	});


	(function ($) {
		$.toLink = function (text) {
			var urlRegExp = /((ftp|https?):\/\/([-\w\.]+)+(:\d+)?(\/([\w\/_\.]*(\?\S+)?)?)?)/gm;
			var newText = text.replace(urlRegExp, '<a href="$1" target="_blank">$1</a>');

			return newText;
		};

	})(jQuery);

	(function ($) {
		$.TwitterDateConverter = function (time) {

			var newtext = time.replace(/(\d{1,2}[:]\d{2}[:]\d{2}) (.*)/, '$2 $1');
			//moving the time code to the end
			newtext = newtext.replace(/(\+\S+) (.*)/, '$2 $1');

			var date = new Date(Date.parse(newtext)),

		    diff = (((new Date()).getTime() - date.getTime()) / 1000),
		    day_diff = Math.floor(diff / 86400);

			if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31)
				return;

			return day_diff == 0 && (
			diff < 60 && "just now" ||
			diff < 120 && "1 minute ago" ||
			diff < 3600 && Math.floor(diff / 60) + " minutes ago" ||
			diff < 7200 && "1 hour ago" ||
			diff < 86400 && Math.floor(diff / 3600) + " hours ago") ||
		    day_diff == 1 && "Yesterday" ||
		    day_diff < 7 && day_diff + " days ago" ||
		    day_diff < 31 && Math.ceil(day_diff / 7) + " weeks ago";
		};
	})(jQuery);

}

function parseUsername(str) {
	return str.replace(/[@]+[A-Za-z0-9-_]+/g, function (u) {
		var username = u.replace("@", "")
		var url = "http://twitter.com/" + username;
		return "<a href='" + url + "' target='_blank'>" + u + "</a>";
	});
}

function parseURL(str) {
	return str.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/g, function (url) {
		return "<a href='" + url + "' target='_blank'>" + url + "</a>";
	});
}

function parseHashtag(str) {
	return str.replace(/[#]+[A-Za-z0-9-_]+/g, function (t) {
		var tag = t.replace("#", "%23")
		var url = "http://search.twitter.com/search?q=" + tag;

		return "<a href='" + url + "' target='_blank'>" + t + "</a>";
	});
}
var ExpandoHandler = new DEPClickEventHandler("ExpandoClickExternal");
ExpandoHandler.AllowNavigation = false;
ExpandoHandler.HandlerFunction = function (e) {
    try {
		$(e.sender).toggleClass("expanded");
		$(".expando#"+e.Arguments["linkId"]).slideToggle("fast");
    }
    catch (e)
    { }
}
DEP.AddClickEventHandler(ExpandoHandler);
var HorizontalTertiaryNavClickHandler = new DEPClickEventHandler("HorizontalTertiaryNavClick");
HorizontalTertiaryNavClickHandler.HandlerFunction = function (e) {
    //Hide the content only if user is not going directly to the link.
    var nav = $("#nav-tertiary-horizontal");
    nav.children(".horizontal_tertiary_nav_item_selected").removeClass("horizontal_tertiary_nav_item_selected").addClass("horizontal_tertiary_nav_item");
    $(e.sender).removeClass("horizontal_tertiary_nav_item").addClass("horizontal_tertiary_nav_item_selected");

    var success = false;
    var url = MakeUrlUnique(e.Arguments["url"]);
    $.get(url, function (data) {
        success = true;
        $("#tab-content").html(data);
    });
}
DEP.AddClickEventHandler(HorizontalTertiaryNavClickHandler);///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
//module id: culture-dropdown

$(document).ready(function () {
	$(".culture_flyout").mouseenter(function (e) {
		$(this).find(".culture_selected_link").toggleClass("over", true);
		$(".culture_drop_down", this).delay(300).slideDown("fast");
	});

	$(".culture_flyout").mouseleave(function (e) {
		$(this).find(".culture_selected_link").toggleClass("over", false);
		$(".culture_drop_down").stop(true, true);
		$(".culture_drop_down", this).slideUp("fast");
	});

});


var setNowPlayingCarouselIndex = function (index) {
    currentlyPlayingIndex = index;
    var itemName = "#carouselItem" + currentlyPlayingIndex;
    //var key = $(itemName).attr("ref");
    var arrLocation = $(itemName).children('a').attr("href").split("?");
    //window.location.hash = arrLocation[arrLocation.length - 1];
    // $('st_sharethis').attr('st_url') = DEP.Settings["site_root"] + "/lightswitch/visual-studio-in-action" + $(itemName).children('a').attr("href");
}



//fires after a video has finished playing
var SetCarouselCurrentlyPlayingIndexHandler = new DEPEventHandler("SetCarouselCurrentlyPlayingIndex");
SetCarouselCurrentlyPlayingIndexHandler.AllowNavigation = false;
SetCarouselCurrentlyPlayingIndexHandler.HandlerFunction = function (e) {
    var carouselIndex = currentlyPlayingIndex;
    var nextIndex = parseInt(carouselIndex) + 1;
    if (nextIndex > itemCount) {
        currentlyPlayingIndex = 1;
    }
    else {
        currentlyPlayingIndex = nextIndex;
    }
    var itemName = "#carouselItem" + currentlyPlayingIndex;
    //do not play next if there is only one video
    if (itemCount > 1) {
        $(itemName).children('a').click();
    }
    var listItem = $("#carousel_ul #carouselItem" + currentlyPlayingIndex);
    var posIndex = ($('#carousel_ul li').index(listItem));

    //do we need to scroll
    if (itemCount > numVisibleItems) {
        if (posIndex > numVisibleItems) {
            $('#right_scroll').click();
       }


    }


}
DEP.AddEventHandler(SetCarouselCurrentlyPlayingIndexHandler);

//handles click on carousel thumb
var LaunchVideoCarouselPlayVideoHandler = new DEPClickEventHandler("LaunchVideoCarouselPlayVideo");
LaunchVideoCarouselPlayVideoHandler.AllowNavigation = false;
LaunchVideoCarouselPlayVideoHandler.HandlerFunction = function (e) {
	try {
		// extract a few params
		var playerId = "video-carousel-player";  //e.Arguments["playerId"];
		var mediaSource = e.Arguments["mediaSource"];
		var title = ""; //e.Arguments["title"];
		var description = "";  //e.Arguments["description"];
		var carouselIndex = e.Arguments["carouselIndex"];
		var isAdaptiveStreaming = e.Arguments["isAdaptiveStreaming"];
		//alert(carouselIndex + " :: " + mediaSource + " = " + isAdaptiveStreaming);
		if (isAdaptiveStreaming != "true") { isAdaptiveStreaming = false; } 
		//most videos have no isAdaptiveStreaming argument set at the *video* level, so it defaults to undefined, 
		//which we set to "false" as the vast majority of videos on the site aren't adaptive streaming capable.
		var autoPlay = true;  //e.Arguments["autoPlay"];
		

		setNowPlayingCarouselIndex(carouselIndex);
		var itemName = "#carouselItem" + currentlyPlayingIndex;
		//set overlay on selected video
		$("li div").removeClass('selected');
		$("li div").children('.currentlyPlayingText').hide();

		//set the style for current item
		$("#carouselItem" + currentlyPlayingIndex + " div:first").addClass('selected');
		$("#carouselItem" + currentlyPlayingIndex + " div:first").children('.currentlyPlayingText').show();

		//hide play icon in overlay
		$("li div").children('.playicon').show();
		$("#carouselItem" + currentlyPlayingIndex + " div:first").children('.playicon').hide();

		//show the appropriate desc
		$(".long_description").hide();
		$(".title").hide();
		$(".sharing").hide();
		$("#longDesc" + currentlyPlayingIndex).show(300);
		$("#title" + currentlyPlayingIndex).show(300);
		$("#share" + currentlyPlayingIndex).show(300);

		if (SilverlightInstalled()) {
			// open and play selected media
			OpenMediaFromUri(playerId, mediaSource, title, description, isAdaptiveStreaming, autoPlay);
		}

	}
	catch (e)
    { }

}
DEP.AddClickEventHandler(LaunchVideoCarouselPlayVideoHandler);

var LaunchVideoCarouselHandler = new DEPClickEventHandler("LaunchVideoCarousel");
LaunchVideoCarouselHandler.AllowNavigation = false;
LaunchVideoCarouselHandler.HandlerFunction = function (e) {
    try {
        // extract a few params
        //        var playerId = e.Arguments["playerId"];
        //        var mediaSource = e.Arguments["mediaSource"];
        //        var title = e.Arguments["title"];
        //        var description = e.Arguments["description"];
        //        var isAdaptiveStreaming = e.Arguments["isAdaptiveStreaming"];
        //        var autoPlay = e.Arguments["autoPlay"];
        var carouselIndex = e.Arguments["carouselIndex"];

        setNowPlayingCarouselIndex(carouselIndex);

        var itemName = "#carouselItem" + currentlyPlayingIndex;
        //set overlay on selected video
        $("li div").removeClass('selected');
        $("#carouselItem" + currentlyPlayingIndex + " div:first").addClass('selected');

        //This hides the FB stuff, so comment it out.
        //$(".sharing").hide();
        $("#share" + currentlyPlayingIndex).show(300);

        if (SilverlightInstalled()) {
            // open and play selected media
            OpenMediaFromUri(playerId, mediaSource, title, description, isAdaptiveStreaming, autoPlay);
        }

    }
    catch (e)
    { }

}
DEP.AddClickEventHandler(LaunchVideoCarouselHandler);
///<reference path="../../script/jquery/jquery-1.4.2.min.js"/>
///<reference path="../../script/dep.js"/>
/* module: content-switch */

///<reference path="../../script/jquery/jquery.js"/>
///<reference path="../../script/dep.js"/>
/* module: nav-primary-net */


$(".nav-primary-net .item").live("mouseenter", function (e) {
	$(this).toggleClass("over", true);
	$(this).find(".primary_nav_net_dropdown").show(1);
});

$(".nav-primary-net .item").live("mouseleave", function (e) {
	var dropparent = $(this);
	var dropdown = $(this).find(".primary_nav_net_dropdown");
	dropdown.stop(true, true);
	dropdown.hide(1);
	dropparent.toggleClass("over", false);
});var translateFromLanguage;
var usesCufonScript;
var userAcceptLanguage = "";
var languages = "";
var noAutoTranslateLangs = ["he", "pl", "sl"];
var noDisplayLangs = ["Hebrew", "Polish", "Slovenian"];

//This gets the user's accept language.
function setLanguage() {
    var language;
    $.ajax({
        url: "http://ajaxhttpheaders.appspot.com",
        dataType: 'jsonp',
        success: function (headers) {
            language = headers['Accept-Language'];
            userAcceptLanguage = language.substring(0, 2);
        }
    });
}

/* Click to Translate Handler. */
var ClickToTranslateHandler = new DEPClickEventHandler("TranslateClick");
ClickToTranslateHandler.AllowNavigation = true;
ClickToTranslateHandler.HandlerFunction = function (e) {
    translateFromLanguage = e.Arguments["fromLanguage"];
    usesCufonScript = e.Arguments["usesCufon"];
    setLanguage();
    for (var i = 0; i < noAutoTranslateLangs.length; i++) {
        if (userAcceptLanguage == noAutoTranslateLangs[i])
            userAcceptLanguage = "auto";
    }
    Microsoft.Translator.Translate(document.body, translateFromLanguage, userAcceptLanguage);
    setTimeout("modifyTranslatorToolbarStyles()", 500);
}
DEP.AddClickEventHandler(ClickToTranslateHandler);

function modifyTranslatorToolbarStyles() {
    $("#MSTTArrowBox").attr("style", "border-left:1px solid #595959; border-right:1px solid #595959;");
    $("#MSTTGoBox").attr("style", "border-left:1px solid #595959; border-right:1px solid #595959;");
    $("#MSTTHelpBox").attr("style", "border-right:1px solid #595959;");
    $("#MSTTToBox").attr("style", "background-color:#362F2A;");
    $("#MSTTToLink, #MSTTToBox").live("mouseover", function () {
        //TODO:  Fix this (this makes it so that when languages in drop down are in different languages, they still hide properly.
        //        $("#MSTTToBox > div a").each(function (e) {
        //            if (e == 15 || e == 23)
        //                $(this).attr("style", "display:none;");
        //        });
        var oldStyles = $(this).attr("style");
        //Hide designated languages from drop down of languages.
        for (var i = 0; i < noDisplayLangs.length; i++) {
            $("#MSTTToBox").find("a[href*='" + noDisplayLangs[i] + "']").attr("style", "display:none;");
        }
        $(this).attr("style", oldStyles + "background-color:#7f7f7f;");
    });
    $("#MSTTToLink, #MSTTToBox").live("mouseout", function () {
        var oldStyles = $(this).attr("style");
        $(this).attr("style", oldStyles + "background-color:#362F2A;");
    });

    $("#MSTTGoBox").live("mouseover", function () {
        var oldStyles = $("#MSTTGoButton").attr("style");
        $("#MSTTGoButton").attr("style", oldStyles + "background-image:none;");
        if ($("#MSTTGoButton").attr("href").indexOf("Start") > -1) {
            $("#MSTTGoButton").attr("style", "background-color:#000;");
        }
        else {
            $("#MSTTGoButton").attr("style", "background-color:#7f7f7f;");
        }
    });
    $("#MSTTGoBox").live("mouseout", function () {
        var oldStyles = $("#MSTTGoButton").attr("style");
        $("#MSTTGoButton").attr("style", oldStyles + "background-image:none;");
        if ($("#MSTTGoButton").attr("href").indexOf("Start") > -1) {
            $("#MSTTGoButton").attr("style", "background-color:#000;");
        }
        else {
            $("#MSTTGoButton").attr("style", "background-color:#7f7f7f;");
        }
    });
//    if (usesCufonScript == "true") {
//        $("#MSTTToBox").live("mouseover", function () {
//            $(this).find("a[href*='Chinese']").attr("style", "display:none;");
//            $(this).find("a[href*='Japanese']").attr("style", "display:none;");
//        });
//    }
    $("#MSTTToBox > div > a").live("mouseover", function () {
        var oldStyles = $(this).attr("style");
        $(this).attr("style", oldStyles + "background-color:#7f7f7f;");
    });
    $("#MSTTToBox > div > a").live("mouseout", function () {
        var oldStyles = $(this).attr("style");
        $(this).attr("style", oldStyles + "background-color:#362F2A;");
    });
    $("#MSTTHelpBox, #MSTTExitBox").live("mouseover", function () {
        var oldStyles = $(this).attr("style");
        $(this).attr("style", oldStyles + "background-color:#7f7f7f;");
    });
    $("#MSTTHelpBox, #MSTTExitBox").live("mouseout", function () {
        var oldStyles = $(this).attr("style");
        $(this).attr("style", oldStyles + "background-color:#362F2A;");
    });
    $("#MSTTHelpLink").live("hover", function () {
        $(this).attr("href", "http://social.msdn.microsoft.com/Forums/en-US/category/translation");
    });
}




   /* code for original "from sydney" requirements, keeping here in case we need to revert to original requirments at some point */
   //var currURL = document.URL.toLowerCase();;
   //if (currURL.indexOf("/visualstudio/en-us") != -1) {
   //	var cookieread = cookie.read("FromLightweightSite");
   //	if (cookieread) {
   //		alert('this would autotranslate from cookie. cookie: ' + cookieread);
   //	} else {
   //		if (document.referrer) {
   //			var ref = document.referrer;
   //			if ((ref.indexOf("/visualstudio/pt-pt") != -1) || (ref.indexOf("/visualstudio/fr-ca") != -1) || (ref.indexOf("/visualstudio/latam") != -1)) {
   //				cookie.write("FromLightweightSite", "true", "");
   //				alert("this would set a cookie + autotranslate: " + ref);
   //			}
   //		}
   //	}	
   //}

   //This gets the user's accept language.
function getLanguageAndTranslate() {
    $.ajax({
        url: "http://ajaxhttpheaders.appspot.com",
        dataType: 'jsonp',
        success: function (headers) {
            languages = headers['Accept-Language'];
            setTimeout(function () {
                languages = languages.split(",");
                var hasEnglish = false;
                var noAutoTranslate = true;
                userAcceptLanguage = languages[0].split("-")[0];
                for (i = 0; i < languages.length; i++) {
                    languages[i] = languages[i].split(";")[0];
                    if (languages[i].substring(0, 2) == "en") {
                        hasEnglish = true;
                        //user has "en" somewhere in their list of browser languages
                    }
                }
                //Check for the no translate languages.
                for (var i = 0; i < noAutoTranslateLangs.length; i++) {
                    if (languages[0].substring(0, 2) == noAutoTranslateLangs[i])
                        noAutoTranslate = true;
                }
                if (!hasEnglish && !noAutoTranslate) {
                    //user does NOT have "en" in their list of browser languages and noAutoTranslate is not true, meaning it should autotranslate.
                    setTimeout("Microsoft.Translator.Translate(document.body, '', userAcceptLanguage)", 1000);
                    modifyTranslatorToolbarStyles();
                }
            }, 1000);
        }
    });
}


$(document).ready(function (e) {
	modifyTranslatorToolbarStyles();
	var currURL = document.URL.toLowerCase();
	if (currURL.indexOf("/visualstudio/en-us") != -1) {

		getLanguageAndTranslate();
	}
});

/* API for MS Translator:  http://www.microsofttranslator.com/dev/ */


function MediaStateChanged(state, mediaName, timeMark, MediaLength) {

    var temp = mediaName.split("|");
    var name = temp[0];
    var source = temp[1].replace(DEP.Settings["streaming_root"], "");
    
    switch (state)
    {
        case "Stop":
        
            //alert("Stop");
            break;

        case "Opened":
        
            //alert("Opened");
            //alert(mediaName);
            break;

        case "Ended":

            // fire each ended event
            for (var e in videoEndEvents[name]) {
                videoEndEvents[name][e].Fire();
            }

            break;

        case "CompleteMarkerReached":

            // fire each event
            for (var e in videoMarkerEvents[name]) {
                videoMarkerEvents[name][e].Fire();
            }

            break;
    }
}

var videoEndEvents = [];
var videoMarkerEvents = [];

function InitVideoEvents(id) {

    if (videoEndEvents[id] == null || videoEndEvents[id] == "undefined") {
        //alert("videoEndEvents | " + videoEndEvents[id] + " | " + id);
        videoEndEvents[id] = [];
    }

    if (videoMarkerEvents[id] == null || videoMarkerEvents[id] == "undefined") {
        //alert("videoMarkerEvents | " + videoMarkerEvents[id] + " | " + id);
        videoMarkerEvents[id] = [];
    }
}

function OpenMediaFromUri(playerId, mediaSource, title, description, isAdaptiveStreaming, autoPlay) {

    // get player
    var SLPlugin = $("#sl-" + playerId).get(0);
    var thumbSource = "";

    // make call to play passed media
    var strOut = SLPlugin.Content.Player.PlayMediaFromUri(playerId, mediaSource, thumbSource, title, description, isAdaptiveStreaming, autoPlay);
}

//function CloseMedia(mediaContainer) {
//    alert(mediaContainer);
//    $('#' + mediaContainer).innerHtml = "";
//}

//function LoadPlaylist(listName, autoplay) {
//    var SLPlugin = document.getElementById("SLP");
//    var strOut = SLPlugin.Content.Player.LoadPlaylist(listName, autoplay);

//}

//function LoadPlaylistItem(listName, playListItemId, autoplay) {
//    var SLPlugin = document.getElementById("SLP");
//    var strListOut = SLPlugin.Content.Player.LoadPlaylist(listName, false);
//    var strItemOut = SLPlugin.Content.Player.SetPlayListItem(playListItemId, autoplay);
//}


//function SetPlayListItem(playListItemId, autoplay) {
//    var SLPlugin = document.getElementById("SLP");
//    var strOut = SLPlugin.Content.Player.SetPlayListItem(playListItemId, autoplay);

//}


// Big button purple mouse over event handler
$(function()
{
    if (!isIE6)
    {      

        $(".button_purple_big").live("mouseover", function(e)
        {

            // swap left image
            var image = $(".button_purple_big_left", this).attr("src").replace(/_purple_/ig, "_blue_");
            $(".button_purple_big_left", this).attr("src", image);

            // update right class name
            var className = $(".button_purple_big_right", this).attr("class") + " over_purple_big";
            $(".button_purple_big_right", this).attr("class", className);

            // swap arrow image
            image = $(".button_purple_big_arrow", this).attr("src").replace(/_purple_/ig, "_blue_");
            $(".button_purple_big_arrow", this).attr("src", image);

            // update class name
            className = $(this).attr("class") + " over_purple_big";
            $(this).attr("class", className);
        });
    }
});

// Big button purple mouse out event handler
$(function()
{
    if (!isIE6)
    {
        $(".button_purple_big").live("mouseout", function(e)
        {
            // swap left image
            var image = $(".button_purple_big_left", this).attr("src").replace(/_blue_/ig, "_purple_");
            $(".button_purple_big_left", this).attr("src", image);

            // swap right image
            var className = $(".button_purple_big_right", this).attr("class").replace(/ over_purple_big/ig, "");
            $(".button_purple_big_right", this).attr("class", className);

            // swap arrow image
            image = $(".button_purple_big_arrow", this).attr("src").replace(/_blue_/ig, "_purple_");
            $(".button_purple_big_arrow", this).attr("src", image);

            // update class name
            className = $(this).attr("class").replace(/ over_purple_big/ig, "");
            $(this).attr("class", className);
        });
    }
});/* Click Handler */
var HeroConvertibleVideoEndHandler = new DEPEventHandler("HeroConvertibleVideoEnd");
HeroConvertibleVideoEndHandler.AllowNavigation = false;
HeroConvertibleVideoEndHandler.HandlerFunction = function (e) {
    // animate video disappearing.
    $("#" + e.Arguments["videoId"]).slideUp(500);
}
DEP.AddEventHandler(HeroConvertibleVideoEndHandler);

var HeroConvertibleVideoCloseHandler = new DEPClickEventHandler("HeroConvertibleVideoClose");
HeroConvertibleVideoCloseHandler.AllowNavigation = false;
HeroConvertibleVideoCloseHandler.HandlerFunction = function (e) {
    // animate video disappearing.
    $("#" + e.Arguments["videoId"]).slideUp(500);
    try {
        var objects = $("object")
        for (var i = 0; i < objects.length; i++) {
            try { objects[i].Content.Player.Pause(); }
            catch (ex) { }
        }
    }
    catch (ex) { }
}
DEP.AddClickEventHandler(HeroConvertibleVideoCloseHandler);
$(document).ready(function() {
    $(".child_row").addClass("hidden");
});


var TableRowExpandClickHandler = new DEPClickEventHandler("TableRowExpandClick");

TableRowExpandClickHandler.HandlerFunction = function (e) {
    //    Make all the rows hidden only for the Express download table.
    if (e.Arguments["id"].indexOf("express") > 0) {
        $(".child_row").addClass("hidden");
        $("." + e.Arguments["id"] + "_group_child_row").toggleClass("hidden");
    }
    else {
        $("." + 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");
        }
    }

    //icon.src = icon.src.replace("nav_inactive", "nav_active");
}

DEP.AddClickEventHandler(TableRowExpandClickHandler);
// small button purple mouse over event handler
$(function()
{
    if (!isIE6)
    {
        $(".button_purple_small").live("mouseover", function(e)
        {

            // swap left image
            var image = $(".button_purple_small_left", this).attr("src").replace(/_purplesm_/ig, "_bluesm_");
            $(".button_purple_small_left", this).attr("src", image);

            // update right class name
            var className = $(".button_purple_small_right", this).attr("class") + " over_purple_small";
            $(".button_purple_small_right", this).attr("class", className);

            // swap arrow image
            image = $(".button_purple_small_arrow", this).attr("src").replace(/_purplesm_/ig, "_bluesm_");
            $(".button_purple_small_arrow", this).attr("src", image);

            // update class name
            className = $(this).attr("class") + " over_purple_small";
            $(this).attr("class", className);
        });
    }
});

// small button purple mouse out event handler
$(function()
{
    if (!isIE6)
    {
        $(".button_purple_small").live("mouseout", function(e)
        {
            // swap left image
            var image = $(".button_purple_small_left", this).attr("src").replace(/_bluesm_/ig, "_purplesm_");
            $(".button_purple_small_left", this).attr("src", image);

            // swap right image
            var className = $(".button_purple_small_right", this).attr("class").replace(/ over_purple_small/ig, "");
            $(".button_purple_small_right", this).attr("class", className);

            // swap arrow image
            image = $(".button_purple_small_arrow", this).attr("src").replace(/_bluesm_/ig, "_purplesm_");
            $(".button_purple_small_arrow", this).attr("src", image);

            // update class name
            className = $(this).attr("class").replace(/ over_purple_small/ig, "");
            $(this).attr("class", className);
        });
    }
});

var TertiaryNavClickHandler = new DEPClickEventHandler("TertiaryNavClick");

TertiaryNavClickHandler.HandlerFunction = function (e) {

    var nav = $("#nav-tertiary");
    nav.find("div.tertiary_nav_item_divider").css("border-width", "1px").css("height", "0");
    var icon = nav.children(".tertiary_nav_item_selected").find(".tertiary_nav_item_icon")[0];
    icon.src = icon.src.replace("nav_active", "nav_inactive");
    nav.children(".tertiary_nav_item_selected").removeClass("tertiary_nav_item_selected").addClass("tertiary_nav_item");
    $(e.sender).parent().removeClass("tertiary_nav_item").addClass("tertiary_nav_item_selected");

    var newItem = nav.children(".tertiary_nav_item_selected");
    icon = newItem.find(".tertiary_nav_item_icon")[0];
    icon.src = icon.src.replace("nav_inactive", "nav_active");

    newItem.prev().css("border-width", "0").css("height", "1px");

    var success = false;
    var url = MakeUrlUnique(e.Arguments["url"]);

    $.get(url, function (data) {
        success = true;
        $("#tab-content").html(data);
        //        lpAddMonitorTag();
    });

    //This is for the ClickTale event.
    var CTobjidaj=$(e.sender).parent().attr("id");
    if(typeof ClickTaleExec == 'function')
        ClickTaleExec("AjaxClickTaleExec('" + CTobjidaj + "')");


    //    if (!success)
    //        this.AllowNavigation = true;
}

DEP.AddClickEventHandler(TertiaryNavClickHandler);

var TertiaryNavInlineClickHandler = new DEPClickEventHandler("TertiaryNavInlineClick");
TertiaryNavInlineClickHandler.HandlerFunction = function (e) {


    var url = MakeUrlUnique(DEP.Settings["site_root"] + e.Arguments["url"] + "?mode=fragment");

    $.get(url, function (data) {
        $("#tab-content").html(data);
    });

    var nav = $("#nav-tertiary");
    nav.find("div.tertiary_nav_item_divider").css("border-width", "1px").css("height", "0");
    var icon = nav.children(".tertiary_nav_item_selected").find(".tertiary_nav_item_icon")[0];
    icon.src = icon.src.replace("nav_active", "nav_inactive");
    nav.children(".tertiary_nav_item_selected").removeClass("tertiary_nav_item_selected").addClass("tertiary_nav_item");
    $("#" + e.Arguments["pageId"]).removeClass("tertiary_nav_item").addClass("tertiary_nav_item_selected");

    var newItem = nav.children(".tertiary_nav_item_selected");
    icon = newItem.find(".tertiary_nav_item_icon")[0];
    icon.src = icon.src.replace("nav_inactive", "nav_active");

    newItem.prev().css("border-width", "0").css("height", "1px");
}

DEP.AddClickEventHandler(TertiaryNavInlineClickHandler);

// Big button purple mouse over event handler
$(function()
{
    if (!isIE6)
    {
        
        $(".button_white_small").live("mouseover", function(e)
        {
            // swap left image
            var image = $(".button_white_small_left", this).attr("src").replace(/_gray_/ig, "_white_");
            $(".button_white_small_left", this).attr("src", image);

            // update right class name
            var className = $(".button_white_small_right", this).attr("class") + " over_white_small";
            $(".button_white_small_right", this).attr("class", className);

            //        // swap arrow image
            image = $(".button_white_small_arrow", this).attr("src").replace(/_gray_/ig, "_white_");
            $(".button_white_small_arrow", this).attr("src", image);

            // update class name
            className = $(this).attr("class") + " over_white_small";
            $(this).attr("class", className);
        });
    }
});

// Big button purple mouse out event handler
$(function()
{
    if (!isIE6)
    {
        $(".button_white_small").live("mouseout", function(e)
        {
            // swap left image
            var image = $(".button_white_small_left", this).attr("src").replace(/_white_/ig, "_gray_");
            $(".button_white_small_left", this).attr("src", image);

            // swap right image
            var className = $(".button_white_small_right", this).attr("class").replace(/ over_white_small/ig, "");
            $(".button_white_small_right", this).attr("class", className);

            // swap arrow image
            image = $(".button_white_small_arrow", this).attr("src").replace(/_white_/ig, "_gray_");
            $(".button_white_small_arrow", this).attr("src", image);

            // update class name
            className = $(this).attr("class").replace(/ over_white_small/ig, "");
            $(this).attr("class", className);
        });
    }
});
// Big button blue mouse over event handler
$(function()
{
    if (!isIE6)
    {      

        $(".button_blue_big").live("mouseover", function(e)
        {

            // swap left image
            var image = $(".button_blue_big_left", this).attr("src").replace(/_blue_/ig, "_purple_");
            $(".button_blue_big_left", this).attr("src", image);

            // update right class name
            var className = $(".button_blue_big_right", this).attr("class") + " over_purple_big";
            $(".button_blue_big_right", this).attr("class", className);

            // swap arrow image
            image = $(".button_blue_big_arrow", this).attr("src").replace(/_blue_/ig, "_purple_");
            $(".button_blue_big_arrow", this).attr("src", image);

            // update class name
            className = $(this).attr("class") + " over_purple_big";
            $(this).attr("class", className);
        });
    }
});

// Big button blue mouse out event handler
$(function()
{
    if (!isIE6)
    {
        $(".button_blue_big").live("mouseout", function(e)
        {
            // swap left image
            var image = $(".button_blue_big_left", this).attr("src").replace(/_purple_/ig, "_blue_");
            $(".button_blue_big_left", this).attr("src", image);

            // swap right image
            var className = $(".button_blue_big_right", this).attr("class").replace(/ over_purple_big/ig, "");
            $(".button_blue_big_right", this).attr("class", className);

            // swap arrow image
            image = $(".button_blue_big_arrow", this).attr("src").replace(/_purple_/ig, "_blue_");
            $(".button_blue_big_arrow", this).attr("src", image);

            // update class name
            className = $(this).attr("class").replace(/ over_purple_big/ig, "");
            $(this).attr("class", className);
        });
    }
});
var ScollerPromoClickHandler = new DEPEventHandler("ScrollerPromoClick");
ScollerPromoClickHandler.AllowNavigation = false;
ScollerPromoClickHandler.HandlerFunction = function (e) {
    return false;
}
DEP.AddEventHandler(ScollerPromoClickHandler);

var ScrollerPreviousClickHandler = new DEPEventHandler("ScrollerPreviousClick");
ScrollerPreviousClickHandler.AllowNavigation = false;
ScrollerPreviousClickHandler.HandlerFunction = function (e) {
    $("a.scroller_previous").bind("click", function () {
        carousel.prev();
        //Call this so that the cufon text will show up again after clicking the scroller.
        Cufon.refresh();
        return false;
    });
}
DEP.AddEventHandler(ScrollerPreviousClickHandler);

var ScrollerNextClickHandler = new DEPEventHandler("ScrollerNextClick");
ScrollerNextClickHandler.AllowNavigation = false;
ScrollerNextClickHandler.HandlerFunction = function (e) {
    $("a.scroller_next").bind("click", function () {
        carousel.next();
        //Call this so that the cufon text will show up again after clicking the scroller.
        Cufon.refresh();
        return false;
    });
}
DEP.AddEventHandler(ScrollerNextClickHandler);

function videoCarousel_initCallback(carousel) {
    $("a.scroller_previous").bind("click", function () {
        carousel.prev();
        //Call this so that the cufon text will show up again after clicking the scroller.
        Cufon.refresh();
        return false;
    });

    $("a.scroller_next").bind("click", function () {
        carousel.next();
        //Call this so that the cufon text will show up again after clicking the scroller.
        Cufon.refresh();
        return false;
    });
}///<reference path="../../script/jquery/jquery-1.4.2.min.js"/>
///<reference path="../../script/dep.js"/>
/* module: language-display-express */

//Hover state for non-selected items.
$(function () {
    $(".primary_nav_variant_item").hover(function (e) {
        var className = $(".primary_nav_variant_item_link", this).attr("class") + " over_nav_variant_item_link";
        $(".primary_nav_variant_item_link", this).attr("class", className);
    },

    //    $(".primary_nav_variant_item").mouseleave(function (e) {
    function (e) {
        var className = $(".primary_nav_variant_item_link", this).attr("class").replace(/ over_nav_variant_item_link/ig, "");
        $(".primary_nav_variant_item_link", this).attr("class", className);
    });
});

//Hover state for non-selected last item.
$(function () {
    $(".primary_nav_variant_item_last").hover(function (e) {
        var className = $(".primary_nav_variant_item_link_last", this).attr("class") + " over_nav_variant_item_link";
        $(".primary_nav_variant_item_link_last", this).attr("class", className);
    },
    //    $(".primary_nav_variant_item").mouseleave(function (e) {
    function (e) {
        var className = $(".primary_nav_variant_item_link_last", this).attr("class").replace(/ over_nav_variant_item_link/ig, "");
        $(".primary_nav_variant_item_link_last", this).attr("class", className);
    });
});

//Hover state for selected items.
$(function () {
    $(".primary_nav_variant_item_selected").hover(function (e) {
        var className = $(".primary_nav_variant_item_link_selected", this).attr("class") + " over_nav_variant_item_link_selected";
        $(".primary_nav_variant_item_link_selected", this).attr("class", className);
    },

    //    $(".primary_nav_variant_item").mouseleave(function (e) {
    function (e) {
        var className = $(".primary_nav_variant_item_link_selected", this).attr("class").replace(/ over_nav_variant_item_link_selected/ig, "");
        $(".primary_nav_variant_item_link_selected", this).attr("class", className);
    });
});

//Hover state for selected last item.
$(function () {
    $(".primary_nav_variant_item_last_selected").hover(function (e) {
        var className = $(".primary_nav_variant_item_link_last_selected", this).attr("class") + " over_nav_variant_item_link_selected";
        $(".primary_nav_variant_item_link_last_selected", this).attr("class", className);
    },

    //    $(".primary_nav_variant_item").mouseleave(function (e) {
    function (e) {
        var className = $(".primary_nav_variant_item_link_last_selected", this).attr("class").replace(/ over_nav_variant_item_link_selected/ig, "");
        $(".primary_nav_variant_item_link_last_selected", this).attr("class", className);
    });
});

//Show drop down.
$(function () {
    $(".primary_nav_variant_item, .primary_nav_variant_item_last, .primary_nav_variant_item_selected, .primary_nav_variant_item_last_selected").hover(function (e) {
        //Show without animation.
        $(".primary_nav_variant_dropdown", this).css("display", "block");
    },

    //    $(".primary_nav_variant_item").mouseleave(function (e) {
    function (e) {
        $(this).find(".primary_nav_variant_dropdown").stop(true, true);
        //Hide drop down without animation.
        $(".primary_nav_variant_dropdown", this).attr("style", "display:none");
    });
});
//$(document).ready(function () {
//    $(".nav-bar-products").mouseenter(navOpen);
//    $(".nav-bar-products").mouseleave(navStartCloseTimer);

//    navCurrentFeature = "";
//    navLinkTimer = 0;
//    navExpanded = false;
//    navCloseAfterOpen = false;
//    navCloseTimer = 0;
//    navUseOpacity = jQuery.support.opacity;

//    if (!navUseOpacity) {
//        $(".nav-bar-products_drop_down_menu_wrapper").css("opacity", "");
//        $(".nav-bar-products_drop_down_menu").css("opacity", "");
//        $(".nav_top").css("opacity", "");
//        $(".nav_top_selected").css("opacity", "");
//        $(".nav_bottom").css("opacity", "");
//        $(".nav_bottom_selected").css("opacity", "");
//        $(".white_button").css("opacity", "");
//    }

//    $(function () {
//        $("#testPro").hover(function (e) {
//            $(this).find("div.other_prods_text").addClass("over_bottom_white");
//            $(this).find("div.other_prods_details").addClass("over_bottom_white");
//            $(this).addClass("over_other_prods");
//        },
//        function (e) {
//            $(this).removeClass("over_other_prods");
//            $(this).find("div.other_prods_text").removeClass("over_bottom_white");
//            $(this).find("div.other_prods_details").removeClass("over_bottom_white");
//        });
//    });
//});

//function navOpen() {
//    navCloseAfterOpen = false;
//    if (navUseOpacity) {
//        $(".nav-bar-products_drop_down_menu_wrapper").fadeTo(100, 1);
//        $(".nav_top_image").fadeTo(100, 1);
//        $(".nav_top_product_title").fadeTo(100, 1);
//        $(".nav_top_product_description").fadeTo(100, 1);
//        $(".nav_top_product_title-other-products").fadeTo(100, 1);
//        $(".other_prods").fadeTo(100, 1);
//        $(".other_prods_divider").fadeTo(100, 1);
//        $(".feature_info").fadeTo(100, 1);
//        $(".white_button").fadeTo(100, 1);
//        $(".nav-bar-products_drop_down_bottom_border").fadeTo(100, 1);
//        $(".nav-bar-products_drop_down_menu_wrapper").fadeTo(100, 1, navAnim1);
//    } else {
//        $(".nav-bar-products_drop_down_menu_wrapper").css("display", "block");
//        $(".nav-bar-products_drop_down_left_border").fadeIn(100);
//        $(".nav_top_image").fadeIn(100);
//        $(".nav_top_product_title").fadeIn(100);
//        $(".nav_top_product_description").fadeIn(100);
//        $(".nav_top_product_title-other-products").fadeIn(100);
//        $(".other_prods").fadeIn(100);
//        $(".other_prods_divider").fadeIn(100);
//        $(".feature_info").fadeIn(100);
//        $(".white_button").fadeIn(100);
//        $(".nav-bar-products_drop_down_bottom_border").fadeIn(100);
//        $(".nav-bar-products_drop_down_menu_wrapper").fadeIn(100, navAnim1);
//    }
//}

//function navAnim1() {
//    if (!navUseOpacity) {
//        $(".nav-bar-products_drop_down_menu_wrapper").fadeOut(0);
//        $(".nav-bar-products_drop_down_bottom_border").fadeOut(0);
//        $(".feature_info").fadeOut(0);
//        $(".other_prods").fadeOut(0);
//        $(".other_prods_divider").fadeOut(0);
//        $(".nav_top").fadeOut(0);
//        $(".nav_top_selected").fadeOut(0);
//        $(".nav_bottom").fadeOut(0);
//        $(".nav_bottom_selected").fadeOut(0);
//        $(".white_button").fadeOut(0);
//    }
//    $(".nav-bar-products_drop_down_menu_wrapper", this).css("clear", "both");
//    setTimeout("navAnim2();", 150);
//    setTimeout("navAnim3();", 200);
//    setTimeout("navAnim4();", 250);
//}

//function navAnim2() {
//    //$(".nav-bar-products_drop_down_menu_wrapper").delay(500).animate({ height: "426px" }, 500);
//    if (navUseOpacity) {
//        $(".nav-bar-products_drop_down_menu_wrapper").delay(500).animate({ height: "426px" }, 500);
//        $(".nav_top").fadeTo(100, 1);
//        $(".nav_top_selected").fadeTo(100, 1);
//        $(".nav-bar-products_drop_down_bottom_border").fadeTo(100, 1);
//        $(".nav_top_image").fadeTo(100, 1);
//        $(".nav_top_product_title").fadeTo(100, 1);
//        $(".nav_top_product_description").fadeTo(100, 1);
//        $(".nav_top_product_title-other-products").fadeTo(100, 1);
//    } else {
//        $(".nav-bar-products_drop_down_menu_wrapper").delay(500).animate({ height: "426px" }, 300);
//        $(".nav_top").fadeIn(100);
//        $(".nav_top_selected").fadeIn(100);
//        $(".nav-bar-products_drop_down_bottom_border").fadeIn(100);
//        $(".nav_top_image").fadeIn(100);
//        $(".nav_top_product_title").fadeIn(100);
//        $(".nav_top_product_description").fadeIn(100);
//        $(".nav_top_product_title-other-products").fadeIn(100);
//    }
//    if (typeof (IEPNGFix) !== 'undefined') { IEPNGFix.update(); }
//}

//function navAnim3() {
//    if (navUseOpacity) {
//        $(".nav_bottom").fadeTo(100, 1);
//        $(".nav_bottom").animate({ height: "318px", opacity: 1 }, 300);
//        $(".nav_bottom_selected").fadeTo(100, 1);
//        $(".nav_bottom_selected").animate({ height: "318px", opacity: 1 }, 300);
//        $(".feature_info").fadeTo(100, 1);
//        $(".other_prods").fadeTo(100, 1);
//        $(".nav-bar-products_drop_down_left_border").fadeTo(100, 1);
//        $(".nav-bar-products_drop_down_right_border").fadeTo(100, 1);
//    } else {
//        $(".nav_bottom").animate({ height: "315px" }, 100);
//        $(".nav_bottom_selected").animate({ height: "315px" }, 100);
//        $(".feature_info").fadeIn(100);
//        $(".other_prods").fadeIn(100);
//        $(".nav-bar-products_drop_down_left_border").fadeIn(100);
//        $(".nav-bar-products_drop_down_right_border").fadeIn(100);
//    }
//}

//function navAnim4() {
//    if (navUseOpacity) {
//        $(".white_button").fadeTo(100, 1, navOpenComplete);
//        $(".nav-bar-products_drop_down_bottom_border").fadeTo(100, 1);
//    } else {
//        $(".white_button").fadeIn(100, navOpenComplete);
//        $(".nav-bar-products_drop_down_bottom_border").fadeIn(100);
//    }
//    if (typeof (IEPNGFix) !== 'undefined') { IEPNGFix.update(); }
//}

//function navOpenComplete() {
//    navExpanded = true;
//    if (navCloseAfterOpen) {
//        navCloseAfterOpen = false;
//        navStartCloseTimer();
//    }
//}

//function navStartCloseTimer() {
//    if (navExpanded) {
//        navCloseTimer = setTimeout("navCloseDropDown();", 100);
//        $(".nav-bar-products_drop_down_menu_wrapper").mouseenter(navStopCloseTimer);
//        $(".nav-bar-products_drop_down_menu").mouseenter(navStopCloseTimer);
//        $(".nav-bar-products").stop(true, true);
//    } else {
//        navCloseAfterOpen = true;

//    }
//}

//function navStopCloseTimer() {
//    clearTimeout(navCloseTimer);
//    $(".nav-bar-products_drop_down_menu_wrapper").unbind("mouseenter", navStopCloseTimer);
//    $(".nav-bar-products").unbind("mouseenter", navStopCloseTimer);
//    $(".nav-bar-products_drop_down_menu_wrapper").stop(true, true);
//    $(".nav-bar-products").stop(true, true);
//}

//function navCloseDropDown() {
//    $(".nav-bar-products_drop_down_menu_wrapper").unbind("mouseenter", navStopCloseTimer);
//    $(".nav-bar-products").unbind("mouseenter", navStopCloseTimer);

//    $(".nav-bar-products_drop_down_menu_wrapper").stop(true, true);
//    $(".nav-bar-products").stop(true, true);

//    navExpanded = false;
//    $(".nav-bar-products_drop_down_menu_wrapper").animate({ height: "0px" }, 300, navResetStyles);

//    if (navUseOpacity) {
//        $(".white_button").fadeTo(100, 0);
//        $(".nav_bottom").animate({ height: "0px", opacity: 0 }, 300);
//        $(".nav_bottom_selected").animate({ height: "0px", opacity: 0 }, 300);
////        $(".nav_top").fadeTo(250, 0);
////        $(".nav_top_selected").fadeTo(250, 0);
//        $(".nav-bar-products_drop_down_left_border").fadeTo(250, 0);
//        $(".nav-bar-products_drop_down_right_border").fadeTo(250, 0);
//    } else {
//        $(".white_button").fadeOut(100);
//        $(".nav_bottom").animate({ height: "0px" }, 300);
//        $(".nav_bottom_selected").animate({ height: "0px" }, 300);
////        $(".nav_top").fadeOut(250);
////        $(".nav_top_selected").fadeOut(250);
//        $(".nav-bar-products_drop_down_left_border").fadeOut(250);
//        $(".nav-bar-products_drop_down_right_border").fadeOut(250);
//    }
//}

//function navResetStyles() {
//    $(".nav-bar-products_drop_down_menu_wrapper").css("display", "none");
//    //$(".nav-bar-products_drop_down_menu_wrapper").css("height", "0px");
//    $(".nav_bottom").css("height", "0px");

//    if (navUseOpacity) {
//        $(".nav_bottom").css("opacity", "0");
//        $(".nav_bottom_selected").css("opacity", "0");
//        $(".nav_top").css("opacity", "0");
//        $(".nav_top_selected").css("opacity", "0");
//        $(".white_button").css("opacity", "0");
//    } else {
//        $(".nav_top").fadeIn(0);
//        $(".nav_top_selected").fadeIn(0);
//        $(".nav_bottom").fadeIn(0);
//        $(".nav_bottom_selected").fadeIn(0);
//        $(".white_button").fadeIn(0);
//    }
//}

////Hover over top of each product.
//$(function () {
//    $("#vs-professional-2010").hover(function (e) {
//        $("#top-vs-professional-2010").addClass(" over_top");
//        $("#bottom-vs-professional-2010").addClass(" over_bottom");
//        $("#vs-professional-2010").find("div.nav_top_product_description").addClass("nav_top_product_description_over");
//    },
//    function (e) {
//        $("#top-vs-professional-2010").removeClass(" over_top");
//        $("#bottom-vs-professional-2010").removeClass(" over_bottom");
//        $("#vs-professional-2010").find("div.nav_top_product_description").removeClass("nav_top_product_description_over");
//    });
//});

////Hover over top of each product.
//$(function () {
//    $("#vs-premium-2010").hover(function (e) {
//        $("#top-vs-premium-2010").addClass(" over_top");
//        $("#bottom-vs-premium-2010").addClass(" over_bottom");
//        $("#vs-premium-2010").find("div.nav_top_product_description").addClass("nav_top_product_description_over");
//    },
//    function (e) {
//        $("#top-vs-premium-2010").removeClass(" over_top");
//        $("#bottom-vs-premium-2010").removeClass(" over_bottom");
//        $("#vs-premium-2010").find("div.nav_top_product_description").removeClass("nav_top_product_description_over");
//    });
//});

////Hover over top of each product.
//$(function () {
//    $("#vs-ultimate-2010").hover(function (e) {
//        $("#top-vs-ultimate-2010").addClass(" over_top");
//        $("#bottom-vs-ultimate-2010").addClass(" over_bottom");
//        $("#vs-ultimate-2010").find("div.nav_top_product_description").addClass("nav_top_product_description_over");
//    },
//    function (e) {
//        $("#top-vs-ultimate-2010").removeClass(" over_top");
//        $("#bottom-vs-ultimate-2010").removeClass(" over_bottom");
//        $("#vs-ultimate-2010").find("div.nav_top_product_description").removeClass("nav_top_product_description_over");
//    });
//});

////For hovering over other products, only highlight the top.
//$(function () {
//    $("#other-products").hover(function (e) {
//        $("#top-other-products").addClass(" over_top");
//    },
//    function (e) {
//        $("#top-other-products").removeClass(" over_top");
//    });
//});

////This is to make the features all turn a certain color when hovering over any features.
//$(function () {
//    $("#bottom-vs-professional-2010").hover(function (e) {
//        $(".nav-bar-products_drop_down_menu").find("div.features_text").addClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.features_text_details").addClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_text").addClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_details").addClass("over_bottom_light_gray");
//        $(function () {
//            $(".ide_block").hover(function (e) {
//                $(".ide_text").addClass("over_bottom_white");
//                $(".ide_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".ide_text").removeClass("over_bottom_white");
//                $(".ide_arrow").removeClass(" over_arrow");
//            });
//            $(".ide_block").click(function () {
//                webTrendsSetVarClick("VS2010Pro", "IDE");
//            });
//        });
//        $(function () {
//            $(".dps_block").hover(function (e) {
//                $(".dps_text").addClass("over_bottom_white");
//                $(".dps_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".dps_text").removeClass("over_bottom_white");
//                $(".dps_arrow").removeClass(" over_arrow");
//            });
//            $(".dps_block").click(function () {
//                webTrendsSetVarClick("VS2010Pro", "DPS");
//            });
//        });
//        $(function () {
//            $(".tfsFeature_block").hover(function (e) {
//                $(".tfsFeature_text").addClass("over_bottom_white");
//                $(".tfsFeature_text_details").addClass("over_bottom_white");
//                $(".tfsFeature_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".tfsFeature_text").removeClass("over_bottom_white");
//                $(".tfsFeature_text_details").removeClass("over_bottom_white");
//                $(".tfsFeature_arrow").removeClass(" over_arrow");
//            });
//            $(".tfsFeature_block").click(function () {
//                webTrendsSetVarClick("VS2010Pro", "TFS");
//            });
//        });
//        $(function () {
//            $(".msdnsub_block").hover(function (e) {
//                $(".msdnsub_text").addClass("over_bottom_white");
//                $(".msdnsub_text_details").addClass("over_bottom_white");
//                $(".msdnsub_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".msdnsub_text").removeClass("over_bottom_white");
//                $(".msdnsub_text_details").removeClass("over_bottom_white");
//                $(".msdnsub_arrow").removeClass(" over_arrow");
//            });
//        });
//        $(".msdnsub_block").click(function () {
//            webTrendsSetVarClick("VS2010Pro", "MSDNSub");
//        });
//    },
//    function (e) {
//        $(".nav-bar-products_drop_down_menu").find("div.features_text").removeClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.features_text_details").removeClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_text").removeClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_details").removeClass("over_bottom_light_gray");
//    });
//});
//$(function () {
//    $("#bottom-vs-premium-2010").hover(function (e) {
//        $(".nav-bar-products_drop_down_menu").find("div.features_text").addClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.features_text_details").addClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_text").addClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_details").addClass("over_bottom_light_gray");
//        $(function () {
//            $(".ide_block").hover(function (e) {
//                $(".ide_text").addClass("over_bottom_white");
//                $(".ide_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".ide_text").removeClass("over_bottom_white");
//                $(".ide_arrow").removeClass(" over_arrow");
//            });
//            $(".ide_block").click(function () {
//                webTrendsSetVarClick("VS2010Prem", "IDE");
//            });
//        });
//        $(function () {
//            $(".dps_block").hover(function (e) {
//                $(".dps_text").addClass("over_bottom_white");
//                $(".dps_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".dps_text").removeClass("over_bottom_white");
//                $(".dps_arrow").removeClass(" over_arrow");
//            });
//            $(".dps_block").click(function () {
//                webTrendsSetVarClick("VS2010Prem", "DPS");
//            });
//        });
//        $(function () {
//            $(".tfsFeature_block").hover(function (e) {
//                $(".tfsFeature_text").addClass("over_bottom_white");
//                $(".tfsFeature_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".tfsFeature_text").removeClass("over_bottom_white");
//                $(".tfsFeature_arrow").removeClass(" over_arrow");
//            });
//            $(".tfsFeature_block").click(function () {
//                webTrendsSetVarClick("VS2010Prem", "TFS");
//            });
//        });
//        $(function () {
//            $(".msdnsub_block").hover(function (e) {
//                $(".msdnsub_text").addClass("over_bottom_white");
//                $(".msdnsub_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".msdnsub_text").removeClass("over_bottom_white");
//                $(".msdnsub_arrow").removeClass(" over_arrow");
//            });
//            $(".msdnsub_block").click(function () {
//                webTrendsSetVarClick("VS2010Prem", "MSDNSub");
//            });
//        });
//        $(function () {
//            $(".tt_block").hover(function (e) {
//                $(".tt_text").addClass("over_bottom_white");
//                $(".tt_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".tt_text").removeClass("over_bottom_white");
//                $(".tt_arrow").removeClass(" over_arrow");
//            });
//            $(".tt_block").click(function () {
//                webTrendsSetVarClick("VS2010Prem", "TestTools");
//            });
//        });
//        $(function () {
//            $(".dbdev_block").hover(function (e) {
//                $(".dbdev_text").addClass("over_bottom_white");
//                $(".dbdev_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".dbdev_text").removeClass("over_bottom_white");
//                $(".dbdev_arrow").removeClass(" over_arrow");
//            });
//            $(".dbdev_block").click(function () {
//                webTrendsSetVarClick("VS2010Prem", "DBDev");
//            });
//        });
//        $(function () {
//            $(".debug_block").hover(function (e) {
//                $(".debug_text").addClass("over_bottom_white");
//                $(".debug_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".debug_text").removeClass("over_bottom_white");
//                $(".debug_arrow").removeClass(" over_arrow");
//            });
//            $(".debug_block").click(function () {
//                webTrendsSetVarClick("VS2010Prem", "Debug");
//            });
//        });
//        $(function () {
//            $(".alm_block").hover(function (e) {
//                $(".alm_text").addClass("over_bottom_white");
//                $(".alm_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".alm_text").removeClass("over_bottom_white");
//                $(".alm_arrow").removeClass(" over_arrow");
//            });
//            $(".alm_block").click(function () {
//                webTrendsSetVarClick("VS2010Prem", "ALM");
//            });
//        });
//    },
//    function (e) {
//        $(".nav-bar-products_drop_down_menu").find("div.features_text").removeClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.features_text_details").removeClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_text").removeClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_details").removeClass("over_bottom_light_gray");
//    });
//});
//$(function () {
//    $("#bottom-vs-ultimate-2010").hover(function (e) {
//        $(".nav-bar-products_drop_down_menu").find("div.features_text").addClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.features_text_details").addClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_text").addClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_details").addClass("over_bottom_light_gray");
//        $(function () {
//            $(".ide_block").hover(function (e) {
//                $(".ide_text").addClass("over_bottom_white");
//                $(".ide_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".ide_text").removeClass("over_bottom_white");
//                $(".ide_arrow").removeClass(" over_arrow");
//            });
//            $(".ide_block").click(function () {
//                webTrendsSetVarClick("VS2010Ult", "IDE");
//            });
//        });
//        $(function () {
//            $(".dps_block").hover(function (e) {
//                $(".dps_text").addClass("over_bottom_white");
//                $(".dps_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".dps_text").removeClass("over_bottom_white");
//                $(".dps_arrow").removeClass(" over_arrow");
//            });
//            $(".dps_block").click(function () {
//                webTrendsSetVarClick("VS2010Ult", "DPS");
//            });
//        });
//        $(function () {
//            $(".tfsFeature_block").hover(function (e) {
//                $(".tfsFeature_text").addClass("over_bottom_white");
//                $(".tfsFeature_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".tfsFeature_text").removeClass("over_bottom_white");
//                $(".tfsFeature_arrow").removeClass(" over_arrow");
//            });
//            $(".tfsFeature_block").click(function () {
//                webTrendsSetVarClick("VS2010Ult", "TFS");
//            });
//        });
//        $(function () {
//            $(".msdnsub_block").hover(function (e) {
//                $(".msdnsub_text").addClass("over_bottom_white");
//                $(".msdnsub_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".msdnsub_text").removeClass("over_bottom_white");
//                $(".msdnsub_arrow").removeClass(" over_arrow");
//            });
//            $(".msdnsub_block").click(function () {
//                webTrendsSetVarClick("VS2010Ult", "MSDNSub");
//            });
//        });
//        $(function () {
//            $(".tt_block").hover(function (e) {
//                $(".tt_text").addClass("over_bottom_white");
//                $(".tt_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".tt_text").removeClass("over_bottom_white");
//                $(".tt_arrow").removeClass(" over_arrow");
//            });
//            $(".tt_block").click(function () {
//                webTrendsSetVarClick("VS2010Ult", "TestTools");
//            });
//        });
//        $(function () {
//            $(".dbdev_block").hover(function (e) {
//                $(".dbdev_text").addClass("over_bottom_white");
//                $(".dbdev_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".dbdev_text").removeClass("over_bottom_white");
//                $(".dbdev_arrow").removeClass(" over_arrow");
//            });
//            $(".dbdev_block").click(function () {
//                webTrendsSetVarClick("VS2010Ult", "DBDev");
//            });
//        });
//        $(function () {
//            $(".debug_block").hover(function (e) {
//                $(".debug_text").addClass("over_bottom_white");
//                $(".debug_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".debug_text").removeClass("over_bottom_white");
//                $(".debug_arrow").removeClass(" over_arrow");
//            });
//            $(".debug_block").click(function () {
//                webTrendsSetVarClick("VS2010Ult", "Debug");
//            });
//        });
//        $(function () {
//            $(".alm_block").hover(function (e) {
//                $(".alm_text").addClass("over_bottom_white");
//                $(".alm_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".alm_text").removeClass("over_bottom_white");
//                $(".alm_arrow").removeClass(" over_arrow");
//            });
//            $(".alm_block").click(function () {
//                webTrendsSetVarClick("VS2010Ult", "ALM");
//            });
//        });
//        $(function () {
//            $(".am_block").hover(function (e) {
//                $(".am_text").addClass("over_bottom_white");
//                $(".am_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".am_text").removeClass("over_bottom_white");
//                $(".am_arrow").removeClass(" over_arrow");
//            });
//            $(".am_block").click(function () {
//                webTrendsSetVarClick("VS2010Ult", "AM");
//            });
//        });
//        $(function () {
//            $(".labMgmtFeature_block").hover(function (e) {
//                $(".labMgmtFeature_text").addClass("over_bottom_white");
//                $(".labMgmtFeature_arrow").addClass(" over_arrow");
//            },
//            function (e) {
//                $(".labMgmtFeature_text").removeClass("over_bottom_white");
//                $(".labMgmtFeature_arrow").removeClass(" over_arrow");
//            });
//            $(".labMgmtFeature_block").click(function () {
//                webTrendsSetVarClick("VS2010Ult", "LabMgmt");
//            });
//        });
//    },
//    function (e) {
//        $(".nav-bar-products_drop_down_menu").find("div.features_text").removeClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.features_text_details").removeClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_text").removeClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_details").removeClass("over_bottom_light_gray");
//    });
//});
//$(function () {
//    $("#bottom-other-products").hover(function (e) {
//        $(".nav-bar-products_drop_down_menu").find("div.features_text").addClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.features_text_details").addClass("over_bottom_light_gray");
//        $(".other_prods_text").addClass("over_bottom_light_gray");
//        $(".other_prods_details").addClass("over_bottom_light_gray");
//        //Hover over each "other product"
//        $(function () {
//            $("#testPro").hover(function (e) {
//                $(this).find("div.other_prods_text").addClass("over_bottom_white");
//                $(this).find("div.other_prods_details").addClass("over_bottom_white");
//                $(this).addClass("over_other_prods");
//            },
//            function (e) {
//                $(this).removeClass("over_other_prods");
//                $(this).find("div.other_prods_text").removeClass("over_bottom_white");
//                $(this).find("div.other_prods_details").removeClass("over_bottom_white");
//            });
//            $("#testPro").click(function () {
//                webTrendsSetVarClick("OtherProds", "TestPro");
//            });
//        });
//        $(function () {
//            $("#tfs").hover(function (e) {
//                $(this).find("div.other_prods_text").addClass("over_bottom_white");
//                $(this).find("div.other_prods_details").addClass("over_bottom_white");
//                $(this).addClass("over_other_prods");
//            },
//            function (e) {
//                $(this).removeClass("over_other_prods");
//                $(this).find("div.other_prods_text").removeClass("over_bottom_white");
//                $(this).find("div.other_prods_details").removeClass("over_bottom_white");
//            });
//            $("#tfs").click(function () {
//                webTrendsSetVarClick("OtherProds", "TFS");
//            });
//        });
//        $(function () {
//            $("#tee").hover(function (e) {
//                $(this).find("div.other_prods_text").addClass("over_bottom_white");
//                $(this).find("div.other_prods_details").addClass("over_bottom_white");
//                $(this).addClass("over_other_prods");
//            },
//            function (e) {
//                $(this).removeClass("over_other_prods");
//                $(this).find("div.other_prods_text").removeClass("over_bottom_white");
//                $(this).find("div.other_prods_details").removeClass("over_bottom_white");
//            });
//            $("#tee").click(function () {
//                webTrendsSetVarClick("OtherProds", "TEE");
//            });
//        });
//        $(function () {
//            $("#labMgmt").hover(function (e) {
//                $(this).find("div.other_prods_text").addClass("over_bottom_white");
//                $(this).find("div.other_prods_details").addClass("over_bottom_white");
//                $(this).addClass("over_other_prods");
//            },
//            function (e) {
//                $(this).removeClass("over_other_prods");
//                $(this).find("div.other_prods_text").removeClass("over_bottom_white");
//                $(this).find("div.other_prods_details").removeClass("over_bottom_white");
//            });
//            $("#labMgmt").click(function () {
//                webTrendsSetVarClick("OtherProds", "LabMgmt");
//            });
//        });
//    },
//    function (e) {
//        $(".nav-bar-products_drop_down_menu").find("div.features_text").removeClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.features_text_details").removeClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_text").removeClass("over_bottom_light_gray");
//        $(".nav-bar-products_drop_down_menu").find("div.other_prods_details").removeClass("over_bottom_light_gray");
//    });
//});


/* For WebTrends Click Handler */
function webTrendsSetVarClick(prodName, featureName) {
    dcsSetVar("DCS.dcsuri", "/products/2010-editions/product_lightbox/" + prodName + "/" + featureName);
}///<reference path="../../script/jquery/jquery-1.4.2.min.js"/>
///<reference path="../../script/dep.js"/>
////module id: hero-selector

var HeroRotatorDotClick = new DEPClickEventHandler("HeroRotatorDotClick");
HeroRotatorDotClick.AllowNavigation = false;
HeroRotatorDotClick.HandlerFunction = function (e) {
    if (!hr.animating) {
        hr.animating = true;
        hr.stop();

        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);
        }
    }
}
DEP.AddClickEventHandler(HeroRotatorDotClick);

$(document).ready(function () {
    hr.start();
});


var hr = {
    interval: null,
    animating: false,

    start: function () {
        if ($(".hero-rotator").length > 0)
            hr.interval = setInterval(hr.playNext, 6000);
    },

    reset: function () {
        clearInterval(hr.interval);
        hr.start();
    },

    stop: function () {
        clearInterval(hr.interval);
    },

    updateDots: function (index) {

        var q = null;
        q = ".hero-rotator .controls > a img[class!='toggle']'";
        $(q).attr("src", $(q).attr("src").replace("purple", "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", "purple"));

    },

    playIn: function (hero) {

        var index = $(hero).index();

        $(hero).fadeIn(400, function () {
            hr.animating = false;
            $(hero).toggleClass("current", true);
        });

        hr.updateDots(index);
    },

    playOut: function (hero) {
        
        $(hero).fadeOut(400);
        $(hero).toggleClass("current", false);
    },


    playNext: function(){

        if (!hr.animating) {
            hr.animating = true;

            var q = ".hero-rotator .hero.current";

            // get current
            var current = $(q).get(0);
            var next = null;

            // get next            
            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);
        }
    
    
    }

}

//Hover state for non-selected items.
$(function () {
    $(".primary_nav_variant_item").hover(function (e) {
        var className = $(".primary_nav_variant_item_link", this).attr("class") + " over_nav_variant_item_link";
        $(".primary_nav_variant_item_link", this).attr("class", className);
    },

    //    $(".primary_nav_variant_item").mouseleave(function (e) {
    function (e) {
        var className = $(".primary_nav_variant_item_link", this).attr("class").replace(/ over_nav_variant_item_link/ig, "");
        $(".primary_nav_variant_item_link", this).attr("class", className);
    });
});

//Hover state for non-selected last item.
$(function () {
    $(".primary_nav_variant_item_last").hover(function (e) {
        var className = $(".primary_nav_variant_item_link_last", this).attr("class") + " over_nav_variant_item_link";
        $(".primary_nav_variant_item_link_last", this).attr("class", className);
    },
    //    $(".primary_nav_variant_item").mouseleave(function (e) {
    function (e) {
        var className = $(".primary_nav_variant_item_link_last", this).attr("class").replace(/ over_nav_variant_item_link/ig, "");
        $(".primary_nav_variant_item_link_last", this).attr("class", className);
    });
});

//Hover state for selected items.
$(function () {
    $(".primary_nav_variant_item_selected").hover(function (e) {
        var className = $(".primary_nav_variant_item_link_selected", this).attr("class") + " over_nav_variant_item_link_selected";
        $(".primary_nav_variant_item_link_selected", this).attr("class", className);
    },

    //    $(".primary_nav_variant_item").mouseleave(function (e) {
    function (e) {
        var className = $(".primary_nav_variant_item_link_selected", this).attr("class").replace(/ over_nav_variant_item_link_selected/ig, "");
        $(".primary_nav_variant_item_link_selected", this).attr("class", className);
    });
});

//Hover state for selected last item.
$(function () {
    $(".primary_nav_variant_item_last_selected").hover(function (e) {
        var className = $(".primary_nav_variant_item_link_last_selected", this).attr("class") + " over_nav_variant_item_link_selected";
        $(".primary_nav_variant_item_link_last_selected", this).attr("class", className);
    },

    //    $(".primary_nav_variant_item").mouseleave(function (e) {
    function (e) {
        var className = $(".primary_nav_variant_item_link_last_selected", this).attr("class").replace(/ over_nav_variant_item_link_selected/ig, "");
        $(".primary_nav_variant_item_link_last_selected", this).attr("class", className);
    });
});$(document).ready(function () {
    var images = new Array();
    var urls = new Array();
    images[0] = "/visualstudio/_base_v1/images/promos/sponsor_01_devexpress_ad_222x182.jpg";
    images[1] = "/visualstudio/_base_v1/images/promos/sponsor_02_infragistics_ad_222x182.jpg";
    images[2] = "/visualstudio/_base_v1/images/promos/sponsor_03_JetBrains_ad_222x182.png";
    images[3] = "/visualstudio/_base_v1/images/promos/sponsor_04_MicroFocus_ad_222x182.jpg";
    images[4] = "/visualstudio/_base_v1/images/promos/sponsor_05_Telerik_ad_222x182.jpg";
    images[5] = "/visualstudio/_base_v1/images/promos/sponsor_05_AppDev_ad_222x182.jpg";
    urls[0] = "http://www.devexpress.com/";
    urls[1] = "http://www.infragistics.com";
    urls[2] = "http://www.jetbrains.com/resharper/index.html";
    urls[3] = "http://www.microfocus.com";
    urls[4] = "http://www.telerik.com";
    urls[5] = "http://launchoffer.appdev.com";
    rotateImages(6, images, urls);
});

var SponsorsCardClickHandler = new DEPClickEventHandler("SponsorsCardClick");

SponsorsCardClickHandler.HandlerFunction = function (e) {

    var sponsors = $("#sponsors-card");

    if (e.Arguments["sponsorType"] == "platinum") {
        $(function () {
            $("#globalLogos").addClass(" hide_logos");
            $("#silverLogos").addClass(" hide_logos");
            $("#platinumLogos").removeClass(" hide_logos");
            $("#platinum_tab").addClass(" header_tab_selected");
            $("#silver_tab").removeClass(" header_tab_selected");
            $("#global_tab").removeClass(" header_tab_selected");
        })

    }
    else if (e.Arguments["sponsorType"] == "silver") {
        $(function () {
            $("#globalLogos").addClass(" hide_logos");
            $("#silverLogos").removeClass(" hide_logos");
            $("#platinumLogos").addClass(" hide_logos");
            $("#silver_tab").addClass(" header_tab_selected");
            $("#global_tab").removeClass(" header_tab_selected");
            $("#platinum_tab").removeClass(" header_tab_selected");
        })
    }
    else {
        $(function () {
            //Global sponsors should show
            $("#globalLogos").removeClass(" hide_logos");
            $("#silverLogos").addClass(" hide_logos");
            $("#platinumLogos").addClass(" hide_logos");
            $("#global_tab").addClass(" header_tab_selected");
            $("#silver_tab").removeClass(" header_tab_selected");
            $("#platinum_tab").removeClass(" header_tab_selected");
        })
    }
}

DEP.AddClickEventHandler(SponsorsCardClickHandler);

//For random generation of 3 sponsor card ads on top.
function rotateImages(numItems, imageArray, urlArray) {
    var nums = new Array();
    var i;
    for (i = 0; i < 3; i++) {
        idx = generateRandom(numItems);
        while (isDup(nums, idx)) {
            idx = generateRandom(numItems);
        }
        nums[i] = idx;
    }
    var sponsorCard = document.getElementById("sponsors-card");
    if (sponsorCard != null) {
        var allImages = sponsorCard.getElementsByTagName("img");
        var allUrls = sponsorCard.getElementsByTagName("a");
        if (allImages != null) {
            var j;
            for (j = 0; j < 3; j++) {
                allImages[j].src = imageArray[nums[j]];
                allUrls[j].href = urlArray[nums[j]];
            }
        }
    }
}

function generateRandom(numItems) {
    var randIndex = Math.floor(Math.random() * numItems);
    if (randIndex == 0) {
        randIndex = 1;
    }
    if (randIndex > numItems) {
        randIndex = numItems;
    }
    return randIndex;
}

function isDup(numArray, index) {
    for (i = 0; i < numArray.length; i++) {
        if (index == numArray[i]) {
            return true;
        }
    }
    return false;
}//For Ego rotator.
var EgoRotatorHandler = new DEPEventHandler("EgoRotator");
EgoRotatorHandler.HandlerFunction = function (e) {
    var divs = $("div.randomize").get().sort(function () {
        return Math.round(Math.random()) - 0.5; //random so we get the right +/- combo
    }).slice(0, 1)
    $(divs).appendTo(divs[0].parentNode).show();
}
DEP.AddEventHandler(EgoRotatorHandler);

//For random item.
var RandomizeHandler = new DEPEventHandler("Randomize");
RandomizeHandler.HandlerFunction = function (e) {
    var divs = $("div.randomizeItem").get().sort(function () {
        return Math.round(Math.random()) - 0.5; //random so we get the right +/- combo
    }).slice(0, 1)
    $(divs).prependTo(divs[0].parentNode).show();
}
DEP.AddEventHandler(RandomizeHandler);
