/* * * * * * * * * * * * * * * * * * * * * * *
 *   C A R E N Z A  S C R I P T  F I L E     *
 *                                           *
 *   (c) Copyright 2008 - CARENZA            *
 *   http://www.carenza.nl/                  *
 *                                           *
 * * * * * * * * * * * * * * * * * * * * * * */

window.onload = function () {
	
	var submenu = document.getElementById("submenu");
	
	if(links = document.getElementById("menu").getElementsByTagName("a")) {
		loc1 = location.href.lastIndexOf("/");
		loc2 = location.href.lastIndexOf("/",loc1-1);
		foldername = location.href.substring(loc2 + 1, loc1);
		filename = location.href.substring(loc1 + 1);
		if (loc1+1 == location.href.length) {
				links[0].className = "active";
		} else for ( var i = 0; i < links.length; i++) {
			//if ( i == 0) alert(links[i].href.length+' '+links[i].href.lastIndexOf("/"));
			//if ( i == 0 && links[i].href.lastIndexOf("/") == links[i].href.length - 2) { links[i].className = "active"; }
			//if (links[i].href.substring(links[i].href.lastIndexOf("/"),links[i].href.lastIndexOf("/",links[i].href.lastIndexOf("/")-1)+1) == foldername) {
			if (links[i].href.substring(links[i].href.lastIndexOf("/")+1) == filename) {
				links[i].className = "active"; break;
			}
		}
	}
	if(submenu) {
		links2 = submenu.getElementsByTagName("a");
		for (var i=0; i<links2.length; i++) {
			if (links2[i].href.substring(links2[i].href.lastIndexOf("/")+1) == filename) {
				links2[i].className = "active";
			}
		}
	}

        var menu = document.getElementById("menu").getElementsByTagName("ul");
        
        menu[0].onmouseover = function () {
        	var a = document.getElementById("menu").getElementsByTagName("a");
        	for (var i=0; i<a.length; i++) { if(a[i].className == "active") { a[i].className="activ"; } }
        }
        menu[0].onmouseout = function () {
        	var a = document.getElementById("menu").getElementsByTagName("a");
        	for (var i=0; i<a.length; i++) { if(a[i].className == "activ") { a[i].className="active"; } }
        }
}
