﻿//---[ Advanded Options ]-----
var hideDelay = 500;//delay before subMenus disappear after you take mouse off of them (in milliseconds, 500 == half second)
var minOpacity = 0;
var slideDownSpeed = 40;//<-- bigger number == slower
var slideUpSpeed = 40;
var slideOutSpeed = 60;
var slideInSpeed = 60;
var fadeOutIncrement = 10;
var fadeOutSpeed = 50;
var fadeInIncrement = 10;
var fadeInSpeed =50;
//-----[ No need to edit below this line ]------------------------------------------------------------------------------------------------------------------------

var timeOuts= new Array();
var slideOut_Down_timeOuts = new Array();
var slideIn_slider_timeOuts = new Array();
var slideIn_timeOuts = new Array();
var slideOut_slider_timeOuts = new Array();
var slideDown_slider_timeOuts = new Array();
var slideUp_slider_timeOuts = new Array();
var slideUp_timeOuts = new Array();
var opacityTimeOuts = new Array();
var fadeOutTimeOuts = new Array();
var currentSubMenu = "";
var currentButton = "";
var tempId = "";
var familyTree = new Array();
var increment = 20;//helps determine speed of slide transitions. A smaller number will look choppier in ie and slower computers but smoother on faster computers and in browsers that process it better like firefox and opera.
var originalHeights = new Array();
var originalWidths = new Array();
var subMenuOptions = new Array();
var minHeight = 1;
var minWidth = 1;
var smType = new Array();
/*
 _________________________________
|   subMenuOptions Array Legend   |
|=================================|
|   [0] =>[ maxOpacity ]		  |
|   [1] =>[ orientation ]		  |
|   [2] =>[ drop direction ]	  |
|   [3] =>[ v offset ]			  |
|   [4] =>[ h offset ]			  |
|   [5] =>[ drops shadows ]		  |
|   [6] =>[ corners ]			  |
|   [7] =>[ fade transition ]	  |
|   [8] =>[ slide transition ]	  |
|   [9] =>[ corner height ]		  |
|   [10] =>[ shadow style ]		  |
|_________________________________|
*/

function mainMenuBtn_OnMouseOut(subMenuId, aNumber){//#####################################################################
	call_hideAllSubMenus();
	if(subMenuOptions[8] == '1'){ call_slideUp(subMenuId, aNumber); }//end if
}//end function

function mainMenuBtn_OnMouseOver(compiledOptions, subMenuId, aNumber, thisBtnId, thisObj, startOpac, endOpac){//######################################
	if(subMenuOptions.length < 1){subMenuOptions = compiledOptions.split("-"); }//end if
	
	showInitialSubMenu(subMenuId,thisBtnId);

	fixForIE(subMenuId);
	hideAllSubMenusButThis(subMenuId,thisObj);
	if(subMenuOptions[8] == '1'){ cancell_slideUp(subMenuId); }//end if
	if(subMenuOptions[8] == '1'){ slideDown(subMenuId, aNumber); }//end if
	fadeIn(subMenuId, startOpac, endOpac);
	//if(subMenuOptions[7] != '1'){showMe(subMenuId)}//end if
	
	
}//end function

function subMenu_OnMouseOut(thisSubMenuId){//#####################################################################
	
	call_hideAllSubMenus(); 
	call_hideMe(thisSubMenuId);
}//end function

function subMenu_OnMouseOver(thisSubMenuId){//#####################################################################
	//highlightParentButton(thisSubMenuId);
	
	cancell_hideParent(thisSubMenuId);
	cancell_hideMe(thisSubMenuId);
	cancell_hideAllSubMenus();

	whoIsYourDaddy(thisSubMenuId);
	cancell_fadeOut(thisSubMenuId); 
	if(subMenuOptions[8] == '1'){ cancell_slideIn(thisSubMenuId); }//end if
	if(subMenuOptions[8] == '1'){ cancell_slideUp(thisSubMenuId); }//end if
}//end function

