whereAreWe = function() {
	var where = window.location.pathname;
	var endPath = where.lastIndexOf("/");
	var whereDir = where.substring(1, endPath);
	whereDirs = whereDir.split("/", 2);
	var fileName = where.substring(endPath+1, where.length);
	return whereDirs;
}

fileData = function() {
	var where = window.location.pathname;
	var endPath = where.lastIndexOf("/");
	var fileName = where.substring(endPath+1, where.length);
	return fileName;
}

subnavSelect = function() {
	var whereDirs = whereAreWe();
	var subDiv = document.getElementById("subnav").getElementsByTagName("A");
	divSub = new Array();
	for (var k = 0; k < subDiv.length; k++) {
		if (subDiv[k].id) {
			divSub.push(subDiv[k].id);
		}
	}
	var thirdDiv = document.getElementById("navsub").getElementsByTagName("UL");
	for (var h = 0; h < divSub.length; h++) {
		if (whereDirs[1] == divSub[h]) {
			var navItem = document.getElementById(divSub[h]);
			var navImg = navItem.firstChild;
			navImg.src = navImg.src.replace("_off", "_on");
			navImg.onmouseover = null;
			navImg.onmouseout = null;
			thirdDiv[h].style.display = "block";
		}
	}
}

thirdSelect = function() {
	var nameFile = fileData();
	var anchorsNames = document.getElementById("navsub").getElementsByTagName("A");
	for (var g = 0; g < anchorsNames.length; g++) {
		var lastPath = anchorsNames[g].href.lastIndexOf("/");
		var anchorRef = anchorsNames[g].href.substring(lastPath+1, anchorsNames[g].href.length);
		if (nameFile == anchorRef) {
			anchorsNames[g].style.color = "#A48E69";
		}
	}
}
	

rollOver = function() {
	var whereDirs = whereAreWe();
	var nameFile = fileData();
	var navDiv = document.getElementById("nav").getElementsByTagName("IMG");
	for (var i = 0; i < navDiv.length; i++) {
		navDiv[i].onmouseover = function() {
				this.src = this.src.replace("_off", "_on");
		}
		navDiv[i].onmouseout = function() {
				this.src = this.src.replace("_on", "_off");
		}
		if (whereDirs[0] != undefined) {
			if (whereDirs[0] == navDiv[i].id) {
				navDiv[i].src = navDiv[i].src.replace("_off", "_on");
				navDiv[i].onmouseover = null;
				navDiv[i].onmouseout = null;
			}
		}
	}
	if (whereDirs[1] != undefined) {
		subnavSelect();
		thirdSelect();
	}
}

window.onload = rollOver;