var menu;
var submenu;
var menu_timer;

function getObj(name) {
	if (document.getElementById) {
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}
	else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
	else if (document.layers) {
		this.obj = document.layers[name];
		this.style = document.layers[name];
	}
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}



function ShowSubmenu(submenu_id, menu_item) {
	
	Hide();
	
	submenu = document.getElementById(submenu_id);
	active = document.getElementById(menu_item);
	active.style.backgroundPosition = "bottom";
	
	pos = (findPos(document.getElementById(menu_item)));
	x = pos[0];
	
	if(submenu == null) return;
	submenu.style.display = "block";
	submenu.style.left = x + "px";
}



function Hide() {
	document.getElementById("lnk_about").style.backgroundPosition = "top";
	document.getElementById("lnk_drinks").style.backgroundPosition = "top";
	document.getElementById("lnk_food").style.backgroundPosition = "top";
	document.getElementById("lnk_actions").style.backgroundPosition = "top";
	document.getElementById("lnk_contact").style.backgroundPosition = "top";
	ResetTimer();
	if(submenu != null) {
		submenu.style.display = "none";
	}
}		

function ResetTimer() {
	if(menu_timer!=null) {
		clearTimeout(menu_timer);
	}
}

function SetTimer() {
	menu_timer=setTimeout('Hide();', 500);
}

function sendGuestbook() {
	document.forms[0].vl.value = 1;
	if (document.forms[0].name.value && document.forms[0].email.value && document.forms[0].comments.value) {
		document.forms[0].submit();
	}
	else {
		alert("Please fill out all required fields!");
	}
}

function sendReservation() {
	document.forms[0].vl.value = 1;
	if (document.forms[0].name.value && document.forms[0].email.value && document.forms[0].phone.value && document.forms[0].date.value) {
		document.forms[0].submit();
	}
	else {
		alert("Please fill out all required fields!");
	}
}


