
// Determine browser.
var isMinNS4 = document.layers;
var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1;
var dom=document.getElementById&&!ie;

// Browser Detection
isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
safari = ((navigator.appVersion.indexOf("Safari")!=-1)) ? true : false;
safari2 = ((navigator.appVersion.indexOf(" 419.3")!=-1)) ? true : false;

//alert(navigator.appVersion);

var activeMenuBlockNum;

var activeMenuBlockNum;

topNavs = new Array("Biografie", "Werk", "Pr&auml;senz", "Publikationen", "Aktuell", "Kontakt");
topNav = "Biografie";
	
navObj = new Object();
navObj["Biografie"] = new Array("Timeline", "Lebenslauf");
navObj["Werk"] = new Array("Malerei", "andere Medien");
navObj["Pr&auml;senz"] = new Array("Ausstellungen", "Sammlungen", "Kunst am Bau");
navObj["Publikationen"] = new Array("Literatur", "Kataloge", "Filme", "Illustrationen");
navObj["Aktuell"] = new Array("Ausstellung", "Auktionen", "Verk&auml;uflich");
navObj["Kontakt"] = new Array("Mail", "Impressum");
	
function startNav(nav) {
	
	var html = "";
	
	var pathParts = currentNav.split("/");
	var depth = pathParts.length -1 ;
	
	var pathToTop = "";
	for (var i=0; i<depth; i++) {
		pathToTop += "../";
	}
	var primaryPath = pathParts[0];
	var secondaryPath = pathParts[1];
	
	//html += topNav + "<br>";
	//html += secondaryPath;
	/*
	var html = currentNav + "<br>";
	html += "depth: " + depth + "<br>";
	html += "pathToTop: " + pathToTop + "<br>";
	html += "primaryPath: " + primaryPath + "<br>";
	html += "secondaryPath: " + secondaryPath + "<br>";
	html += "window.location: " + window.location + "<br>";
	*/
	
	var specialLinks = new Object();
	specialLinks["Lebenslauf"] = pathToTop + "biografie/bio/Lebenslauf_HFalk.pdf";
	specialLinks["Mail"] = "mailto:info@hansfalk.ch";
	
	// logo
	var img = "<a href='/index.php'><img src='" + pathToTop + "images/falk_logo.gif' border='0' alt='hans falk logo'></a>";
	document.getElementById("logo").innerHTML = img;
	
	activeMenuBlockNum = -1;
	for (var i=0; i<topNavs.length; i++) {
		var topNav = topNavs[i];
		var style = "style='height: 24px;'";
		html += "<div class='menuBlock' " + style + " id='menuBlock_" + i + "' onMouseOver='flipMenu(this);' onMouseOut='flipMenu();'>";
				html += "<div id='menuTitle_" + i + "' class='menuTitle'><span style='font-weight: bold; color: black; padding: 0px; margin-right: 8px; visibility: visible'>|</span>"+topNav+"</div>";

		
		if (simplify(topNav) == primaryPath) {
			var style = "style='visibility: visible'";
			activeMenuBlockNum = i;
		} else {
			var style = "style='visibility: hidden'";
		}
		//var style = "";
		html += "<div id='menuBlockLowerPart_" + i + "' class='menuBlockLowerPart' " + style + ">" 
		for (var j=0; j<navObj[topNav].length; j++) {
			var navText = navObj[topNav][j];
			//html += secondaryPath;
			var style = "";
			var mousies = "";
			if (simplify(navText) == secondaryPath) {
				var style = "style='background-color: #f63'";
			} else {
				var mousies = "onMouseOver='changeMyBackgroundColor(this, \"#f63\");' onMouseOut='changeMyBackgroundColor(this, \"#444444\");'"
			}
			html += "    <div id='menuItem_"+ i + "_" + j + "' class='menuItem' " + style + " " + mousies + ">";
			if (specialLinks[navText] != null) {
				//html += "yes";
				html += "<a href='" + specialLinks[navText] + "' style='color: #fff' target='_blank' onFocus='this.blur();'>" + navText+ "</a>";
			} else {
				//html += "no";
				//html += "'menuItem_"+ i + "_" + j + "'";
				html += "<a href='" + pathToTop + simplify(topNav) + "/" + simplify(navText) + ".php' style='color: #fff' onFocus='this.blur();'>" + navText+ "</a>";
			}
			html += "</div>\n";
		}
		html +="</div>";
		
		html +="</div>";
	}
	html += "<span style='font-weight: bold; color: black; padding: 0px; margin-right: 8px'>|</span>";
	document.getElementById("menu").innerHTML = html;
	flipMenu(document.getElementById("menuBlock_" + activeMenuBlockNum));
}

