
// global definitions
var lastShownMenu = "knoepferl";

// array with all available body images (order is important!)
var aBodyImgs = new Array();
aBodyImgs[0] = "Hans.jpg";
aBodyImgs[1] = "Sissi.jpg";
aBodyImgs[2] = "Weintraube1.jpg";
aBodyImgs[3] = "Weintraube2.jpg";
aBodyImgs[4] = "Weintraube3.jpg";
aBodyImgs[5] = "Weingarten1.jpg";
aBodyImgs[6] = "Weingarten2.jpg";
aBodyImgs[7] = "Weingarten3.jpg";
aBodyImgs[8] = "Weingarten4.jpg";

// association between show menu items and body images
var aMenuBodyImgs = new Array();
aMenuBodyImgs["knoepferl"] = 3;
aMenuBodyImgs["ueber_uns"] = 0;
aMenuBodyImgs["geschichte"] = 1;
aMenuBodyImgs["weine"] = 4;
aMenuBodyImgs["anreise"] = 8;
aMenuBodyImgs["links"] = 5;
aMenuBodyImgs["kontakt"] = 6;
aMenuBodyImgs["impressum"] = 2;

function loadBodyImage(i) {
	// var i = Math.round(Math.random() * 10);
	i = Math.min(i, 8)
	i = Math.max(i, 0)
	
	document.getElementById("bodyimg").src = "img/banner/" + aBodyImgs[i];
	document.getElementById("bodyimg").alt = aBodyImgs[i];
	document.getElementById("bodyimg").title = aBodyImgs[i].substr(0, aBodyImgs[i].length - 4);
}

// shows the menu and reloads a new body image
// @param	id, the menu id
// @param	i, body image number
function showMenu(id) {
	// check if available!
	loadBodyImage(aMenuBodyImgs[id]);
	
	if (lastShownMenu != "") {
		document.getElementById(lastShownMenu).style.display = "none";
	}
	document.getElementById(id).style.display = "block";
	lastShownMenu = id;
}

// function outline
function outLine(id) {
	if (document.getElementById(id).style.display == "none") {
		document.getElementById(id).style.display = "block";
	} else {
		document.getElementById(id).style.display = "none";
	}
}

// function outline by arrow image button
function outLineByArrow(id) {
	var info = "info_" + id;
	var arrow = "pfeil_" + id;
	
	if (document.getElementById(info).style.display == "none") {
		document.getElementById(info).style.display = "block";
		
		document.getElementById(arrow).src = "img/pfeil_rauf.gif";
		document.getElementById(arrow).alt = "^";
		document.getElementById(arrow).title = "hide";
	} else {
		document.getElementById(info).style.display = "none";
		
		document.getElementById(arrow).src = "img/pfeil_runter.gif";
		document.getElementById(arrow).alt = "v";
		document.getElementById(arrow).title = "show";
	}
}

// simple function to change the image on hovering
function changeArrow(id, hovering) {
	if (hovering) {
		document.getElementById(id).src = document.getElementById(id).src.replace(/\.gif/, "_hover.gif")
	} else {
		document.getElementById(id).src = document.getElementById(id).src.replace(/_hover\.gif/, ".gif")
	}
}

// das Falstaff Fenster
function Falstaff() {
  Neu = window.open("","Neu","width=265,height=382");
  Neu.document.writeln("<html><head><title>Falstaff Pr&auml;mierung</title>");
  Neu.document.writeln("</head><body leftmargin='0' topmargin='0'>");
  Neu.document.writeln("<img alt='Falstaff' src='img/Falstaff.jpg' height='378' width='260'>");
  Neu.document.writeln("</body></html>");
  Neu.document.close();
  Neu.focus();
}

// get the cookie
function getCookie() {
	var wert = "";
	if (document.cookie) {
		var start = document.cookie.indexOf("=") + 1; 	// zaehler wert
		var ende = document.cookie.indexOf(";");    	// nach der zahl
		if (ende == -1) ende = document.cookie.length;
		wert = document.cookie.substring(start, ende);
	}
	return wert;
}

// set a cookie
function setCookie(wert) {
	var ablauf = new Date();
	ablauf.setTime((ablauf.getTime()+(365*24*60*60*1000)));
	document.cookie = "zaehler="+wert+"; expires="+ablauf.toGMTString();
}

// last modified on ...
function modified() {
	var a = new Date(document.lastModified);
	var lm_year = a.getYear();
	lm_year = ((lm_year < 1000) ? ((lm_year < 70) ? 2000 : 1900) : 0) + lm_year;
	var lm_month = a.getMonth() + 1;
	lm_month = ((lm_month < 10) ? '0' : '') + lm_month;
	var lm_day = a.getDate();
	lm_day = ((lm_day < 10) ? '0' : '') + lm_day;
	document.writeln(lm_year+'-'+lm_month+'-'+lm_day);
}