function subMenuBtnA_OnMouseOut(subMenuId, aNumber, thisObj, newClassName){//#####################################################################
	setClass(thisObj, newClassName);//subMenuBtn
	call_hideAllSubMenus();
	if(subMenuOptions[8] == '1'){ call_slideIn(subMenuId,aNumber) }//end if
	call_fadeOut(subMenuId);
	
}//end function

function subMenuBtnA_OnMouseOver(subMenuId, aNumber, thisObj, newClassName,  startOpac, endOpac, thisSubMenuId){//##############################################
	
	highlightParentButton(thisSubMenuId);
	notOver(subMenuId);
	
	cancell_hideMe(thisSubMenuId);																   
	notOver(thisSubMenuId);
	setClass(thisObj, newClassName);
	positionSubSubMenu(thisSubMenuId, thisObj, subMenuId);
	setCurrentSubMenu(thisSubMenuId);
	setCurrentButton(thisObj);													
	findAndHideAllChildrenExceptMine(thisSubMenuId, subMenuId+'_button');
	cancell_fadeOut(subMenuId);
	fadeIn(subMenuId, startOpac, endOpac);
	
	if(subMenuOptions[8] == '1'){ slideOut(subMenuId, aNumber); }//end if
	
	
	
}//end function

function subMenuBtnB_OnMouseOut(thisObj, newClassName){//#####################################################################
	setClass(thisObj, newClassName);
}//end function

function subMenuBtnB_OnMouseOver(thisObj, newClassName, thisSubMenuId){//##############################################
	
	highlightParentButton(thisSubMenuId);
	notOver(thisSubMenuId);
	
	cancell_hideMe(thisSubMenuId);
	cancell_hideAllSubMenus();
	findAndHideAllChildren(thisSubMenuId);
	findAndHideAllChildrenExceptMine(thisSubMenuId,'');
	setClass(thisObj, newClassName);//subMenuBtnOver
	
}//end function

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------

function showShadow(subMenuId){//#######################################################################################
	if(subMenuOptions[5] == '1'){
		var shadowId = subMenuId+"_shadow";
		if(getObject(shadowId,'silent') && getObject(shadowId).className=='shadow'){
			var shadowObj = getThingObj(shadowId);
			var subMenuObj = getThingObj(subMenuId);
			var subMenuX = findPosX(subMenuObj);
			var subMenuY = findPosY(subMenuObj);
			var subMenuWidth = findObjWidth(subMenuObj);
			var subMenuHeight = findObjHeight(subMenuObj);
			//if(subMenuOptions[7] != '1'){changeOpac(subMenuOptions[0], shadowId); }//end if
			//if(subMenuOptions[7] == '1'){changeOpac(minOpacity, shadowId); }//end if
			
			
			//----------------------------------
			if(subMenuOptions[10] == '2'){//<--more realistic shadows is turned on
				var shadowSizers = getElementsByClassName(shadowObj, "img", "shadowSizer");
				shadowSizers[0].style.height = subMenuHeight-25+'px';
				shadowSizers[0].style.width = subMenuWidth-20+'px';
			} else if (subMenuOptions[10] == '1'){//<--faster shadows is turned on
				shadowObj.style.height = subMenuHeight+10+'px';
				shadowObj.style.width = subMenuWidth+10+'px';
			}//end if else if
			//----------------------------------
			
			shadowObj.style.visibility = 'visible';
			shadowObj.style.top = subMenuY+'px';
			shadowObj.style.left = subMenuX+5+'px';
			
		}//end if
	}//end if
}//end function

function hideShadow(subMenuId){//#######################################################################################
	if(subMenuOptions[5] == '1'){
		var shadowId = subMenuId+"_shadow";
		if(getThingObj(shadowId)){
			var shadowObj = getThingObj(shadowId);
			shadowObj.style.visibility = 'hidden';
		}//end if
	}//end if
}//end function

