MENU_FESTIVAL		 		= 0x00;
MENU_PASSES					= 0x01;
MENU_SCHEDULE				= 0x02;
MENU_PROGRAMMING			= 0x03;
MENU_CONFERENCE				= 0x04;
MENU_MERCHANDISE			= 0x05;
MENU_SPONSORSHIP			= 0x06;
MENU_MEDIA					= 0x07;

MENU_ID						= "menu";
SUB_ID						= "menu_sub";
SUB_TOP						= "184px";
SUB_WIDTH					= "150px";
SUB_BACKGROUND_COLOR		= "#FFFFFF";
SUB_BACKGROUND_COLOR_HL		= "#CCCCCC";
SUB_BORDER_LEFT				= "1px solid #666666";
SUB_BORDER_RIGHT			= "1px solid #999999";
SUB_BORDER_TOP				= "1px solid #666666";
SUB_BORDER_BOTTOM			= "1px solid #999999";
SUB_COLOR					= "#666666";
SUB_COLOR_HL				= "#000000";
SUB_FONT_FAMILY				= "arial sans";
SUB_FONT_SIZE				= "8pt";
SUB_PADDING_LEFT			= "2px";
SUB_PADDING_RIGHT			= "2px";
SUB_PADDING_TOP				= "2px";
SUB_PADDING_BOTTOM			= "2px";
SUB_POSITION				= "absolute";

var g_menu = new MenuNode();
var g_blnSub = false;

