var isVisible = "";
var thisPage = "";
var t;

var viewportwidth;
var viewportheight;

// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

if (typeof window.innerWidth != 'undefined') {
	viewportwidth = window.innerWidth,
	viewportheight = window.innerHeight
}

// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
	viewportwidth = document.documentElement.clientWidth,
	viewportheight = document.documentElement.clientHeight
}

// older versions of IE

else {
	viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
   	viewportheight = document.getElementsByTagName('body')[0].clientHeight
}
 
function navSelected(page, subpage) {
	thisPage = page;
	
	switch (page) {
		case "aboutus":
			document.getElementById("aboutus").src = "displays/images/nav-aboutus-rz_active.gif";
			document.getElementById("sub-aboutus").style.visibility = "visible";
			break;
		case "thevenue":
			document.getElementById("thevenue").src = "displays/images/nav-thevenue-rz_active.gif";
			break;
		case "thechef":
			document.getElementById("thechef").src = "displays/images/nav-thechefs-rz_active.gif";
			document.getElementById("sub-thechef").style.visibility = "visible";
			break;
		case "ourmenu":
			document.getElementById("ourmenu").src = "displays/images/nav-ourmenu-rz_active.gif";
			document.getElementById("sub-ourmenu").style.visibility = "visible";
			break;
		case "function":
			document.getElementById("function").src = "displays/images/nav-function-rz_active.gif";
			break;
		case "whatson":
			document.getElementById("whatson").src = "displays/images/nav-whatson-rz_active.gif";
			document.getElementById("sub-whatson").style.visibility = "hidden";
			break;
		case "openinghours":
			document.getElementById("openinghours").src = "displays/images/nav-openinghours-rz_active.gif";
			break;
		case "contactus":
			document.getElementById("contactus").src = "displays/images/nav-contactus-rz_active.gif";
			break;
		case "map":
			document.getElementById("map").src = "displays/images/nav-map-rz_active.gif";
			break;
		case "press":
			document.getElementById("press").src = "displays/images/nav-press-rz_active.gif";
			break;
		default:
			break;
	}
	
	switch (subpage) {
		case "sub_kha":
			document.getElementById(subpage).src = "displays/images/subnav-kha.gif";
			break;
		case "sub_epicure":
			document.getElementById(subpage).src = "displays/images/subnav-epicure.gif";
			break;
		case "sub_david":
			document.getElementById(subpage).src = "displays/images/subnav-david.gif";
			break;
		case "sub_kunchit":
			document.getElementById(subpage).src = "displays/images/subnav-kunchit.gif";
			break;
		case "sub_lunch":
			document.getElementById(subpage).src = "displays/images/subnav-lunch.gif";
			break;
		case "sub_dinner":
			document.getElementById(subpage).src = "displays/images/subnav-dinner.gif";
			break;
		case "sub_brunch":
			document.getElementById(subpage).src = "displays/images/subnav-brunch.gif";
			break;
		case "sub_drinks":
			document.getElementById(subpage).src = "displays/images/subnav-drinks.gif";
			break;
		case "sub_promo":
			document.getElementById(subpage).src = "displays/images/subnav-whatson-promo.gif";
			break;
	}
}

function showSub(sub) {
	isVisible = sub;
	
	switch (sub) {
		case "sub-aboutus":
			document.getElementById("sub-aboutus").style.visibility = "visible";
			document.getElementById("sub-thechef").style.visibility = "hidden";
			document.getElementById("sub-ourmenu").style.visibility = "hidden";
			document.getElementById("sub-whatson").style.visibility = "hidden";
			break;
		case "sub-thechef":
			document.getElementById("sub-aboutus").style.visibility = "hidden";
			document.getElementById("sub-thechef").style.visibility = "visible";
			document.getElementById("sub-ourmenu").style.visibility = "hidden";
			document.getElementById("sub-whatson").style.visibility = "hidden";
			break;
		case "sub-ourmenu":
			document.getElementById("sub-aboutus").style.visibility = "hidden";
			document.getElementById("sub-thechef").style.visibility = "hidden";
			document.getElementById("sub-ourmenu").style.visibility = "visible";
			document.getElementById("sub-whatson").style.visibility = "hidden";
			break;
		/*case "sub-whatson":
			document.getElementById("sub-aboutus").style.visibility = "hidden";
			document.getElementById("sub-thechef").style.visibility = "hidden";
			document.getElementById("sub-ourmenu").style.visibility = "hidden";
			document.getElementById("sub-whatson").style.visibility = "visible";
			break;*/
		default:
			document.getElementById("sub-aboutus").style.visibility = "hidden";
			document.getElementById("sub-thechef").style.visibility = "hidden";
			document.getElementById("sub-ourmenu").style.visibility = "hidden";
			document.getElementById("sub-whatson").style.visibility = "hidden";
			break;
	}
}

function restore() {
	switch (thisPage) {
		case "aboutus":
			document.getElementById("sub-aboutus").style.visibility = "visible";
			document.getElementById("sub-thechef").style.visibility = "hidden";
			document.getElementById("sub-ourmenu").style.visibility = "hidden";
			document.getElementById("sub-whatson").style.visibility = "hidden";
			break;
		case "thechef":
			document.getElementById("sub-aboutus").style.visibility = "hidden";
			document.getElementById("sub-thechef").style.visibility = "visible";
			document.getElementById("sub-ourmenu").style.visibility = "hidden";
			document.getElementById("sub-whatson").style.visibility = "hidden";
			break;
		case "ourmenu":
			document.getElementById("sub-aboutus").style.visibility = "hidden";
			document.getElementById("sub-thechef").style.visibility = "hidden";
			document.getElementById("sub-ourmenu").style.visibility = "visible";
			document.getElementById("sub-whatson").style.visibility = "hidden";
			break;
		/*case "whatson":
			document.getElementById("sub-aboutus").style.visibility = "hidden";
			document.getElementById("sub-thechef").style.visibility = "hidden";
			document.getElementById("sub-ourmenu").style.visibility = "hidden";
			document.getElementById("sub-whatson").style.visibility = "visible";
			break;*/
		default:
			document.getElementById("sub-aboutus").style.visibility = "hidden";
			document.getElementById("sub-thechef").style.visibility = "hidden";
			document.getElementById("sub-ourmenu").style.visibility = "hidden";
			document.getElementById("sub-whatson").style.visibility = "hidden";
			break;
	}
}

function setTimer() {
	t = setTimeout("restore()", 600);
}

function clearTimer() {
	clearTimeout(t);
}

function khapop(width, height, src) {
	var w = width; 
	var h = height;
	var page = src;
	var name = "khapop";
	
	var winl = (screen.width / 2) + 40;
	var wint = (screen.height / 2) - 75;
	
	var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes';
	
	var win = window.open(page, name, winprops);
	
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function khapop2(width, height, src) {
	var w = width; 
	var h = height;
	var page = src;
	var name = "khapop2";
	
	var winl = (screen.width / 2) - 200;
	//var wint = (screen.height / 2) - 150;
	var wint = screen.height - viewportheight - 40;
	
	var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes';
	
	var win = window.open(page, name, winprops);
	
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function khapop3(width, height, src) {
	var w = width; 
	var h = height;
	var page = src;
	var name = "khapop3";
	
	var winl = (screen.width / 2) - 200;
	//var wint = (screen.height / 2) - 150;
	var wint = screen.height - viewportheight - 40;
	
	var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes';
	
	var win = window.open(page, name, winprops);
	
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function closewin() {
	self.close();	
}