function showMe(thing) {//#####################################################################
	var obj = getThingObj(thing);
	var id = getThingId(thing);
	showShadow(id);
	
	if(subMenuOptions[7] == '1'){
		changeOpac(minOpacity, id);
		fadeIn(id, minOpacity, subMenuOptions[0], fadeInSpeed);
	}else{
		obj.style.visibility = 'visible';
		changeOpac(subMenuOptions[0], id);
		
	}//end if else 
}//function

function hideMe(thing){//#############################################################################
	var id = getThingId(thing)
	var obj = getThingObj(thing);
	notOver(id);
	hideShadow(id);
	
	if(subMenuOptions[7] == '1'){
		
		fadeOut(id, minOpacity, fadeOutSpeed);
	}else if(subMenuOptions[8] == '1') {	
		
	}else{
		changeOpac(minOpacity, id);
		obj.style.visibility = 'hidden';
	}//end if else if else

}//end hideMe function

var fixedForIE = 'false';
function fixForIE(thing){//############################################################################
	// for some reason when the position is not "static" the subLink spans dissappear at unappropiate times in ie
	if(fixedForIE == 'false'){
		if(is_ie){
			var subMenuObj = getThingObj(thing);
			var subLinksInThisMenu = getElementsByClassName(subMenuObj, '*', "subLink");
			for(var i=0; i<subLinksInThisMenu.length; i++){
				subLinksInThisMenu[i].style.position = 'static';
			}//end for
			fixedForIE = 'true';
		}//end if
	}//end if
}//end function

//------[ transition functions  ]-----------------------------------------------------------------------------------

function call_fadeOut(id){//##################################################################
	if(subMenuOptions[7] == '1'){
		if(fadeOutTimeOuts[id]){clearTimeout(fadeOutTimeOuts[id]);}//end if
		fadeOutTimeOuts[id] = setTimeout('fadeOut("'+id+'","'+minOpacity+'","'+fadeOutSpeed+'")', hideDelay);
	}//end if
}//function

function cancell_fadeOut(id){//##################################################################
	if(fadeOutTimeOuts[id]){clearTimeout(fadeOutTimeOuts[id]);}//end if
}//end function

function call_slideIn(thing, millisec){//#############################################################################
	if(subMenuOptions[8] == '1'){
		var id = getThingId(thing);
		if(slideIn_timeOuts[id]){clearTimeout(slideIn_timeOuts[id]);}//end if
		slideIn_timeOuts[id] = setTimeout('slideIn("'+id+'","'+millisec+'")',hideDelay);
	}//end if
}//function

function cancell_slideIn(thing){//#############################################################################
	var id = getThingId(thing);
	if(slideIn_timeOuts[id]){clearTimeout(slideIn_timeOuts[id]);}//end if
	if(slideIn_slider_timeOuts[id]){clearTimeout(slideIn_slider_timeOuts[id]);}//end if
}//end function

function slideIn(thing, millisec) {//#############################################################################
	if(subMenuOptions[8] == '1'){
		var speed = Math.round(millisec / 100);
		var timer = 0;
		var obj = getThingObj(thing);
		var id = getThingId(thing);
		
		if(slideIn_slider_timeOuts[id]){ clearTimeout(slideIn_slider_timeOuts[id])	}//end if
		
			if(obj.style.visibility == 'visible' ){
				clearTimeout(slideIn_slider_timeOuts[id]);
				//-------------------------------------------
				var currentWidth = findObjWidth(obj);
				var BRW = getBRW(obj);
				var BLW = getBLW(obj);
				var startWidth = currentWidth - BRW - BLW;
				var endWidth = 0;
				//opacStart = obj.style.opacity*100;//<---removes fadeOut flicker
				//-------------------------------------------
				//alert(id);
				for(i = startWidth; i >= (endWidth-increment); i=i-increment) {
					//alert(findObjWidth(obj));
					slideIn_slider_timeOuts[id] = setTimeout("slideIn_slider(" + i + ",'" + id + "','" + endWidth + "')",(timer * slideInSpeed));
					timer++;
					
				}//end for
		}//end if 
	}//end if
}//end function

