// 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.php';

		var parentloc = loc;

	}

	else {

		var loc = window.location.href;

		var slashpos = loc.lastIndexOf('/');

		var parentloc = loc.substr(0, slashpos + 1) + 'index.php';

	}

	for(var i=0; i < a.length; i++) {

		var currentUrl = a[i].href



		if (parentloc.indexOf('www.pragmaticmartialarts.com/index.php') < 1 && parentloc.indexOf('.com/index.php') < 1)

		{

			if (parentloc.indexOf(currentUrl) >= 0)

			{

				a[i].setAttribute("class", "active");

				a[i].setAttribute("className", "active");

			}

		}



		if (loc.indexOf(currentUrl) >= 0)

		{

			a[i].setAttribute("class", "active");

			a[i].setAttribute("className", "active");

		}
		
		if(loc.indexOf("testimonials.php") >= 0 && currentUrl.indexOf("instructor.php")>=0)
		{

			a[i].setAttribute("class", "active");

			a[i].setAttribute("className", "active");

		}
		
		
		var articlesArray=new Array("mma.php","learningmartialarts.php","lookingattechniques.php","confidence.php");
		
		for (x=0;x<articlesArray.length;x+=1) 
		{
   
			if(loc.indexOf(articlesArray[x]) >= 0 && currentUrl.indexOf("articles.php")>=0)
			{

				a[i].setAttribute("class", "active");

				a[i].setAttribute("className", "active");

			}
		
		}

	}

}

addEvent(window, 'load', checkActive, false);