function body_onload()
{
	//init menu
	var sub = g_menu.insertChild( MENU_FESTIVAL, new MenuNode( "Festival Information", "http://www.awn.com/ottawa/OIAF05/index.php" ) );	
	sub.appendChild( new MenuNode( "Festival Information", "http://www.awn.com/ottawa/OIAF05/index.php" ) );
    sub.appendChild( new MenuNode( "Contact Information", "http://www.awn.com/ottawa/OIAF05/fest_contact.php" ) );
	sub.appendChild( new MenuNode( "Entry Information", "http://www.awn.com/ottawa/OIAF05/fest_entry.php" ) );
	sub.appendChild( new MenuNode( "Passes", "http://www.awn.com/ottawa/OIAF05/fest_passes.php" ) );
	//sub.appendChild( new MenuNode( "Tickets", "http://www.awn.com/ottawa/OIAF05/fest_tickets.php" ) );
	sub.appendChild( new MenuNode( "Accommodations/Travel", "http://www.awn.com/ottawa/OIAF05/fest_accommodation.php" ) );
	sub.appendChild( new MenuNode( "Volunteering", "http://www.awn.com/ottawa/OIAF05/fest_volunteer.php" ) );
	sub.appendChild( new MenuNode( "Canadian Animation Directory", "http://www.awn.com/ottawa/OIAF05/fest_directory.php" ) );
    sub.appendChild( new MenuNode( "Best of Ottawa 2004", "http://www.awn.com/ottawa/OIAF05/fest_bestof2004.php" ) );
	sub.appendChild( new MenuNode( "CFI Screenings", "http://www.awn.com/ottawa/OIAF05/fest_cfiscreenings.php" ) );
	//sub.appendChild( new MenuNode( "Merchandise", "javascript:openNewWindow('http://www.awn.com/ottawa/merchandise/index.php');" ) );
	sub.appendChild( new MenuNode( "History of OIAF", "http://www.awn.com/ottawa/OIAF05/fest_history.php" ) );
	sub.appendChild( new MenuNode( "Award Winners", "http://www.awn.com/ottawa/OIAF05/fest_award.php" ) );
	sub.appendChild( new MenuNode( "Past Festivals", "http://www.awn.com/ottawa/OIAF05/fest_past.php" ) );
	sub.appendChild( new MenuNode( "Pictures", "http://www.awn.com/ottawa/OIAF05/fest_pictures.php" ) );
	sub.appendChild( new MenuNode( "Ottawa Information", "http://www.awn.com/ottawa/OIAF05/fest_ottawa.php" ) );
	sub.appendChild( new MenuNode( "Animation Links", "http://www.awn.com/ottawa/OIAF05/fest_links.php" ) );
	sub.appendChild( new MenuNode( "Join OIAF's Mailing List", "http://www.awn.com/ottawa/OIAF05/fest_mailing.php" ) );

	sub = g_menu.insertChild( MENU_PASSES, new MenuNode( "Passes", "http://www.awn.com/ottawa/OIAF05/fest_passes.php" ) );
	sub.appendChild( new MenuNode( "Passes", "http://www.awn.com/ottawa/OIAF05/fest_passes.php" ) );
	sub.appendChild( new MenuNode( "Animapass", "http://www.awn.com/ottawa/OIAF05/fest_passes.php#anima" ) );
    sub.appendChild( new MenuNode( "TAC Animapass", "http://www.awn.com/ottawa/OIAF05/fest_passes.php#tacanima" ) );
	sub.appendChild( new MenuNode( "TAC Pass", "http://www.awn.com/ottawa/OIAF05/fest_passes.php#taconly" ) );
	sub.appendChild( new MenuNode( "Weekend Pass", "http://www.awn.com/ottawa/OIAF05/fest_passes.php#weekend" ) );
	sub.appendChild( new MenuNode( "Day Pass", "http://www.awn.com/ottawa/OIAF05/fest_passes.php#day" ) );
	sub.appendChild( new MenuNode( "Pass Order Form", "http://www.awn.com/ottawa/fest_passorder.html" ) );
	sub.appendChild( new MenuNode( "TAC Pass Order Form", "http://www.awn.com/ottawa/fest_tacpassorder.html" ) );
	sub.appendChild( new MenuNode( "Ticket Information", "http://www.awn.com/ottawa/OIAF05/fest_tickets.php" ) );
	
	sub = g_menu.insertChild( MENU_SCHEDULE, new MenuNode( "Schedule", "http://www.awn.com/ottawa/OIAF05/schedule_day1.php" ) );
	sub.appendChild( new MenuNode( "Wed. Sept. 21", "http://www.awn.com/ottawa/OIAF05/schedule_day1.php" ) );
	sub.appendChild( new MenuNode( "Thurs. Sept. 22", "http://www.awn.com/ottawa/OIAF05/schedule_day2.php" ) );
	sub.appendChild( new MenuNode( "Fri. Sept. 23", "http://www.awn.com/ottawa/OIAF05/schedule_day3.php" ) );
	sub.appendChild( new MenuNode( "Sat. Sept. 24", "http://www.awn.com/ottawa/OIAF05/schedule_day4.php" ) );
	sub.appendChild( new MenuNode( "Sun. Sept. 25", "http://www.awn.com/ottawa/OIAF05/schedule_day5.php" ) );

	sub = g_menu.insertChild( MENU_PROGRAMMING, new MenuNode( "Programming", "http://www.awn.com/ottawa/OIAF05/prog.php" ) );
	sub.appendChild( new MenuNode( "Programming", "http://www.awn.com/ottawa/OIAF05/prog.php" ) );
	sub.appendChild( new MenuNode( "Honorary President", "http://www.awn.com/ottawa/OIAF05/prog_president.php" ) );
	sub.appendChild( new MenuNode( "International Jury", "http://www.awn.com/ottawa/OIAF05/prog_jury.php" ) );
	sub.appendChild( new MenuNode( "Official Selections", "http://www.awn.com/ottawa/OIAF05/prog_selections.php" ) );
    sub.appendChild( new MenuNode( "Competition Screenings", "http://www.awn.com/ottawa/OIAF05/prog_competition.php" ) );
	sub.appendChild( new MenuNode( "Showcase Screenings", "http://www.awn.com/ottawa/OIAF05/prog_showcase.php" ) );
	sub.appendChild( new MenuNode( "Special Screenings", "http://www.awn.com/ottawa/OIAF05/prog_screenings.php" ) );
	sub.appendChild( new MenuNode( "Workshops", "http://www.awn.com/ottawa/OIAF05/prog_workshops.php" ) );
	sub.appendChild( new MenuNode( "Animarket", "http://www.awn.com/ottawa/OIAF05/prog_animarket.php" ) );
    sub.appendChild( new MenuNode( "Technology Forum", "http://www.awn.com/ottawa/OIAF05/prog_techforum.php" ) );
	sub.appendChild( new MenuNode( "Career Day", "http://www.awn.com/ottawa/OIAF05/prog_careerday.php" ) );
	sub.appendChild( new MenuNode( "Book Signings", "http://www.awn.com/ottawa/OIAF05/prog_booksignings.php" ) );
	sub.appendChild( new MenuNode( "Free Events for Teens", "http://www.awn.com/ottawa/OIAF05/prog_toonapprentice.php" ) );
	sub.appendChild( new MenuNode( "Family Events", "http://www.awn.com/ottawa/OIAF05/prog_family.php" ) );
	sub.appendChild( new MenuNode( "Parties & Events", "http://www.awn.com/ottawa/OIAF05/prog_events.php" ) );
	sub.appendChild( new MenuNode( "Animation Resource Centre", "http://www.awn.com/ottawa/OIAF05/prog_resourcecentre.php" ) );
    sub.appendChild( new MenuNode( "Venues & Festival Map", "http://www.awn.com/ottawa/OIAF05/prog_venues.php" ) );

	sub = g_menu.insertChild( MENU_CONFERENCE, new MenuNode( "Television Animation Conference", "http://www.awn.com/ottawa/OIAF05/conf.php" ) );
	sub.appendChild( new MenuNode( "Television Animation Conference", "http://www.awn.com/ottawa/OIAF05/conf.php" ) );
    sub.appendChild( new MenuNode( "About TAC", "http://www.awn.com/ottawa/OIAF05/conf_about.php" ) ); 
	sub.appendChild( new MenuNode( "Registration & Passes", "http://www.awn.com/ottawa/OIAF05/conf_registrationpasses.php" ) );
	sub.appendChild( new MenuNode( "Programme", "http://www.awn.com/ottawa/OIAF05/conf_programme.php" ) );
	//sub.appendChild( new MenuNode( "Conference Speakers", "http://www.awn.com/ottawa/OIAF05/conf_speakers.php" ) );
	sub.appendChild( new MenuNode( "Keynote Speakers", "http://www.awn.com/ottawa/OIAF05/conf_keynote.php" ) );
	sub.appendChild( new MenuNode( "Networking Opportunities", "http://www.awn.com/ottawa/OIAF05/conf_networking.php" ) );
    sub.appendChild( new MenuNode( "Screenings", "http://www.awn.com/ottawa/OIAF05/conf_screenings.php" ) );
    sub.appendChild( new MenuNode( "Schedule", "http://www.awn.com/ottawa/OIAF05/conf_schedule.php" ) );
	sub.appendChild( new MenuNode( "Delegate Guide", "http://www.awn.com/ottawa/OIAF05/conf_guide.php" ) );
	sub.appendChild( new MenuNode( "Venue", "http://www.awn.com/ottawa/OIAF05/conf_venue.php" ) );
	
	sub = g_menu.insertChild( MENU_MERCHANDISE, new MenuNode( "Merchandise", "javascript:openNewWindow('http://www.awn.com/ottawa/merchandise/index.html');" ) );
	sub.appendChild( new MenuNode( "Merchandise", "javascript:openNewWindow('http://www.awn.com/ottawa/merchandise/index.html');" ) );
	sub.appendChild( new MenuNode( "2005 Merchandise", "javascript:openNewWindow('http://www.awn.com/ottawa/merchandise/images/2005merchandise4.htm');" ) );
    sub.appendChild( new MenuNode( "2004 Merchandise", "javascript:openNewWindow('http://www.awn.com/ottawa/merchandise/images/05%20merchandise.htm');" ) );

			
	sub = g_menu.insertChild( MENU_SPONSORSHIP, new MenuNode( "Sponsorship", "http://www.awn.com/ottawa/OIAF05/spon.php" ) );
	sub.appendChild( new MenuNode( "Sponsorship", "http://www.awn.com/ottawa/OIAF05/spon.php" ) );
    sub.appendChild( new MenuNode( "Sponsorship Inquiry", "http://www.awn.com/ottawa/OIAF05/spon_inquiry.php" ) );
	sub.appendChild( new MenuNode( "Sponsorship Packages", "http://www.awn.com/ottawa/OIAF05/spon_packages.php" ) );
	sub.appendChild( new MenuNode( "Animarket", "http://www.awn.com/ottawa/OIAF05/spon_animarket.php" ) );
	//sub.appendChild( new MenuNode( "Advertising", "http://www.awn.com/ottawa/OIAF05/spon_advertising.php" ) );

	sub = g_menu.insertChild( MENU_MEDIA, new MenuNode( "Media", "http://www.awn.com/ottawa/OIAF05/med.php" ) );
	sub.appendChild( new MenuNode( "Media", "http://www.awn.com/ottawa/OIAF05/med.php" ) );
    sub.appendChild( new MenuNode( "Media Releases", "http://www.awn.com/ottawa/OIAF05/med_newsrelease.php" ) );
	sub.appendChild( new MenuNode( "Media Accreditation Form", "http://www.awn.com/ottawa/OIAF05/pdf/Media_Pass_Request_Form.pdf" ) );
}