function slideIn_slider(width, id, endWidth) {//#############################################################################
	
	var obj = getThingObj(id);
	obj.style.width = width+'px';
	obj.style.visibility = 'visible';
	showShadow(id);
	
	if(width <= (endWidth+increment)){
		obj.style.visibility = 'hidden';
		obj.style.width = minWidth+'px';
		hideShadow(id);
	
	}//end if
}//end function

function slideOut(thing, millisec) {//#############################################################################
    if(subMenuOptions[8] == '1'){
		var speed = Math.round(millisec / 100);
		var timer = 0;
		var obj = getThingObj(thing);
		var id = getThingId(thing);
		
		var BRW = getBRW(obj);
		var BLW = getBLW(obj);
		
		
		
		cancell_slideIn(thing);
		if (!originalWidths[id]){ 	
			originalWidths[id] = findObjWidth(obj)-BLW-BRW;	
			obj.style.width = minWidth+'px';
		}//end if
		//-------------------------------------------
		var startWidth = findObjWidth(obj) - BRW - BLW;
		var endWidth = originalWidths[id];
		//-------------------------------------------
		
		if(startWidth < endWidth ){
			//alert(id+'is '+startWidth+' px wide and the original width is '+endWidth);
			clearTimeout(slideOut_slider_timeOuts[id]);
	
			for(i = startWidth; i <= endWidth; i = i+increment) {
				slideOut_slider_timeOuts[id] = setTimeout("slideOut_slider(" + i + ",'" + id + "','" + endWidth + "')",(timer * slideOutSpeed));
				timer++;
			}//end for
		}//end if 
	}//end if
}//end function

function slideOut_slider(width, id, endWidth) {
	var obj = getThingObj(id);
	obj.style.width = width+'px';
	//obj.style.visibility = 'visible';
	
	
	showShadow(id);
	

	
	if(width >= (endWidth-increment)){
		//obj.style.visibility = 'hidden';
		obj.style.width = endWidth+'px';
		showShadow(id);
	
		
	}//end if
}//end function

function slideDown(thing, millisec) {
    if(subMenuOptions[8] == '1'){
		if(slideDown_slider_timeOuts[id]){clearTimeout(slideDown_slider_timeOuts[id]);}//end if
		var timer = 0;
		var obj = getThingObj(thing);
		var id = getThingId(thing);
		var BBW = getBBW(obj);//<-- BBW = Border Bottom Width || BTW = Border Top Width
		
		//alert(BBW);
		
		var BTW = getBTW(obj);
		cancell_slideUp(thing);
		if (!originalHeights[id]){ 	
			originalHeights[id] = findObjHeight(obj)-BBW-BTW;	
			obj.style.height = minHeight+'px';
			//alert(findObjHeight(obj));
		}//end if
		//-------------------------------------------
		var startHeight = findObjHeight(obj)- BBW - BTW;
		var endHeight = originalHeights[id];
		//-------------------------------------------
		//alert('startHeight = '+startHeight+' || endHeight = '+endHeight);
		if(startHeight < endHeight ){
			
			for(i = startHeight; i <= endHeight; i=i+increment) {
				slideDown_slider_timeOuts[id] = setTimeout("slideDown_slider(" + i + ",'" + id + "','" + endHeight + "')",(timer * slideDownSpeed));
				timer++;
			}//end for
		}//end if 
	}//end if
}//end function

function slideDown_slider(height, id, endHeight) {//#############################################################################
	var obj = getThingObj(id);
	obj.style.height = height+'px';
	showShadow(id);

	if(height >= (endHeight-increment)){
		obj.style.height = endHeight+'px';
		showShadow(id);
	
	}//end if
}//end function

