// -------------------------------------------------------------------------------
// Called From: all of the pages that use the standard subnavigation
// Purpose: The page starts with two functions: PKD_showSubNav and PKD_hideSubNav.  Each 
//			function takes in the object name of the menu. 
//			Depending on the function called and the browser being used, 
//			the visibility state of the dropdown menu is altered using the 
//			appropriate DOM.
//
//			The page then preloads all of the images that will be used in the  
//			horizontal navigation bar.
//
//          The page then loads all of the subnavigation text into each dropdown menu.  
//			Each array consists of the array name, the location of the dropdown menu 
//			(pixels from the left), and the width of the menu.  This is followed by 
//			a varying number of text links and the address (URL) of each link.
//
//			The function PKD_setUpMenus then creates the dropdown menu using the information  
//			from the arrays.  This function takes 5 parameters: the background color of 
//          the menu, the rollover background color of the menu, the text color of 
//          the menu, the rollover text color, and the color of the line separating 
//          each link in the menu.   
// --------------------------------------------------------------------------------

function PKD_displaySelects( selectVisibility ) {
	for ( var i = 0; i < document.forms.length; i++ ) {
		for ( var j = 0; j < document.forms[i].elements.length; j++ ) {
			if ( document.forms[i].elements[j].type.indexOf( "select" ) != -1 ) {
				document.forms[i].elements[j].style.visibility = selectVisibility;
			}
		}
	}
}

function PKD_showSubNav(PKD_subnav){
			
			var PKD_nav;
			var PKD_complete;
			
			if(document.getElementById){
				PKD_complete = "document.getElementById('" + PKD_subnav + "Menu')";
			}
			else if(document.all){
				PKD_complete = "document.all['" + PKD_subnav + "Menu']";
			}
			
			PKD_nav = eval(PKD_complete);
				
			if (PKD_nav){
				PKD_nav.style.visibility = 'visible';	
			}
			
			PKD_displaySelects( 'hidden' );
}

function PKD_hideSubNav(PKD_subnav){
		
			var PKD_nav;
			var PKD_complete;
			
			if(document.getElementById){
				PKD_complete = "document.getElementById('" + PKD_subnav + "Menu')";
			}
			else if(document.all){
				PKD_complete = "document.all['" + PKD_subnav + "Menu']";
			}
			
			PKD_nav = eval(PKD_complete);
				
			if (PKD_nav){
				PKD_nav.style.visibility = 'hidden';	
			}
			
			PKD_displaySelects( 'visible' );
}

//<!-- Adds a suffix onto the image name so that the program calls the on state of the image -->
function PKD_imgOn(iname) {
	if (document.images) {
		document[iname].src = eval(iname + "on.src");
	}
}

//<!-- Adds a suffix onto the image name so that the program calls the off state of the image -->
function PKD_imgOff(iname) {
	if (document.images) {
		document[iname].src = eval(iname + "off.src");
	}
}

var PKD_arMenu = new Array();

	PKD_arMenu[0] = new Array(
			"PKD_about",
			555,		// Pixel offset from right edge.
			110,	// Width of menu.
			"Welcome", 	"aa_intro.html",
			"Biography", 		"aa_biography.html",
			"Photo Gallery", 	"aa_gallery.html",
			"The PKD Award", 	"links_pkdaward.html"
			);

	PKD_arMenu[1] = new Array(
			"PKD_works",
			444,	// Pixel offset from right edge.
			110,	// Width of menu.
			"Novels", 			"works_novels.html",
			"Short Stories", 	"works_stories.html",
			"Collections", 		"works_collections.html",
			"Other Works ", 	"works_other.html",
			"Cover Art", 		"works_covers.html"
			);

	PKD_arMenu[2] = new Array(
			"PKD_films",
			333,	// Pixel offset from right edge.
			110,	// Width of menu.
			"Intro to Films","films_intro.html",
			"Blade Runner", 			"films_bladerunner.html",
			"A Scanner Darkly","films_scanner.html",
						"Total Recall", 		"films_totalrecall.html",
			"Minority Report ", 	"films_minreport.html",
			"Next",					"films_next.html",
			"Paycheck", 			"films_paycheck.html",
			"Other Films ", 		"films_other.html",
			"Other Adaptations ", 	"films_adaptother.html"
			);

	PKD_arMenu[3] = new Array(
			"PKD_media",
			222,	// Pixel offset from right edge.
			110,	// Width of menu.
			"Latest News","media_intro.html",
			"PKD News Archive","media_archive1.html",
			"Articles",			"media_articles.html",
			"Print Interviews",	"media_print.html",
			"Audio", 			"media_audio.html",
			"Press Releases", 	"media_pressreleases.html"
			);

	PKD_arMenu[4] = new Array(
			"PKD_exclusive",
			111,	// Pixel offset from right edge.
			110,	// Width of menu.
			"About New Content",	"new_intro.html",
			"Writings",		"new_writings.html",
			"Letters",		"new_letters.html",
			"Exegesis", 	"new_exegesis.html"
			);

	PKD_arMenu[5] = new Array(
			"PKD_links",
			0,	// Pixel offset from right edge.
			110,	// Width of menu.
			"Site Map",			"links_sitemap.html",
			"Fan Site",			"http://www.philipkdickfans.com/",
			"PKD Award Site",	"http://www.philipkdickaward.org",
			"Paul Williams Site", "http://www.paulwilliams.com/",
			"Contacts", 		"links_contact.html",
			"Site Home", 		"index.html"
			);
		

function PKD_setUpMenus(PKD_backcolor, PKD_overcolor, PKD_textcolor, PKD_overtextcolor, PKD_linecolor){
	if ((document.all) || (document.getElementById)){

	var PKD_subnav = "";
			
			for (j = 0; j < PKD_arMenu.length; j++){
				PKD_subnav += "<div id=\"" + PKD_arMenu[j][0] + "Menu\" style=\"z-index:999;position: absolute; top: 35; right: " + PKD_arMenu[j][1] + "; width: " + PKD_arMenu[j][2] + ";  visibility: hidden\" onmouseover=\"PKD_showSubNav('" + PKD_arMenu[j][0] + "');\" onmouseout=\"PKD_hideSubNav('" + PKD_arMenu[j][0] + "');\">";
					PKD_subnav += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"" + PKD_arMenu[j][2] + "\">";
						
				for (i=3; i < PKD_arMenu[j].length-1; i=i+2){
					PKD_subnav += "<tr>";
					PKD_subnav += "<td width=\"110\" height=\"30\" bgcolor=\"" + PKD_backcolor + "\" onClick=\"document.location.href='" + PKD_arMenu[j][i+1] + "'\" onmouseover=\"this.bgColor='" + PKD_overcolor + "';this.style.color='" + PKD_overtextcolor+ "';\" onmouseout=\"this.bgColor='" + PKD_backcolor + "';this.style.color='" + PKD_textcolor + "'\" style=\"color: " + PKD_textcolor + "; font-family: arial,sans-serif; font-size: 10px;\"><div style=\"padding-left:12px;\">" + PKD_arMenu[j][i] + "</a></div></td>";
					PKD_subnav += "</tr>";
					PKD_subnav += "<tr>";
					PKD_subnav += "<td bgcolor=\"" + PKD_linecolor + "\" height=\"1\"></td>";
					PKD_subnav += "</tr>";
				}
					
				PKD_subnav += "</table>";
				PKD_subnav += "</div>";
			}

		document.write(PKD_subnav);
	}
}

