/* **********************************************************
*  JavaScript definitions for siennasguidetomusic.com
*  **********************************************************
*/

window.addEvent('domready', function(){
	// change class of link to current page
		
	// get all anchors on page
	var allAnchors = $$('a');
	
	// get url as a string
	var page = window.location.toString();

	//if only directory is given, append 'index.html'
	if(page.charAt(page.length -1) == '/'){
		page = page.concat('index.html');
	}
	
	//if bookmark is in url, remove it
	if(page.contains('#')){
		page = page.substring(0, page.indexOf('#'));
	}
	
	// set the class of all anchors to none and
	// compare anchors to url to determine which is/are current
	
	for(i=0; i<allAnchors.length; i++){
		allAnchors[i].erase('class');
		if(allAnchors[i].match(page)){
			//alert('Found one! ' + allAnchors[i]);
			allAnchors[i].set('class', 'current');
		}
	}
	
	//make 'current' the section links in the tabbed navigation if in a subsection
	var basicstab = document.getElementById("basicstab");
	var topicstab = document.getElementById("topicstab");
	var hometab = document.getElementById("hometab");
	
	if(page.contains("Basics", "/")){
		//alert('Found Theory '+theorytab);
		basicstab.set('class', 'current');
		basicstab.getParent('li').set('class', 'current');
	}else{
		if(page.contains("Topics", "/")){
			//alert('Found History '+historytab);
			topicstab.set('class', 'current');
			topicstab.getParent('li').set('class', 'current');
		}else{
			if(page.contains("Home", "/")){
				hometab.set('class', 'current');
				hometab.getParent('li').set('class', 'current');
			}
		}
	}
});