function call_slideUp(thing, millisec){//#############################################################################
	
	if(subMenuOptions[8] == '1'){
		var id = getThingId(thing);
		if(slideUp_timeOuts[id]){clearTimeout(slideUp_timeOuts[id]);}//end if
		slideUp_timeOuts[id] = setTimeout('slideUp("'+id+'","'+millisec+'")',hideDelay);
	}//end if
}//function

function cancell_slideUp(thing){//#############################################################################
	var id = getThingId(thing);
	if(slideUp_timeOuts[id]){clearTimeout(slideUp_timeOuts[id]);}//end if
	if(slideUp_slider_timeOuts[id]){clearTimeout(slideUp_slider_timeOuts[id]);}//end if
}//end function

function slideUp(thing, millisec) {//#############################################################################
	if(subMenuOptions[8] == '1'){
		
		
		
		//var speed = Math.round(millisec / 100);
		var timer = 0;
		var obj = getThingObj(thing);
		var id = getThingId(thing);
		
		if(slideUp_slider_timeOuts[id]){ clearTimeout(slideUp_slider_timeOuts[id])	}//end if
		
		var currentHeight = findObjHeight(obj);
		
		//if(currentHeight >= (originalHeights[id]-increment) ){ alert('hmmm');}//end if
		
		cancell_hideMe(id);
			
			//if(obj.style.visibility == 'visible' ){
			if(currentHeight >= (originalHeights[id]-increment) ){	
				//alert(thing);
				
				clearTimeout(slideUp_slider_timeOuts[id]);
				//-------------------------------------------
				
				var BBW = getBBW(obj);
				var BTW = getBTW(obj);
				var startHeight = currentHeight - BBW - BTW;
				var endHeight = 0;
				//opacStart = obj.style.opacity*100;//<---removes fadeOut flicker
				//-------------------------------------------
				for(i = startHeight; i >= (endHeight-increment); i=i-increment) {
					//alert(findObjWidth(obj));
					slideUp_slider_timeOuts[id] = setTimeout("slideUp_slider(" + i + ",'" + id + "','" + endHeight + "')",(timer * slideUpSpeed));
					timer++;
				}//end for
		}//end if 
	}//end if
}//end function

function slideUp_slider(height, id, endHeight) {//#############################################################################
	//alert(id+'is being slid up');
	var obj = getThingObj(id);
	obj.style.height = height+'px';
	obj.style.visibility = 'visible';
	showShadow(id);
	

	
	if(height <= (endHeight+increment)){
		//alert('all slid up');
		obj.style.visibility = 'hidden';
		obj.style.height = minHeight+'px';
		hideShadow(id);
		
	
	
	}//end if
}//end function

//------[ menu logic functions  ]-----------------------------------------------------------------------------------

function whoIsYourDaddy(id){//#############################################################################
	
	
	
	
	var length = 0;
	for (i in familyTree) {
		length++;
	}//end for
	
	
	if (length <= 0 ){
	
		familyTree[id] = 'none';
		
		//alert(id);
		
	}else if (id && !familyTree[id] && currentSubMenu){
		//alert(id);
		familyTree[id] = currentSubMenu;
	}else{
		
		//alert('odd');
	}//end if
}//function

function findAndHideAllChildren(thisMenuId){//#############################################################################
	//alert(thisMenuId);
	var thisMenuObj = getObject(thisMenuId);
	var subLinksInThisMenu = getElementsByClassName(thisMenuObj, "span", "subLink");
	if (subLinksInThisMenu.length > 0){
		//alert(subLinksInThisMenu.length);
		for(var i=0; i<subLinksInThisMenu.length; i++){
			//alert(subLinksInThisMenu[i].id);
			var subLinkId = subLinksInThisMenu[i].id;
			var subMenuIdArray = subLinkId.split("_");
			var subMenuId = subMenuIdArray[0];
			//clearTimeout(findAndHideAllChildrenTimeout);
			//findAndHideAllChildrenTimeout = setTimeout('findAndHideAllChildren('+subMenuId+')',hideDelay);
			findAndHideAllChildren(subMenuId);
			//call_hideSubSubMenu(subMenuId);
			//---------------------------------------
			var obj = getThingObj(subMenuId);
			//alert(obj);
			if(obj.style.opacity >0){fadeOut(subMenuId, minOpacity, fadeOutSpeed);}//end if
			//---------------------------------------
			var BRW = getBRW(obj);
			var BLW = getBLW(obj);
			var currentWidth = findObjWidth(obj)-BLW-BRW;
			if(currentWidth>0){ slideIn(subMenuId,500); }//end if
			//---------------------------------------

			notOver(subMenuId);
			//alert(subMenuId);
		}//end for
	}//end if
}//function

