// DOM Style Controls - by Paul @ Yellow Pencil .com

function scriptInit() {
if (!document.getElementById) {
	return;
	}
}
function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} 
	else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	} 
	else {
		elm['on' + evType] = fn;
	}
}
function checkActive() {
	var a = document.getElementsByTagName("a");
	
	if (window.location.href.substr(location.href.length - 1, 1) == '/') {
		var loc = window.location.href + 'index.html'; 
	}
	// For about Subnav
	else if (window.location.href.substr(location.href.length - 10) == 'about.html') {
		var temp = window.location.href.substr(0, location.href.length - 10);
		temp += 'about.html';
		var loc = temp;			
	}	
	// For portfolio Subnav
	else if (window.location.href.substr(location.href.length - 14) == 'portfolio.html') {
		var temp = window.location.href.substr(0, location.href.length - 14);
		temp += 'portfolio.html';
		var loc = temp;			
	}
	// For contact Subnav
	else if (window.location.href.substr(location.href.length - 12) == 'contact.html') {
		var temp = window.location.href.substr(0, location.href.length - 12);
		temp += 'contact.html';
		var loc = temp;			
	}
	
	else {
		var loc = window.location.href;
	}
	for(var i=0; i < a.length; i++) {
		if (a[i].href == loc) {
			a[i].setAttribute("class", "active");
			a[i].setAttribute("className", "active");
		}
	}
}
addEvent(window, 'load', checkActive, false);