function body_onmousemove()
{
	if( g_blnSub )	hideSub();
}

function menu_onclick( id )
{
	var url = g_menu.getChild( id ).url;
	if( url != "" )	window.location = url;
}

function menu_onmouseover( id, src, srcX, srcWidth )
{
	if( g_blnSub )									hideSub();
	if( g_menu.getChild( id ).hasChildren() )		showSub( id, src, srcX, srcWidth );
	if( g_menu.getChild( id ).url != "" )			src.style.cursor = "hand";
}

function menuItem_onmouseover( e )
{
	var src = e ? e.target : window.event.srcElement;
	
	if( src.nodeType == 3 )		src = src.parentNode;
	src.style.backgroundColor = SUB_BACKGROUND_COLOR_HL;
	src.style.color = SUB_COLOR_HL;
	src.style.cursor = "hand";
}

function menuItem_onmouseout( e )
{
	var src = e ? e.target : window.event.srcElement;
	
	if( src.nodeType == 3 )		src = src.parentNode;
	src.style.backgroundColor = SUB_BACKGROUND_COLOR;
	src.style.color = SUB_COLOR;
	src.style.cursor = "auto";
}

function menuItem_onclick( e )
{
	var src = e ? e.target : window.event.srcElement;
	
	if( src.nodeType == 3 )		src = src.parentNode;
	window.location = src.url;
}

