var mie=(navigator.appName == 'Microsoft Internet Explorer');
var netsc6=((navigator.appName.indexOf('Netscape') != -1)&&(navigator.appVersion.indexOf('5.0') != -1));
var ie45mac=((navigator.appName.indexOf('Microsoft') != -1)&&(navigator.appVersion.indexOf('Mac') != -1)&&(navigator.appVersion.indexOf('4.5') != -1));
var pc=(navigator.appVersion.indexOf('Mac')==-1);
var stockdiv;
var help=0;
var iTimerId = -1;
var iTimerIdStyle = -1;
var strStoredProfielActive = "";
var blnCancelFading = false;

// this method stores the Active Profile when there is one ...
function StoreElementWithCssClass(cssClass) {
	var objs;
	if(mie){
		objs = window.document.all;
		for(i=0;i< objs.length;i++){
			if(	objs[i].tagName=='DIV' && objs[i].className == cssClass)
			{
				strStoredProfielActive = objs[i].id;		
			}
		}
	}
	else if(netsc6){
		objs = document.getElementsByTagName("div");
		for(i=0;i< objs.length;i++){
			if(objs[i].className == cssClass)
			{
				strStoredProfielActive = objs[i].id;
			}	
		}
	}
}

// changes the style of the top navigation so that we know where we actually are
function ChangeCssClassTopMenuItemOnMouseOver(cssClass) {
	if(mie){
		for (var index = 0; index < arrayTopMenuItems.length; index++)
		{
			// set all the active default classes
			document.all[arrayTopMenuItems[index]].className = cssClass;
		}
	}
	else if(netsc6) {
		for (var index = 0; index < arrayTopMenuItems.length; index++)
		{
			document.getElementById(arrayTopMenuItems[index]).className = cssClass;
		}		
	}
}

// changes the style back so that the ProfielActive element is highlighted again
function ChangeStyleBack(defaultCssClass, activeCssClass) {
	var strDefaultCssClass = "'" + defaultCssClass + "'";
	var strActiveCssClass = "'" + activeCssClass + "'";
	iTimerIdStyle = setTimeout('ChangeStyleBackToOriginal(' + strDefaultCssClass + ", " + strActiveCssClass + ')' ,500);
}

// cancels the style change of the top navigation when it needs to be reverted to its old value
function CancelTimeOutOfStyleChange() {
	if(iTimerIdStyle != -1) {
		clearTimeout(iTimerIdStyle);
		iTimerIdStyle = -1;
	}
}

// changes the styles back to their original values
function ChangeStyleBackToOriginal(defaultCssClass, activeCssClass){
	if(mie){
		for (var index = 0; index < arrayTopMenuItems.length; index++)
		{
			if (document.all[arrayTopMenuItems[index]].className == activeCssClass)
			{
				document.all[arrayTopMenuItems[index]].className = defaultCssClass;
			}
			else if (document.all[arrayTopMenuItems[index]].className == defaultCssClass && strStoredProfielActive != "")
			{
				document.all[strStoredProfielActive].className = activeCssClass;
			}
		}
	}
	else if(netsc6){
		for (var index = 0; index < arrayTopMenuItems.length; index++)
		{
			if (document.getElementById(arrayTopMenuItems[index]).className == activeCssClass)
			{
				document.getElementById(arrayTopMenuItems[index]).className = defaultCssClass;
			}
			else if (document.getElementById(arrayTopMenuItems[index]).className == defaultCssClass && strStoredProfielActive != "")
			{
				document.getElementById(strStoredProfielActive).className = activeCssClass;
			}
		}
	}
}

function maskAllAfterTimeOut() {
	iTimerId = setTimeout("maskOthers('')",500);
}

function CancelTimeOut() {
	blnCancelFading = true;
	if(iTimerId != -1) {
		clearTimeout(iTimerId);
		iTimerId = -1;
	}
}

function maskOthers(nameDiv){
	if (iTimerId != -1) { iTimerId = -1; }
	if(mie){
		for (var index = 0; index < arraySubMenuGroups.length; index++)
		{
			if (document.all[arraySubMenuGroups[index]].className == "DropDownBg")
			{
				document.all[arraySubMenuGroups[index]].style.display = 'none';
				document.all[arraySubMenuGroups[index]].filters.alpha.opacity=0;
				stockdiv = null;
			}
			else if (document.all[arraySubMenuGroups[index]].className == "DropDownBgActive")
			{
				if (nameDiv == "")
				{
					document.all[arraySubMenuGroups[index]].style.display='block';
					document.all[arraySubMenuGroups[index]].filters.alpha.opacity=100;
				}
				else {
					document.all[arraySubMenuGroups[index]].style.display='none';	
					document.all[arraySubMenuGroups[index]].filters.alpha.opacity=0;
				}
				stockdiv = null;
			}
		}
	}
	else if(netsc6){
		for (var index = 0; index < arraySubMenuGroups.length; index++)
		{
			if (document.getElementById(arraySubMenuGroups[index]).className == "DropDownBg")
			{
				document.getElementById(arraySubMenuGroups[index]).style.display = "none";
				stockdiv = null;
			}
			// runs after timeout, we need to restore the original menu
			else if (document.getElementById(arraySubMenuGroups[index]).className == "DropDownBgActive")
			{
				if (nameDiv == "") 
				{
					document.getElementById(arraySubMenuGroups[index]).style.display = "block";	
				}
				else
				{
					document.getElementById(arraySubMenuGroups[index]).style.display = "none";
				}
				stockdiv = null;
			}
		}
	}
}

function showCurrent(nameDiv){
	if(mie){
		if(stockdiv!=eval(nameDiv)){
			maskOthers(nameDiv);
			stockdiv=eval(nameDiv);
			help=0;
		}
		if(stockdiv==eval(nameDiv) && nameDiv!=null){
			stockdiv.style.display="block";
			//does the actual fading of the menu
			if(stockdiv.filters.alpha.opacity<100 && help<=100){
				stockdiv.filters.alpha.opacity+=10;
				help+=10;
				if(!ie45mac ){setTimeout("showCurrent(stockdiv)",50);}
			}
		}
	}
	else if(netsc6){
		if(stockdiv!=nameDiv){
			maskOthers(nameDiv);
			stockdiv=nameDiv;			
		}
		if(stockdiv==nameDiv && nameDiv!=null){
			for (var index = 0; index < arraySubMenuGroups.length; index++)
			{
				if (document.getElementById(arraySubMenuGroups[index]).id == nameDiv)
				{
					document.getElementById(arraySubMenuGroups[index]).style.display="block";
				}
			}
		}	
	}
}