/*
Project: navigation_highlighting.js
Date: 2006-08-22 11:14pm
Autor: Benjamin Schmidt <schmidi2@directbox.com>
Company: Triestram & Partner AG Switzerland
License: GNU GPL
*/

/*
<table border="0" cellpadding="0" cellspacing="0" width="145">

<tbody><tr> 
	<td class="TextNaviLeftRight" background="index_files/LeftTop_orange.gif" height="24" nowrap="nowrap">
		<span class="TextTitleNaviLeftRightBold">&nbsp;::Homepage</span>
	</td>
</tr>
<tr> 
	<td class="navileftOrange" onmouseover="className='navileftOrangeswap';" onmouseout="className='navileftOrange';" height="24">
		<a class="navileftOrange" href="http://www.radiobeo.ch/index.htm">&nbsp;Aktuell</a>
	</td>
</tr>

http://www.radiobeo.ch/wettbewerbe/index.htm
http://www.radiobeo.ch/wettbewerbe/wettbewerbe.htm
*/

navigation_highlighting();



function navigation_highlighting() {
	
	var highlight_class = ""; // = "" important!! Otherwise the class-attr will be empty
	
	
	
	
	//var searchIn_Tag = array("a");
	//var searchIn_Attribute = array("href");
	
	// hhttp://www.radiobeo.ch/index.htm
	var pathname = window.location.pathname;
	if("/" == pathname[0]) { // rem /
		pathname = pathname.substring(1);
	}
	
	// rm
	var pathnamebegin_exclude = "radiobeo/";
	var url_ignore = Array("../", "./");
	if(0 == pathname.indexOf(pathnamebegin_exclude)) {
		pathname = pathname.substr(pathnamebegin_exclude.length);
	}
	
	
	var highlight_byKeyword = pathname;  // -i
	highlight_byKeyword = highlight_byKeyword.toLowerCase();
	
	
	if("" == highlight_byKeyword) {
		return;
	}
	
	
	if(-1 != highlight_byKeyword.indexOf("programm/")) {
		highlight_class = "navileftBlueswap";
	} else
	if(-1 != highlight_byKeyword.indexOf("beoservice/")) {
//		highlight_class = "navileftBlueswap";
		highlight_class = "navirightswap";
	} else
	if(-1 != highlight_byKeyword.indexOf("about/")) {
		highlight_class = "navileftswap";
	} else
	if(-1 != highlight_byKeyword.indexOf("foerderverein/")) {
		highlight_class = "navileftswap";
	} else
	if(-1 != highlight_byKeyword.indexOf("sendegebiet/")) {
		highlight_class = "navileftGreenswap";
	} else
	if(-1 != highlight_byKeyword.indexOf("redaktion/")) {
		highlight_class = "navileftPurpleswap";
	} else
	if(-1 != highlight_byKeyword.indexOf("werbung/")) {
		highlight_class = "navileftRedswap";
	} else
	if(-1 != highlight_byKeyword.indexOf("team/")) {
		highlight_class = "navileftYellowswap";
	}
	
//	alert(highlight_byKeyword);
//	alert(highlight_class);
	
	
	var tags_a = document.getElementsByTagName("a");
	for(i=0; i<tags_a.length; i++) {
		tag_a = tags_a[i];
		tag_a_href = tag_a.getAttribute("href");
		if(tag_a_href==undefined) {
			continue;	// empty href
		}
		tag_a_href = tag_a_href.toLowerCase(); // -i
		
		if( -1 != tag_a_href.indexOf(highlight_byKeyword) ) {
			// Found keyword!

			// must not have a img-element inside!!
			if("img" == tag_a.firstChild.nodeName.toLowerCase())
				continue;

			if("td" == tag_a.parentNode.tagName.toLowerCase()) { // -i
				tag_a.parentNode.className += " "+ highlight_class;
				tag_a.parentNode.setAttribute("onmouseover", "");
				tag_a.parentNode.setAttribute("onmouseout", "");
			}
		}
	}

}	// End function: navigation_highlighting

