var currentMain;
var currentSub;
var currentSubSub;
var currentSubSubItem;
var panelTimer;

function show(panelID) {
	hideAll();
	document.getElementById('subMenu[' + panelID + ']').style.display = 'block';
	try { document.getElementById('selcats').style.visibility = 'hidden'; } catch (e) {}
	try { document.getElementById('selRest').style.visibility = 'hidden'; } catch (e) {}
	try { window.frames.check.document.getElementById('selDet').style.visibility = 'hidden'; } catch (e) {}
	//highlightOn(panelID);
}

function hide(timeout) {
	if (timeout == null || isNaN(timeout)) { timeout = 2000; }
	panelTimer = setTimeout('hideAll()', timeout);
}

function showSub(panelID) {
	if (currentSubSub != null) {
		hideSubNow();
	}
	currentSubSub = document.getElementById('subSubMenu[' + panelID + ']')
	currentSubSub.style.display = 'block';
	highlightSubOn(currentSubSub);
}

function hideSub(panelID) {
	highlightSubOff(document.getElementById('subMenuItem[' + panelID + ']'));
	hideSubNow();
}

function hideSubNow() {
	currentSubSub.style.display = 'none';
}

function hideAll() {
	clearTimeout(panelTimer);
	for (i = 0; i <= 100; i++ ) {
		try {
			document.getElementById('subMenu[' + i + ']').style.display = 'none';
		} catch (e) {
		}
	}
	if (currentMain != null) highlightOff();
	//show dropdown-lists
	try { document.getElementById('selcats').style.visibility = 'visible'; } catch (e) {}
	try { document.getElementById('selRest').style.visibility = 'visible'; } catch (e) {}
	try { window.frames.check.document.getElementById('selDet').style.visibility = 'visible'; } catch (e) {}
}

function highlightOn(cellID) {
	currentMain = document.getElementById('menu[' + cellID + ']');
	currentMain.style.backgroundColor = "#888";
	currentMain.style.color = "#000";
}

function highlightOff() {
	currentMain.style.backgroundColor = "";
	currentMain.style.color = "";
}

function highlightSubOn(subID) {
	currentSub = subID;
	currentSub.style.backgroundColor = "#888";
	currentSub.style.color = "#000";
}

function highlightSubOff(subID) {
	currentSub = subID;
	currentSub.style.backgroundColor = "";
	currentSub.style.color = "";
}

function highlightSubSubOn(subID) {
	currentSubSubItem = subID;
	currentSubSubItem.style.backgroundColor = "#888";
	currentSubSubItem.style.color = "#000";
}

function highlightSubSubOff(subID) {
	currentSubSubItem = subID;
	currentSubSubItem.style.backgroundColor = "";
	currentSubSubItem.style.color = "";
}

var amountOfItemsOnCheck = 0
function pickRestaurant(restID) {
	var a = amountOfItemsOnCheck
	if (a > 0) {
		if (confirm('Your shopping cart contains ' + a + ' dish'+(a>1?'es':'')+'. Your current order will be removed. Do you want to continue?')) {
			document.location.href='action.asp?action=checkopen&dlnrID=' + restID;
		} 
	} else {
		document.location.href='action.asp?action=checkopen&dlnrID=' + restID;
	}
}