// JavaScript Document

var hoverTab = "";
var lastActiveTab = "";
var menuActivationTimer;
var menuDeactivationTimer;
var activeTabOriginalClasses = new Array();                                                                 //embedded scripts in MasterNavigation.xsl populate this array for usage at render time.

function TabOnMouseOver(TabIndex) {
	hoverTab = 'tab' + TabIndex;
	
	if (lastActiveTab == hoverTab) {
		clearTimeout(menuDeactivationTimer);
	}
	menuActivationTimer = setTimeout("ShowTab('" + TabIndex +"')",400);
}

function ShowTab(TabIndex) {
    blurSelects();
    if (hoverTab == 'tab' + TabIndex) {
        lastActiveTab = 'tab' + TabIndex;
        document.getElementById('tab' + TabIndex).className += " ActiveTab";
    }
}

function TabOnMouseOut(TabIndex) {
	hoverTab = "";
	clearTimeout(menuActivationTimer);
	menuDeactivationTimer = setTimeout("HideTab('" + TabIndex +"')",200);
}

function HideTab(TabIndex) {
	if (hoverTab != 'tab' + TabIndex) {
	    document.getElementById('tab' + TabIndex).className = activeTabOriginalClasses[TabIndex - 1];
	}
}

//remove focus from all <select> tags when hovering master nav items
function blurSelects() {

    //FF, IEs & Op
    var selectTag = document.getElementsByTagName('select');
    for (var i = 0; i < selectTag.length; i++) {
        selectTag[i].blur();                                        //chrome does not support blur, therefore chrome fix not implemented.
    }
    return false;

}