function showSub( id, src, srcX, srcWidth )
{
	var subMenu = document.createElement( "DIV" );
	subMenu.id = SUB_ID;
	subMenu.style.left = srcX;
	subMenu.style.top = SUB_TOP;
	subMenu.style.width = SUB_WIDTH;
	subMenu.style.color = SUB_COLOR;
	subMenu.style.fontFamily = SUB_FONT_FAMILY;
	subMenu.style.fontSize = SUB_FONT_SIZE;
	subMenu.style.backgroundColor = SUB_BACKGROUND_COLOR;
	subMenu.style.borderLeft = SUB_BORDER_LEFT;
	subMenu.style.borderRight = SUB_BORDER_RIGHT;
	subMenu.style.borderTop = SUB_BORDER_TOP;
	subMenu.style.borderBottom = SUB_BORDER_BOTTOM;
	subMenu.style.paddingLeft = SUB_PADDING_LEFT;
	subMenu.style.paddingRight = SUB_PADDING_RIGHT;
	subMenu.style.paddingTop = SUB_PADDING_TOP;
	subMenu.style.paddingBottom = SUB_PADDING_BOTTOM;
	subMenu.style.position = SUB_POSITION;
	
	//create sub menu items
	var aSubMenus = g_menu.getChild( id ).getChildren();
	for( i = 0; i < aSubMenus.length; i++ )
	{
		// create menu item
		var menuItem = document.createElement( "DIV" );
		menuItem.style.width = SUB_WIDTH;
		menuItem.url = aSubMenus[i].url;
		menuItem.onmouseover = menuItem_onmouseover;
		menuItem.onmouseout = menuItem_onmouseout;
		menuItem.onclick = menuItem_onclick;
		menuItem.appendChild( document.createTextNode( aSubMenus[i].label ) );
		
		subMenu.appendChild( menuItem );
	}
	
	document.getElementById( MENU_ID ).appendChild( subMenu );
	g_blnSub = true;	
}

function hideSub()
{
	var menu = document.getElementById( MENU_ID );
	var sub = document.getElementById( SUB_ID );
	menu.removeChild( sub );
	
	g_blnSub = false;
}
