// JavaScript Document//these variables are used to find out what page we are onvar filename = location.href.substring(location.href.lastIndexOf('/')+1); //get full name of current pagevar pathname = location.href.substring(0,location.href.lastIndexOf('/'));var dirname = pathname.substring(pathname.lastIndexOf('/')+1);//alert (dirname);if(filename){ //if there is no filename, it must be grabbing "index.html" automaticallyvar nameIndex = filename.indexOf(".html"); //find index of the .html in the namevar pagename = filename.substring(0,nameIndex); //extract the file name without .html}else { var pagename='index';} //if there is no filename, it must be a directory, which makes the browser get "index.html" automatically//alert(pagename);		if (document.images) { //preload all images, otherwise the rollover is very slow    aboutnav       = new Image();    aboutnav.src   = "about_nav.png" ;    abouthover     = new Image() ;    abouthover.src = "about_hover.png" ;	aboutcurrent   = new Image();	aboutcurrent.src = "about_current.png";		blognav       = new Image();    blognav.src   = "blog_nav.png" ;    bloghover     = new Image() ;    bloghover.src = "blog_hover.png" ;	blogcurrent   = new Image();	blogcurrent.src = "blog_current.png";		projectsnav       = new Image();    projectsnav.src   = "projects_nav.png" ;    projectshover     = new Image() ;    projectshover.src = "projects_hover.png" ;	projectscurrent   = new Image();	projectscurrent.src = "projects_current.png";		squaretanglenav       = new Image();    squaretanglenav.src   = "index_nav.png" ;    squaretanglehover     = new Image() ;    squaretanglehover.src = "index_hover.png" ;	squaretanglecurrent   = new Image();	squaretanglecurrent.src = "index_current.png";}function setImage() { //this sets the appropriate "current" page image in the nav, it is called from an onLoad in the <body> tag of each page	if(document.getElementById(pagename))		{			document.getElementById(pagename).src=pagename+"_current.png";		}//the id of the img needs to be the same as the pagename, eg, if the page is "about.html" then <img id="about"> must be in the loadNav function below. If there is no such img id it will fail the if test, so sub pages work, eg, asx_e_dancer.html will show the nav bar with no "current" image, which is what we want.}function swapImage(id, imgname, swapname) { //rollover function - provide the id of the img tag, the filename of the regular image (imgname) and the filename of the swap-in image (swapimage) in the loadNav function below.	if(id != pagename) //if id = pagename, there should be no rollover 	{	document.getElementById(id).src=swapname;	}}function makeLink(name, linkid) { //function to work out if the image should be a link - name and linkname are provided in loadNav function below	if(name!=pagename) //if name=pagename it is the current page, so no need for link	{		//var pTag1 = document.getElementById(linkid); //linkname is provided in loadNav function below		if(name!='blog') //blog is a directory name, so needs special treatment		{		document.getElementById(linkid).setAttribute('href', name+'.html'); //set the href to be "name.html", name is provided in loadNav function below		}		else {document.getElementById(linkid).setAttribute('href', 'blog/');} //special treatment for blog	}}function loadNav() { //loadNav writes html to construct the nav bar and provide names for the above functions - single quotes are escaped with a backslash. This function is called on each individual html page.document.write('<div class="nav"> <div class="navlink"><a onMouseOver="makeLink(\'blog\',\'bloglink\');swapImage(\'blog\',\'blog_nav.png\',\'blog_hover.png\')" onMouseOut="swapImage(\'blog\',\'blog_hover.png\',\'blog_nav.png\')" id="bloglink"><img src="blog_nav.png" alt="blog" id="blog" width="55" height="17" border="0" /></a> | <a onMouseOver="makeLink(\'about\',\'aboutlink\');swapImage(\'about\',\'about_nav.png\',\'about_hover.png\')" onMouseOut="swapImage(\'about\',\'about_hover.png\',\'about_nav.png\')" id="aboutlink"><img src="about_nav.png" alt="about" id="about" width="69" height="17" border="0" /></a> | <a onMouseOver="makeLink(\'projects\',\'projectslink\');swapImage(\'projects\',\'projects_nav.png\',\'projects_hover.png\')" onMouseOut="swapImage(\'projects\',\'projects_hover.png\',\'projects_nav.png\')" id="projectslink"><img src="projects_nav.png" alt="projects" id="projects" width="113" height="17" border="0" /></a></div><div class="navhometext"><a onMouseOver="makeLink(\'index\',\'indexlink\');swapImage(\'index\',\'index_nav.png\',\'index_hover.png\')" onMouseOut="swapImage(\'index\',\'index_hover.png\',\'index_nav.png\')" id="indexlink"><img src="index_nav.png" alt="squaretangle" id="index" width="173" height="17" border="0" /></a></div></div>')}