function simplify(s) {
	s = s.toLowerCase();
	s = s.replace(/&auml;/g, "ae");
	s = s.replace(/&ouml;/g, "oe");
	s = s.replace(/&uuml;/g, "ue");
	s = s.replace(/ /g, "_");
	return s;
}

function flipMenu(menuBlockDiv) {
	//alert(menuBlockDiv.id);
	var out = "";
	var menuBlockNum = -1;
	if (menuBlockDiv != null) {
		menuBlockNum = menuBlockDiv.id.split("_")[1];
	}
	var divs = document.getElementsByTagName("DIV");
	for (var i=0; i<divs.length; i++) {
		var div = divs[i];
		if (div.id.indexOf("menuBlock_") > -1) {
			var divNum = div.id.split("_")[1];
			if (divNum == menuBlockNum) {
				div.style.backgroundColor = "#444444";
				div.style.zIndex = 20;
			} else {
				if (divNum != activeMenuBlockNum) {
					div.style.height = 14;
					div.style.backgroundColor = "#737373";
				}
			}
		}
		if (div.id.indexOf("menuBlockLowerPart_") > -1) {
			//out += div.id + "\n";
			var divNum = div.id.split("_")[1];
			if (divNum == menuBlockNum) {
				div.style.visibility = "visible";
				div.style.zIndex = 20;
				var menutItemDivs = div.getElementsByTagName("DIV");
				for (var j=0; j<menutItemDivs.length; j++) {
					menutItemDivs[j].style.zIndex = 20;
				}
			} else {
				if (divNum != activeMenuBlockNum) {
					div.style.visibility = "hidden";
				}
			}
			//out += div.id + "\n";
		}
			
		if (div.id.indexOf("menuTitle_") > -1 && safari && !safari2) {
			div.style.zIndex = 21;
			div.style.visibility = "block";
			div.style.height = 14;
		}
	
	}

	//menuBlockDiv.style.backgroundColor = "#ffcc00";
	if (menuBlockDiv != null) {
	    var menuItemCount = 0;
		var divs = menuBlockDiv.getElementsByTagName("DIV");
		for (var i=0; i<divs.length; i++) {
			if (divs[i].id.indexOf("menuItem_") > -1) {
				divs[i].style.visibility = "visible";
				divs[i].style.display = "block";
				menuItemCount++;
			}
			if (divs[i].id.indexOf("menuBlockLowerPart_") > -1) {
				divs[i].style.visibility = "visible";
			}
		}
		//alert(menuItemCount);
		var newMenuBlockHeight = 14 + menuItemCount * 14
		if (!ie) {
			newMenuBlockHeight += 4;
		} else if (IEmac) {
			//newMenuBlockHeight -= 4;
		}
		menuBlockDiv.style.height = newMenuBlockHeight; //"auto";
		menuBlockDiv.style.minHeight = 16;
	}

	//alert(out);
}

function changeMyBackgroundColor(div, color) {
	//alert(color);
	div.style.backgroundColor = color;
}

// ---------------------------------- Werk, Bio ---------------------------------- //

function pop(cat, imageNum) {
	openPopup("../../bilder/werk/bilder/imagepop.php?cat="+cat+"&imagenum="+imageNum);
}

function openPopup(winpath) {
	var newWin = window.open(winpath, "newwin", "dependent=yes,location=no,width=595,innerWidth=595,height=539,innerHeight=539,left=100,top=100,menubar=no,location=no,status=no,scrollbars=no");
	newWin.innerWidth = 595;
	newWin.innerHeight = 539;
	newWin.focus();
}


// ---------------------------------- Werk, Bio (Ende) ---------------------------------- //
