// JavaScript Document

function remove_hash(str)
{
	// removes everything from # to end of string
	var wherehash = str.lastIndexOf('#');
	if(wherehash != -1)
	{
		str = str.slice(0,wherehash)
	}
	return str;
}

function remove_ext(str)
{
	// removes file extention
	var whereext = str.lastIndexOf('.');
	var whereslash = str.lastIndexOf('/');
	if((whereext != -1) && (whereext > whereslash))
	{
		str = str.slice(0,whereext)
	}
	return str;
}

function remove_index(str)
{
	//removes word index if it is last word in string
	var whereindex = str.lastIndexOf('index');
	var whereslash = str.lastIndexOf('/');
	if((whereindex != -1) && (whereindex > whereslash))
	{
		str = str.slice(0,whereindex)
	}
	return str;
}

function top_dir(str)
{
	// returns http://something/something/
	var firstslash = str.indexOf('/', 7);
	var secondslash = str.indexOf('/', firstslash + 1);
	var thirdslash = str.indexOf('/', secondslash + 1);
	if(thirdslash != -1)
	{
		str = str.slice(0,thirdslash+1);		
	}
	return str;	
}

function markthispage()
{
	var thispage=location.href;
	// remove hash
	remove_hash(thispage);
	// remove file extention
	remove_ext(thispage);
	// remove 'index'
	remove_index(thispage);
	
	var thissection = top_dir(thispage);
	
	var atags=document.getElementsByTagName('a');
	
	for(var i=0;i<atags.length;i++)
	{
		var thislink = atags[i].href;
		// remove from # to end of link
		remove_hash(thislink);
		// remove file extention
		remove_ext(thislink);
		// remove 'index'
		remove_index(thislink);
		
		if(thissection == thislink)
		{
				atags[i].className = "thissection";
		}

		if (thispage == thislink)
		{
			atags[i].className = "thispage";
		}
		
	}
}

/*
function navChange()
{
	thisPath=location.pathname;
	arrPath=thisPath.split("/");
	thisFolder=arrPath[8]; 
	thisPage=arrPath[9];

	for(i=0; i<6; i++)
	{
		if(arrFolders[i][0] == thisFolder)
		{	
			if(thisPage == "index.html" || thisPage == "")
			{
				// if page is in folder, change folder to navThisPage class
				navLink = returnObjById(arrFolders[i][1]);
				navLink.className = "navThisPage";
			}
			else
			{
				// if page is root/index page, change folder to navThisFolder class
				navLink = returnObjById(arrFolders[i][1]);
				navLink.className = "navThisFolder";
			}
		}
	}

}
*/