function findAndHideAllChildrenExceptMine(thisMenuId, thisSubLinkId){//#############################################################################
	var thisMenuObj = getObject(thisMenuId);
	var subLinksInThisMenu = getElementsByClassName(thisMenuObj, "span", "subLink");
	if (subLinksInThisMenu.length > 0){
		//alert(subLinksInThisMenu.length);
		for(var i=0; i<subLinksInThisMenu.length; i++){
			//alert(subLinksInThisMenu[i].id);
			var subLinkId = subLinksInThisMenu[i].id;
			if(subLinkId != thisSubLinkId){
				var subMenuIdArray = subLinkId.split("_");
				var subMenuId = subMenuIdArray[0];
				findAndHideAllChildren(subMenuId);
				//---------------------------------------
				var obj = getThingObj(subMenuId);
				//alert(obj);
				if(obj.style.opacity >0){fadeOut(subMenuId, minOpacity, fadeOutSpeed);}//end if
				//---------------------------------------
				var BRW = getBRW(obj);
				var BLW = getBLW(obj);
				var currentWidth = findObjWidth(obj)-BLW-BRW;
				if(currentWidth>0){ slideIn(subMenuId,500); }//end if
				//---------------------------------------
				notOver(subMenuId);
			}//end if
		}//end for
	}//end if
}//function

function hideOtherMainMenuSubs(){//#############################################################################
	var obj = getObject('mainMenu');
}//end function

function call_hideParent(childId){//#############################################################################
	if (childId && familyTree[childId]){
		if(timeOuts[childId]){clearTimeout(timeOuts[childId]);}//end if
		timeOuts[childId] = setTimeout('hideParent("'+childId+'")',1000);
	}//end if
}//function

function hideParent(childId){//#############################################################################
	if (childId && familyTree[childId]){
		var parentObj = getObject(familyTree[childId]);
		
		notOver(familyTree[childId]);
		var childObj = getObject(childId);
		
		notOver(childId);
		clearTimeout(timeOuts[childId]);
		//---------------------------------------
		//childObj.style.visibility = 'hidden';
		//parentObj.style.visibility = 'hidden';
		//hideShadow(childId);
		//---------------------------------------
	}//end if
}//function

function cancell_hideParent(childId){//#############################################################################
	if (timeOuts[childId]){
		clearTimeout(timeOuts[childId]);
		}//end if
	if (timeOuts[currentSubMenu]){
		clearTimeout(timeOuts[currentSubMenu]);}//end if
}//end function

function clearAllTimeouts(){//#############################################################################
	for(key in timeOuts	){
		clearTimeout(timeOuts[key]);
	}//end for
}//function

