// NavBar Script
// Copyright (C) Daniel Tullemans 2006

// Page object type
function objPage(in_name, in_text, in_url)
{
	var newPage = Array();
	newPage["name"] = in_name;
	newPage["text"] = in_text;
	newPage["url"] = in_url;
	return newPage;
}

var formatStart = new Array();
var formatEnd = new Array();
var pages = new Array();
var headerCode = "header";
var html_out = "";

// Formatting codes
formatStart["page"] = "";
formatEnd["page"] = "<br>";

formatStart["header"] = "<br><strong><em>";
formatEnd["header"] = "</em></strong><br>";

formatStart["current"] = "<em>";
formatEnd["current"] = "</em><br>";

var numPages = 0;

function addPage(in_pgname, in_pgtext, in_pgurl)
{
	pages[numPages] = objPage(in_pgname, in_pgtext, in_pgurl);
	numPages++;
}

// Codename first,
// Text second,
// URL third.
//
// If you want to make a heading, make the codename equal to headerCode

// MAKE SURE TO UPDATE THIS WHENEVER NEW PAGES ARE ADDED

addPage(headerCode, "Main:", "");
addPage("home", "Home", "index.htm");
addPage("aboutme", "About me", "aboutme.htm");
addPage("whatis", "Asperger's Syndrome: What is it?", "whatis.htm");
addPage("understanding", "Understanding ASD", "understanding.htm");
addPage("upcoming", "Upcoming presentations", "upcoming.htm");
addPage("resources", "Resources", "resources.htm");
addPage("contact", "Contact me", "contact.htm");
addPage("links", "Links", "links.htm");

addPage(headerCode, "Sensory Toys:", "");
addPage("senstoys", "Catalogue", "senstoys.htm");

addPage(headerCode, "Books:", "");
addPage("book-which", "Choosing an appropriate school", "book-which.htm");
addPage("book-family", "Talking to family and Friends", "book-family.htm");
addPage("book-teachers", "Working with Teachers", "book-teachers.htm");
addPage("book-essential", "The Essential Guide to Secondary School", "book-essential.htm");
addPage("book-brb", "Teacher Assistants Big Red Book", "book-brb.htm");
addPage("book-howtostop", "How to Stop Your Words Bumping...", "book-howtostop.htm");
addPage("book-igts", "I'm Going To School", "book-igts.htm");
addPage("book-funside", "The Fun Side of Asperger", "book-funside.htm");

addPage(headerCode, "Articles:", "");
addPage("meeting-teacher", "Meeting with your Teacher", "meeting-teacher.htm");
addPage("teachers", "Teachers", "teachers.htm");
addPage("t-aides", "Teacher Aides", "t-aides.htm");
addPage("perfect", "The Importance of Being Perfect", "perfect.htm");
addPage("transitions", "Transitions", "transitions.htm");
addPage("parents", "Parents", "parents.htm");
addPage("hugs", "Creating Opportunities for Hugs", "hugs.htm");
addPage("visitors", "Preparing for Visitors", "visitors.htm");
addPage("pracstrat", "Practical Strategies", "pracstrat.htm");

addPage(headerCode, "Other:", "");
addPage("newsletter", "Newsletter", "newsletter.htm");


function writeNavBar(currentPage)
{
	for (var x=0; x<numPages; x++)
	{
		var pagelink = pages[x];
		var pagetype = "page";
		if (pagelink["name"] == headerCode)
		{
			pagetype = "header";
		}
		else if (pagelink["name"] == currentPage)
		{
			pagetype = "current";
		}
		
		html_out += formatStart[pagetype];
		if (pagetype == "page")
		{
			html_out += "<a href='" + pagelink["url"] + "'>";
		}
		html_out += pagelink["text"];
		if (pagetype == "page")
		{
			html_out += "</a>";
		}
		html_out += formatEnd[pagetype];
	}
	document.write(html_out);
}











