// JavaScript Document

	/*Booklet Variables*/
	var intro = new Array("Table of Contents","index.html");
	var introTitle = "Introduction";
	
	var chapterIntro = new Array(introTitle,intro);
	
	var ch1Title = "Chapter 1 - What is an Extra?";
	var ch1e1 = new Array("How to be a Paid Extra","paid-acting-extra.html");
	var ch1e2 = new Array("Do I need to be in Hollywood to be an Extra?","hollywood-extras.html");
	var ch1e3 = new Array("Do I need to take acting lessons to be an Extra?","acting-lessons.html");
	var ch1e4 = new Array("What exactly is an EXTRA?","extra-definition.html");
	
	var chapter1 = new Array(ch1Title, ch1e1, ch1e2, ch1e3, ch1e4);
	
	var ch2Title = "Chapter 2 - How to Become a Working Extra";
	var ch2e1 = new Array("Why be an Extra?","why.html");
	var ch2e2 = new Array("Getting a job as an Extra","extra-jobs.html");
	var ch2e3 = new Array("Set Photos","set-photos.html");
	
	var chapter2 = new Array(ch2Title, ch2e1, ch2e2, ch2e3);
	
	var ch3Title = "Chapter 3 - A Day in the Life of an Extra";
	var ch3e1 = new Array("Production Staff hierarchy, Responsibilities of the Extras.","responsibilities.html");
	var ch3e2 = new Array("A day in the life of an Extra","average-day-extras-day.html");
	var ch3e3 = new Array("Getting Paid as an Extra","extras-pay.html");
	var ch3e4 = new Array("Eating on the Set","food.html");
	
	var chapter3 = new Array(ch3Title, ch3e1, ch3e2, ch3e3, ch3e4);
	
	var ch4Title = "Chapter 4 - Info to get Started";
	var ch4e1 = new Array("Page Training and Tools for Extras","extras-training.html");
	var ch4e2 = new Array("Tools of the Trade","tools.html");
	var ch4e3 = new Array("Head Shots","headshots.html");
	var ch4e4 = new Array("Wardrobe","wardrobe.html");
	var ch4e5 = new Array("How much can I make as an Extra?","union-rates.html");
	var ch4e6 = new Array("Film Union Info","union-info.html");
	var ch4e7 = new Array("EXTRA CASTING COMPANIES, CASTING DIRECTORS, And Guide TO...","extra-casting-companies.html");
	var ch4e8 = new Array("Other Ways of Getting Extra work.","extra-work.html");
	var ch4e9 = new Array("Television Extra work. Getting your car into a Film","car-acting.html");
	
	var chapter4 = new Array(ch4Title, ch4e1, ch4e2, ch4e3, ch4e4,ch4e5, ch4e6, ch4e7, ch4e8, ch4e9);
	
	var ch5Title = "Chapter 5 - Casting Companies";
	var ch5e1 = new Array("Casting Company Lists","casting-companies.html");
	var ch5e2 = new Array("Los Angeles Casting Companies","la-casting.html");
	var ch5e3 = new Array("New York Casting Companies","ny-casting.html");
	var ch5e4 = new Array("Chicago Casting Companies","chicago-casting.html");
	
	var chapter5 = new Array(ch5Title, ch5e1, ch5e2, ch5e3, ch5e4);
	
	var ch6Title = "Chapter 6 - Industry Terms";
	var ch6e1 = new Array("Basic Studio Lingo so You don't sound like an idiot on the Set","industry-terms.html");
	
	var chapter6 = new Array(ch6Title, ch6e1);
	
	var ch7Title = "Chapter 7 - Bonus Links";
	var ch7e1 = new Array("Bonus Links for more Extra Casting Info","links.html");
	
	var chapter7 = new Array(ch7Title, ch7e1);
	
	var booklet = new Array(8);
	booklet[0] = chapterIntro;
	booklet[1] = chapter1;
	booklet[2] = chapter2;
	booklet[3] = chapter3;
	booklet[4] = chapter4;
	booklet[5] = chapter5;
	booklet[6] = chapter6;
	booklet[7] = chapter7;

	/*Parse File Name*/

	function getFileName(){
		var url = document.URL;
		var start = "";

		//for normal '/' address feeds

		if(url.lastIndexOf('\\')==-1) {
			start = url.lastIndexOf('\/')+1;	
		}

		// for ie

		else {
			start = url.lastIndexOf('\\')+1;			  
		}

		var end = url.length;
		var currentURL = url.substring(start, end);
		return currentURL;
	}

	/*Set Current*/

	function currentElement(elementID){

		document.getElementById(elementID).className += ' current';

	}

	function breadCrumbs(chIndex, topicIndex){

		breadCrumbID = document.getElementById('bread-crumbs');

		crumbs = "<a href=\"http:\/\/www.tvtix.com\/\">TVTix.com<\/a> >> ";

		crumbs += "<a href=\"http:\/\/www.tvtix.com\/extras\/\">How To Be a Paid Extra<\/a> >> ";

		crumbs += "<a class=\"current\" href=\"http:\/\/www.tvtix.com\/extras\/" + booklet[chIndex][topicIndex][1] + "\">" + booklet[chIndex][topicIndex][0] + "<\/a>";

		breadCrumbID.innerHTML = crumbs;

	}

	function renderPage(){

		var thisFile = getFileName();
		var currentChapter="";
		var currentEntry="";
		var previousEntry = "";
		var nextEntry = "";

		var ftMenu = new YAHOO.widget.Menu("footer-nav", { fixedcenter: true, lazyload: true, maxheight: 200, position: "absolute", visible: false });

		var chapterCopy = document.getElementById("chapter");
		var entryCopy = document.getElementById("entry");
		var ftNav = document.getElementById("ft-nav");
		var prevButton = document.getElementById("prev");
		var nextButton = document.getElementById("next");
		var chID = "";

		for(a=0;a<=booklet.length-1;a++){

			for(b=0;b<=booklet[a].length-1;b++){

				if(booklet[a][b][1]==thisFile) {
					currentChapter = booklet[a][0].toString();
					currentEntry = booklet[a][b][0].toString();
					chID = "ch" + a;
					breadCrumbs(a, b);
					
					ftMenu.addItem({text: booklet[a][b][0], url: booklet[a][b][1], classname: "current"}, a);
					document.getElementById("currently-on").innerHTML = "<div class=\"ft-nav-label\">You're currently On:</div>" +
	                booklet[a][b][0];

					
					if(booklet[a][b+1]){
						nextButton.innerHTML = "<a href=\"" + booklet[a][b+1][1] + "\"><h4>Next Topic >><\/h4>" + booklet[a][b+1][0] + "</a>";			}

					else if( (a+1) < booklet.length ){
						nextButton.innerHTML = "<a href=\"" + booklet[a+1][1][1] + "\"><h4>Next Topic >><\/h4>" + booklet[a+1][1][0] + "</a>";			}

					if(booklet[a][b-1] && b-1!=0){
						prevButton.innerHTML = "<a href=\"" + booklet[a][b-1][1] + "\"><h4><< Previous Topic<\/h4>" + booklet[a][b-1][0] + "</a>";		}

					else if(booklet[a-1]){
						prevButton.innerHTML = "<a href=\"" + booklet[a-1][(booklet[a-1].length-1)][1] + "\"><h4><< Previous Topic<\/h4>" + booklet[a-1][booklet[a-1].length-1][0] + "</a>";			
					}
				}
				
				else if (b!=0) {
					ftMenu.addItem({text: booklet[a][b][0], url: booklet[a][b][1]},a);
				}
			
			}
			ftMenu.setItemGroupTitle(booklet[a][0], a); 
		}

		ftMenu.render("footer-nav-container");
		YAHOO.util.Event.addListener("footer-nav-toggle", "click", ftMenu.show, null, ftMenu);

		chapterCopy.innerHTML = currentChapter;
		entryCopy.innerHTML = currentEntry;
		currentElement(chID);
	}