/*
Text and Links for for menu
*/

var menu = "";

menu += '<div class="menutitle" onclick="Go(\'/\');setSelected(\'welcome\',\'\')" id="welcome">Welcome</div>';
menu += '<div class="menutitle" onclick="Go(\'/menu\');setSelected(\'menu\',\'\')" id="menu">Menu</div>';

menu += '<div class="menutitle" onclick="Go(\'/club\');setSelected(\'club\',\'\')" id="club">Birthday Club</div>';

menu += '<div class="menutitle" onclick="Go(\'/tickets\');setSelected(\'tickets\',\'\')" id="tickets">Win Tickets</div>';

menu += '<div class="menutitle" onclick="Go(\'/functions\');setSelected(\'functions\',\'\')" id="functions">Party Functions</div>';

menu += '<div class="menutitle" onclick="SwitchMenu(\'sub4\');setSelected(\'company\',\'sub4\')" id="company">Company</div>';
menu += '<span class="submenu" id="sub4">';
menu += '&raquo; <a href="/story">Our Story</a> <br/>';
menu += '&raquo; <a href="/partners">Community Partners</a> <br/>';
menu += '&raquo; <a href="/feedback">Feedback</a> <br/>';
menu += '</span>';

//write it out
document.write ('<div id="masterdiv">' +  menu + '</div><div class="menutitle"></div>');



/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only
var parent = "";
var ch = "";

if (document.getElementById){ //DynamicDrive.com change
	document.write('<style type="text/css">\n')
	document.write('.submenu{display: none;}\n')
	document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
		var el = document.getElementById(obj);
		var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function setSelected(parent1,child)
{
	parent = parent1;
	ch = child;
	var divs = document.getElementById("masterdiv").getElementsByTagName("div");
	for (var i=0; i<divs.length; i++)
	{
		divs[i].className = "menutitle";
	}
	
	if (document.getElementById(parent) != null)
		document.getElementById(parent).className = "menutitleSelected";
}

function get_cookie(Name) {
	var search = Name + "="
	var returnvalue = "";
	if (document.cookie.length > 0)
	{
		offset = document.cookie.indexOf(search)
		if (offset != -1) {
			offset += search.length
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			returnvalue=unescape(document.cookie.substring(offset, end))
		}
	}
	return returnvalue;
}

function onloadfunction(){

	if (persistmenu=="yes")
	{
		var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname

		var cookievalue=get_cookie(cookiename)
		//	alert(cookievalue);
		if (cookievalue!="")
		{
			var bites = cookievalue.split('|');;
			parent = (bites[0] != null && bites[0] != "undefined" && bites[0].length > 0) ? bites[0] : "";
			ch = (bites[1] != null && bites[1] != "undefined" &&  bites[1].length > 0) ? bites[1] : "";
			//	alert(parent + "\n" + ch);
			if (parent != null && parent.length > 0 && ch.length > 0)
			{
				document.getElementById(ch).style.display="block";
				setSelected(parent,ch);
			}
			else
			{
				document.getElementById(parent).style.display="block";
				setSelected(parent,ch);
			}
		}
	}
}

function savemenustate()
{
	//if(ch != null && ch.length > 0) parent = ch;

	var loaded = (parent + "|" + ch);

	var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname;
	var cookievalue=(persisttype=="sitewide")? loaded+";path=/;" : parent;
	document.cookie=cookiename+"="+cookievalue;
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate;

function Go(url)
{
	top.location.href=url;
}