/**************************************************************************
 *                                                                        *
 *  JAVASCRIPT MENU HIGHLIGHTER v.1.0 (051123)                            *
 * --------------------------------------------                           *
 * ©2005 Media Division (www.MediaDivision.com)                           *
 *                                                                        *
 * Written by Marius Smarandoiu & Armand Niculescu                        *
 *                                                                        *
 * You are free to use, modify and distribute this file, but please keep  *
 * this header and credits                                                *
 *                                                                        *
 * Usage:                                                                 *
 * - the script will apply the .current class to the <a> and its parent   *
 *   <li> that is contained in the element with id="primarynav" and points*
 *   to the current URL                                                   *
 * - works in IE6, Firefox and Opera                                      *
 **************************************************************************/

window.onload=setPage();

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(extractPageName(arr[i].href) == crtPage)
		{
			//document.write("bir oncesi... ");
			arr[i].className = "current";
			arr[i].parentNode.className = "current";
		}

		// Bir alt menü mü diye bak
		else
		{
			var atitle = arr[i].title;
			var temp=-1;
			var description=document.getElementsByTagName("meta")[1];
			if(description.name== "description")
			{
				temp = description.content.search(atitle);
			}
			//document.write(temp);
			if(temp>=0)
			{
				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-top")!=null) 
		setActiveMenu(document.getElementById("nav-top").getElementsByTagName("a"), extractPageName(hrefString));				
}

<!-- Added below on 22.12.06, A.B.Sevdik-->
function setMenuPageByTitle()
{
	//document.write("buradaaaa.. ");
	// Document.title yerine meta etiketinin name=description'da content kismina bak.
	var description=document.getElementsByTagName("meta")[1];
	var descp="";
	if(description.content)
		descp=description.content;
		//docTitle = document.title;
	/*else
		//docTitle = "";
		*/
	if(document.getElementById("subnav")!=null)
		setActiveMenuByTitle(document.getElementById("subnav").getElementsByTagName("a"), descp);	
}

function setActiveMenuByTitle(arr,crtPage)
{
	//document.write(crtPage+".. ");
	//document.write(arr.length);
	for(var i=0; i<arr.length; i++)
	{
		var title=arr[i].title;
		var temp=-1;
		temp=crtPage.search(title);
		//document.write(temp+"... ");
		if(temp>=0)
		{		
			//document.write("in temp if ")
			arr[i].className = "now";
			arr[i].parentNode.className = "now";
		}
	}
}

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

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