function showInitialSubMenu(subMenuId, parentBtnId){//#############################################################################
	if(!smType[subMenuId]){smType[subMenuId] = 'initSub';}//end if
	if (timeOuts[subMenuId]){clearTimeout(timeOuts[subMenuId]);}//end if
	if (timeOuts['hideAllSubMenus']){clearTimeout(timeOuts['hideAllSubMenus']);}//end if
	var parentBtnObj = getObject(parentBtnId);
	var parentBtnX = findPosX(parentBtnObj);
	var parentBtnY = findPosX(parentBtnObj);
	var parentBtnHeight = findObjHeight(parentBtnObj);
	var subMenuObj = getObject(subMenuId);
	var megaMenuObj = getObject('megamenu');
	var megaMenuY = findPosY(megaMenuObj);
	if(subMenuOptions[7] == '1'){changeOpac(minOpacity, subMenuId); }//end if <--only use this if using the fade in transition
	//if(subMenuOptions[7] == '1'){changeOpac(minOpacity, subMenuId+"_shadow"); }//end if <--only use this if using the fade in transition
	subMenuObj.style.left = parentBtnX+'px';
	var vOffset = subMenuOptions[3];
	subMenuObj.style.top = megaMenuY+parentBtnHeight-vOffset+'px';
	subMenuObj.style.visibility = 'hidden';//so that the opacity function knows to make it visible
	setClass(parentBtnObj, "btnOver");
	
	//---------------------------------
	
	//---------------------------------
	
}//end function

function positionSubSubMenu( parentMenuId, parentBtnObj, subMenuId){//#############################################################################
	if (timeOuts[subMenuId]){clearTimeout(timeOuts[subMenuId]);}//end if
	var parentMenuObj = getObject(parentMenuId);
	var parentMenuX = findPosX(parentMenuObj);
	var parentMenuWidth = findObjWidth(parentMenuObj);
	var parentBtnY = findPosY(parentBtnObj);
	var subMenuObj = getObject(subMenuId);
	if(subMenuOptions[6] == '1'){ vOffset = subMenuOptions[9]; }else{ vOffset = '0';}//end if else
	subMenuObj.style.top = parentBtnY-vOffset+'px';
	subMenuObj.style.left = parentMenuX+parentMenuWidth+'px';
}//end function

function call_hideSubSubMenu( subMenuId){//#############################################################################
	timeOuts[subMenuId] = setTimeout('hideSubSubMenu(\''+subMenuId+'\')',hideDelay);
}//end function

function hideSubSubMenu(subMenuId){//#############################################################################
	var subMenuObj = getObject(subMenuId);
	notOver(subMenuId);
	//---------------------------------------
	hideShadow(subMenuId);
	//---------------------------------------
}//end function

function call_hideAllSubMenus(){//#############################################################################
	clearTimeout(timeOuts['hideAllSubMenus']);
	timeOuts['hideAllSubMenus'] = setTimeout('hideAllSubMenus()',hideDelay);
}//end function

function cancell_hideAllSubMenus(){//#############################################################################
	clearTimeout(timeOuts['hideAllSubMenus']);
}//end function

function hideAllSubMenusButThis(keeper, meObj){//#############################################################################
	var subMenusArray = getElementsByClassName(document, "div", "subMenu");
	for(var i=0; i<subMenusArray.length; i++){
		var id = getThingId(subMenusArray[i]);
		if(id != keeper){
			//---------------------------------------
			hideShadow(id);
			//---------------------------------------
			if(subMenusArray[i]){notOverByObj(subMenusArray[i]);}//end if
			if(subMenusArray[i].style.opacity >0){fadeOut(id, minOpacity, fadeOutSpeed);}//end if
			notOverByObj(subMenusArray[i]);      
			notOverMainMenuButMe(meObj);
			//---------------------------------------
			var obj = subMenusArray[i];
			if(obj.style.width){//<---if it is not supposed to be scaled horizontally the width will not be set
				var BRW = getBRW(obj);
				var BLW = getBLW(obj);
				var currentWidth = findObjWidth(obj)-BLW-BRW;
				if(currentWidth>0){ slideIn(id,500); }//end if
			}else{
				var BBW = getBBW(obj);
				var BTW = getBTW(obj);
				var currentHeight = findObjHeight(obj)-BBW-BTW;
				if(currentHeight>0){slideUp(id,500); }//end if
			}//end if else
			//---------------------------------------
		}//end if
	}//end for
}//end function

