var menuEntry = new Array("menu_home","menu_mercato","menu_eventi","menu_promozioni","menu_spesa","menu_attivita","menu_storia","menu_contatti");


function menuPageScroll() {

try {
	var y = window.pageYOffset;
	var menu = document.getElementById("page_menu");
	menu.style.top = y; 

} catch(error) {
	if(debugMode == 1) {
		alert("menuPageScroll() :: " + error);
	}
}

}


function menuEntryPosition(entryid) {

var i = 0;
while((i < menuEntry.length) && (menuEntry[i] != entryid))
	i++;

if(i == menuEntry.length) {
	return -1;
}

return i;

}


function menuMouseOver(entryid) {

try {
	var position = menuEntryPosition(entryid);
	if(position == -1)
		return;

	var div = document.getElementById(entryid);
	div.style.backgroundColor = menuOverColor;
	
	if(position == 0) {
		div.style.borderBottomColor = menuOverBorderColor;
		div = document.getElementById('menu_head');
		div.style.backgroundImage = "url('images/menuCentrale-alto_over.png')";
	
	} else if(position == (menuEntry.length - 1)) {
		div.style.borderBottomColor = "#ff9966";
		div = document.getElementById(menuEntry[position - 1]);
		div.style.borderBottomColor = menuOverBorderColor;
		div = document.getElementById('menu_foot');
		div.style.backgroundImage = "url('images/menuCentrale-basso_over.png')";
		
	} else {	
		div.style.borderBottomColor = menuOverBorderColor;
		div = document.getElementById(menuEntry[position - 1]);
		div.style.borderBottomColor = menuOverBorderColor;
	}

} catch(error) {
	if(debugMode == 1) {
		alert("menuMouseOver(" + entryid + ") :: " + error);
	}
}

}


function menuMouseOut(entryid) {

try {
	var position = menuEntryPosition(entryid);
	if(position == -1)
		return;

	var div = document.getElementById(entryid);
	div.style.backgroundColor = "transparent";
	
	if(position == 0) {
		div.style.borderBottomColor = "";
		div = document.getElementById('menu_head');
		div.style.backgroundImage = "url('images/menuCentrale-alto.png')";
	
	} else if(position == (menuEntry.length - 1)) {
		div.style.borderBottomColor = "#ffa95f";
		div = document.getElementById(menuEntry[position - 1]);
		div.style.borderBottomColor = "";
		div = document.getElementById('menu_foot');
		div.style.backgroundImage = "url('images/menuCentrale-basso.png')";
	
	} else {	
		div.style.borderBottomColor = "";
		div = document.getElementById(menuEntry[position - 1]);
		div.style.borderBottomColor = "";
	}

} catch(error) {
	if(debugMode == 1) {
		alert("menuMouseOut(" + entryid + ") :: " + error);
	}
}

}


function loadPage(pageid) {

location.href = "index.php?page=" + pageid;

}

