var interval;

var showHideSpeed = 500;
var working = false;
var mouseOn = false;
var currentActive;

function activateMenuHolder(menuHolderID,show)
{
	var id = '#' + menuHolderID;
	if (show) {
		$(id).show(showHideSpeed);
		mouseOn = true;
	}
	else {
		mouseOn = false;
	}
	
}

var submenus = new Array();

/*submenus.push("menuHolder_2");
submenus.push("menuHolder_3");
submenus.push("menuHolder_4");
submenus.push("menuHolder_5");
submenus.push("menuHolder_6");
submenus.push("menuHolder_7");
submenus.push("menuHolder_8");
submenus.push("menuHolder_9");
submenus.push("menuHolder_10");
submenus.push("menuHolder_11");
submenus.push("menuHolder_12");
submenus.push("menuHolder_13");
submenus.push("menuHolder_14");
submenus.push("menuHolder_15");*/
submenus.push("menuHolder_30");

setInterval(hideAll,500);

function hideAll()
{
	if(!mouseOn)
	{
		for(var i=0;i<submenus.length;i++)
		{
			var id = submenus[i];
			var e = document.getElementById(id);
			
			if(e != "undefined" && e != null) $(e).hide(showHideSpeed);
		}
		
		working = false;
	}
}

var bubblingEnabled = false;
var cancelLocation = false;
function windowLocation(location,caller_a)
{
	if(cancelLocation) return;
	
	//We had bubbling and this is the end of it.
	//Reset.
	if(caller_a == null && bubblingEnabled)
	{
		cancelLocation = false;
		bubblingEnabled = false;
		return;
	}
	//This is the main item, no bubbling, just go to location.
	else if(caller_a == null)
	{
		window.location = location;
	}
	//This is a sub-page, we have bubbling
	//enable it and allow only this caller to go to location.
	//Since cancelLocation will be set to true here, no other
	//caller, who is not the main section will go beyond the first
	//if statement of this function.
	else if (caller_a != null)
	{
		bubblingEnabled = true;
		cancelLocation = true;
	}
	
	window.location = location;
}