function hideAllSubMenus(){//#############################################################################
	var subMenusArray = getElementsByClassName(document, "div", "subMenu");
	for(var i=0; i<subMenusArray.length; i++){
		if(subMenusArray[i]){notOverByObj(subMenusArray[i]);}//end if
		var id = getThingId(subMenusArray[i]);
		if(subMenusArray[i].style.opacity >0){fadeOut(id, minOpacity, fadeOutSpeed);}//end if
		notOverByObj(subMenusArray[i]);
		notOverMainMenu();
		
		//---------------------------------------
		var obj = subMenusArray[i];
		if(obj.style.width){//<---if it is not supposed to be scaled horizontally the width will not be set
			var BRW = getBRW(obj);
			var BLW = getBLW(obj);
			var currentWidth = findObjWidth(obj)-BLW-BRW;
			if(currentWidth>0){ slideIn(id,500); }//end if
		}else{
			var BBW = getBBW(obj);
			var BTW = getBTW(obj);
			var currentHeight = findObjHeight(obj)-BBW-BTW;
			if(currentHeight>0){slideUp(id,500); }//end if
		}//end if else
		//---------------------------------------
		
		//---------------------------------------
		hideShadow(id);
		//---------------------------------------
		
	}//end for
	clearTimeout(timeOuts['hideAllSubMenus']);
}//end exnayAllSubMenus function

function call_hideMe(id){//#############################################################################
	//alert('the hideMe function has been called by '+id);
	if(!timeOuts[id]){
	timeOuts[id] = setTimeout('hideMe("'+id+'")',hideDelay);
	}//end if
}//end call_hideMe function

function cancell_hideMe(id){//#############################################################################
	clearTimeout(timeOuts[id]);
}//end cancell_hideMe function

function setCurrentSubMenu(id){//#############################################################################
	if(id && currentSubMenu != id){
		currentSubMenu = id;
	}//end if
}//end hideMe function

function setCurrentButton(obj){//#############################################################################
	if(obj && currentButton != obj){
		currentButton = obj;
	}//end if
}//end hideMe function

function highlightParentButton(id){//#############################################################################
		
		if(currentButton && smType[id] != 'initSub'){
			tempId = id;
			//alert(id.className);
			setClass(currentButton, "subMenuBtnOver");
		}//end if
		
	
}//end function

function notOver(thisMenuId){//#############################################################################
	if (thisMenuId){var thisMenuObj = getObject(thisMenuId);}//end if
	var buttonsInThisMenu = getElementsByClassName(thisMenuObj, 'div', "subMenuBtnOver");
	for(var i=0; i<buttonsInThisMenu.length; i++){
		var obj =buttonsInThisMenu[i];
		if(obj){ setClass(obj, "subMenuBtn");}//end if
	}//end for
}//end hideMe function

function notOverByObj(thisMenuObj){//#############################################################################
	if(thisMenuObj){
		var buttonsInThisMenu = getElementsByClassName(thisMenuObj, 'div', "subMenuBtnOver");
		for(var i=0; i<buttonsInThisMenu.length; i++){
			var obj =buttonsInThisMenu[i];
			if(obj){ setClass(obj, "subMenuBtn");}//end if
		}//end for
	}//end if
}//end function

function notOverMainMenu(){//#############################################################################
	var thisMenuObj = getObject('megamenu');
	var buttonsInThisMenu = getElementsByClassName(thisMenuObj, 'div', "btnOver");
	for(var i=0; i<buttonsInThisMenu.length; i++){
		var obj =buttonsInThisMenu[i];
		if(obj){ setClass(obj, "button");}//end if
	}//end for
}//end function

function notOverMainMenuButMe(meObj){//#############################################################################
	var thisMenuObj = getObject('megamenu');
	var buttonsInThisMenu = getElementsByClassName(thisMenuObj, 'div', "btnOver");
	for(var i=0; i<buttonsInThisMenu.length; i++){
		if(buttonsInThisMenu[i] != meObj){
			var obj =buttonsInThisMenu[i];
			if(obj){ setClass(obj, "button");}//end if
		}//end if
	}//end for
}//end function