
function extractPageName(hrefString)
{
	var arr = hrefString.split('.');
	arr = arr[arr.length-2].split('/');
	return arr[arr.length-1].toLowerCase();		
}

function setActiveMenu(arr, crtPage)
{

	for(var i=0; i < arr.length; i++)
	if(crtPage == 'horse_mekki' || crtPage == 'horse_meripihka' || crtPage == 'horse_evapalema' || crtPage == 'horse_meerian' || crtPage == 'horse_hillahelle') {
		if(extractPageName(arr[i].href) == 'hevoset') {
			arr[i].className = "current";
			arr[i].parentNode.className = "current";
		}
	}
	else 	if(crtPage == 'tuote_asmena' || crtPage == 'tuote_poku' || crtPage == 'tuote_jalo' || crtPage == 'tuote_riuska' || crtPage == 'tuote_liina' || crtPage == 'tuote_lippo' || crtPage == 'tuote_rapsu' || crtPage == 'tuote_kivi' || crtPage == 'tuote_luumu' || crtPage == 'tuote_lumia' || crtPage == 'taulut') {
		if(extractPageName(arr[i].href) == 'tuotteet') {
			arr[i].className = "current";
			arr[i].parentNode.className = "current";
		}
	}
	
	else {	
		if(extractPageName(arr[i].href) == crtPage)
		{
			arr[i].className = "current";
			arr[i].parentNode.className = "current";
		}
	}
}

function setPage()
{
	if(document.location.href) 
		hrefString = document.location.href;
	else
		hrefString = document.location;

	if (document.getElementById("nav")!=null) 
		setActiveMenu(document.getElementById("nav").getElementsByTagName("a"), extractPageName(hrefString));
}
