if (top != self) top.location.href=self.location.href;

if (self.location.host.indexOf("waechter"))
{
	baseElem = document.getElementsByTagName("base");
	if (baseElem.length > 0)
	{
		baseElem = baseElem[0];
		self.location.href = baseElem.href;	
	}
}

var chapterNavi = null;
var subChapterNavi = null;
var newNavi = null; 
var anchorHideNavi = null; 
var naviSeparator = null;


var chapterTitle = "Kapitelnavigation";
var subChapterTitle = "Unterkapitelnavigation";

var chapTitles = 
{	
	"/IRL":      "Irland-Themen", 
	"/Links":    "Link-Themen",
	"/Kochbuch": "Kategorien",
	"/Spass":    "mehr Spaßiges",
	"/Fahrrad":  "Fahrrad-Touren",
	"/GB/ENG":   "England-Themen",
	"/GB/IOM":   "Man-Themen",
	"/GB/SCO":   "Schottland-Themen",
	"/GB/WAL":   "Wales-Themen",
	"/GB":       "Großbritannien-Themen" 
}

var subchapTitles = 
{
	"/Tour":                   "Etappen",
	"/Bilder":                 "Bilder-Übersichten",
	"/Whiskey":                "Whiskey-Sorten",
	"/Provinzen":              "Provinzen",
	"/Kochbuch/Auflaeufe":     "Aufläufe",
	"/Kochbuch/Beilagen":      "Beilagen",
	"/Kochbuch/Dips":          "Dips",
	"/Kochbuch/Getraenke":     "Getränke",
	"/Kochbuch/Hauptgerichte": "Hauptgerichte",
	"/Kochbuch/Kuchen":        "Kuchen",
	"/Kochbuch/Marmeladen":    "Marmeladen",
	"/Kochbuch/Nachspeisen":   "Nachspeisen",
	"/Kochbuch/Nudelsossen":   "Nudelsoßen",
	"/Kochbuch/Platzerln":     "Platzerln",
	"/Kochbuch/Salate":        "Salate",
	"/Kochbuch/Salzgebaeck":   "Salzgebäck",
	"/Kochbuch/Suessspeisen":  "Süßspeisen",
	"/Kochbuch/Suppen":        "Suppen",
	"/Kochbuch/Vorspeisen":    "Vorspeisen"
}

function setMyCookie()
{
	var ablauf = new Date();
	ablauf.setTime(ablauf.getTime() + (30 * 24 * 60 * 60 * 1000)); //ca. 30 Tage (kommt auf die Stunde nicht an bei Sommerzeit)
	document.cookie = "menueausblenden=nein; expires=" + ablauf.toGMTString() + "; path=/";
}

function deleteMyCookie()
{
	var ablauf = new Date();
	ablauf.setTime(ablauf.getTime() - 3600); //läuft in Vergangenheit ab ==> gelöscht
	document.cookie = "menueausblenden=; expires=" + ablauf.toGMTString() + "; path=/";
}

function readMyCookie() 
{
	var retvalue = true;
	if (document.cookie.length > 0)
	{
		var parts = document.cookie.split(/=/);

		if ((parts[0] == "menueausblenden") && (parts[1] == "nein"))
		{
			retvalue = false;

			setMyCookie();  //refresh the Cookie
		}
	}
	return retvalue; //false if cookie says: don't hide menu, true otherwise
}

function getNavigations()
{
	chapterNavi = document.getElementById('Kapitelnavigation');
	if (! chapterNavi)
	{
		chapterNavi = document.getElementById('Abschnittsnavigation');
		if (! chapterNavi)
			return;
	}			

	subChapterNavi = document.getElementById('Unterkapitelnavigation');
	naviSeparator = document.getElementById('TrennerNavigation');
}

function getNaviTitles()
{
	var path = self.location.pathname;

	for (chap in chapTitles)
	{
		if (path.indexOf(chap) == 0)
		{
			chapterTitle = chapTitles[chap];
			break;
		}
	}

	for (subchap in subchapTitles)
	{
		if (path.indexOf(subchap) != -1)
		{
			subChapterTitle = subchapTitles[subchap];
			break;
		}
	}
}

function createAdditionalNaviElement()
{
	var mainElem = document.getElementById("all");
	if (! mainElem)
		return null;

	newNavi = document.createElement("div");
	mainElem.insertBefore(newNavi, mainElem.firstChild);

	newNavi.className = "Navigation";
	newNavi.style.paddingBottom = "0.5em"; 
	newNavi.style.display = "none";
}

function createChapterLink(theParentElem)
{
	var anchorElem = document.createElement("a");
	theParentElem.appendChild(anchorElem);

	var textNode = document.createTextNode(chapterTitle);
	anchorElem.appendChild(textNode);

	var attrNode = document.createAttribute("href");
	attrNode.nodeValue = "#Blende_Navigation_ein";
	anchorElem.setAttributeNode(attrNode);

	// dom doesn't work for event handlers, therefore: 
	anchorElem.onmouseover = showChapterNavi;
	anchorElem.onmouseout = hideChapterNavi;
	anchorElem.onclick = doNothing;
}

function createSubchapterLink(theParentElem)
{
	var anchorElem = document.createElement("a");
	theParentElem.appendChild(anchorElem);

	var textNode = document.createTextNode(subChapterTitle);
	anchorElem.appendChild(textNode);

	var attrNode = document.createAttribute("href");
	attrNode.nodeValue = "#Blende_Unter-Navigation_ein";
	anchorElem.setAttributeNode(attrNode);

	// dom doesn't work for event handlers, therefore: 
	anchorElem.onmouseover = showSubChapterNavi;
	anchorElem.onmouseout = hideSubChapterNavi;
	anchorElem.onclick = doNothing;

}

function createShowLink(theParentElem)
{
	var anchorElem = document.createElement("a");
	theParentElem.appendChild(anchorElem);

	var imgElem = document.createElement("img");
	anchorElem.appendChild(imgElem);

	attrNode = document.createAttribute("alt");
	attrNode.nodeValue = "Navigation immer einblenden";
	imgElem.setAttributeNode(attrNode);

	imgElem.style.verticalAlign = "top";
	imgElem.style.padding = "2px";

	attrNode = document.createAttribute("src");
	attrNode.nodeValue = "/Bilder/Menu/JS/raus.png";
	imgElem.setAttributeNode(attrNode);

	attrNode = document.createAttribute("title");
	attrNode.nodeValue = "Navigation immer einblenden";
	anchorElem.setAttributeNode(attrNode);

	attrNode = document.createAttribute("href");
	attrNode.nodeValue = "#Blende_Navigation_permanent_ein";
	anchorElem.setAttributeNode(attrNode);

	// dom doesn't work for event handlers, therefore: 
	anchorElem.onclick = showTheMenue;

	anchorElem.style.padding = "0px";
	anchorElem.style.lineHeight = "20px";
}

function createHideLink()
{
	var theParentElem = (subChapterNavi)?subChapterNavi:chapterNavi;

	var liElem = document.createElement("li");

	var anchorElem = document.createElement("a");
	liElem.appendChild(anchorElem);

	var imgElem = document.createElement("img");
	anchorElem.appendChild(imgElem);

	attrNode = document.createAttribute("alt");
	attrNode.nodeValue = "Navigation immer einblenden";
	imgElem.setAttributeNode(attrNode);

	imgElem.style.verticalAlign = "top";
	imgElem.style.padding = "2px";

	attrNode = document.createAttribute("src");
	attrNode.nodeValue = "/Bilder/Menu/JS/rein.png";
	imgElem.setAttributeNode(attrNode);

	attrNode = document.createAttribute("title");
	attrNode.nodeValue = "Navigation ausblenden";
	anchorElem.setAttributeNode(attrNode);

	attrNode = document.createAttribute("href");
	attrNode.nodeValue = "#Blende_Navigation_aus";
	anchorElem.setAttributeNode(attrNode);

	// dom doesn't work for event handlers, therefore: 
	anchorElem.onclick = hideTheMenue;

	theParentElem.appendChild(liElem);

	anchorElem.style.padding = "0px";
	anchorElem.style.lineHeight = "20px";

	anchorHideNavi = anchorElem;
}

function createAdditionalElements()
{
	createAdditionalNaviElement();

	createChapterLink(newNavi);
	if (subChapterNavi)
	{
		newNavi.appendChild(document.createTextNode(" "));
		createSubchapterLink(newNavi);
	}
	newNavi.appendChild(document.createTextNode(" "));
	createShowLink(newNavi);

	createHideLink();
}

function hideTheChapterMenue()
{
	chapterNavi.style.display = "none";
	// dom doesn't work for event handlers, therefore: 
	chapterNavi.onmouseover = keepChapterNavi;
	chapterNavi.onmouseout = hideChapterNavi;

	chapterNavi.style.position = "absolute";
	chapterNavi.style.top = "1.6em";
	if (document.all && !window.opera)
		chapterNavi.style.left = "0";
	chapterNavi.style.background = "#FEB";
	chapterNavi.style.border = "2px solid #930";
	chapterNavi.style.padding = "0.3em";
}

function hideTheSubchapterMenue()
{
	subChapterNavi.style.display = "none";
	if (naviSeparator)
		naviSeparator.style.display = "none";

	// dom doesn't work for event handlers, therefore: 
	subChapterNavi.onmouseover = keepSubChapterNavi;
	subChapterNavi.onmouseout = hideSubChapterNavi;

	subChapterNavi.style.position = "absolute";
	subChapterNavi.style.top = "1.6em";
	if (document.all && !window.opera)
		subChapterNavi.style.left = "0";
	subChapterNavi.style.background = "#FEB";
	subChapterNavi.style.border = "2px solid #930";
	subChapterNavi.style.padding = "0.3em";
}

function hideTheMenue()
{
	if (this.href)
		this.blur();
	hideTheChapterMenue();

	if (subChapterNavi)
	{ 
		hideTheSubchapterMenue();
	}
	anchorHideNavi.style.display = "none";

	newNavi.style.display = "block";
	deleteMyCookie();
	return false;
}

function showTheChapterMenue()
{
	// dom doesn't work for event handlers, therefore: 
	chapterNavi.onmouseover = doNothing;
	chapterNavi.onmouseout = doNothing;

	chapterNavi.style.position = "static";
	chapterNavi.style.background = "transparent";
	chapterNavi.style.border = "none";
	chapterNavi.style.padding = "0";

	chapterNavi.style.display = "block";
}

function showTheSubchapterMenue()
{
	// dom doesn't work for event handlers, therefore: 
	subChapterNavi.onmouseover = doNothing;
	subChapterNavi.onmouseout = doNothing;

	subChapterNavi.style.position = "static";
	subChapterNavi.style.background = "transparent";
	subChapterNavi.style.border = "none";
	subChapterNavi.style.padding = "0";

	subChapterNavi.style.display = "block";
	if (naviSeparator)
		naviSeparator.style.display = "block";
}

function showTheMenue()
{
	newNavi.style.display = "none";

	if (this.href)
		this.blur();
	showTheChapterMenue();
	if (subChapterNavi)
		showTheSubchapterMenue();
	anchorHideNavi.style.display = "inline";

	setMyCookie();
	return false; 
}

function myOnload()
{
	if (! document.getElementById) //ignore old browsers
		return;

	var hidemenue = readMyCookie(); //check whether hiding of menue is disabled
	
	getNavigations();

	getNaviTitles();

	if (chapterNavi)
	{
		createAdditionalElements();

		if (hidemenue == true)
		{
			hideTheMenue();
		}
		else
		{
			showTheMenue();
		}
	}
}

/*
		}
*/


function alwaysShowNavi()
{
	setMyCookie();
	document.getElementById("popupnavigation").style.display = "none";

	chapterNavi = document.getElementById('Kapitelnavigation');
	if (! chapterNavi)
	{
		chapterNavi = document.getElementById('Abschnittsnavigation');
		if (! chapterNavi)
			return false;
	}			

	chapterNavi.style.position = "static";
	chapterNavi.style.background = "transparent";
	chapterNavi.style.border = "none";
	chapterNavi.style.display = "block";
	chapterNavi.style.padding = "0";

	// dom doesn't work for event handlers, therefore: 
	chapterNavi.onmouseover = doNothing;
	chapterNavi.onmouseout = doNothing;

	subChapterNavi = document.getElementById('Unterkapitelnavigation');
	if (subChapterNavi)
	{ 
		subChapterNavi.style.display = "block";


		// dom doesn't work for event handlers, therefore: 
		subChapterNavi.onmouseover = doNothing;
		subChapterNavi.onmouseout = doNothing;
	}

	return false;
}

function doNothing()
{
	return false; 
}

window.onload   = myOnload;

var myTimer = null;
var mySubTimer = null;

function showChapterNavi()
{
	if (myTimer)
		window.clearTimeout(myTimer);
	chapterNavi.style.display = "block";
	if (subChapterNavi)
		hideItSub();
//newNavi.style.display = "none";

	return false;
}

function hideChapterNavi()
{
	myTimer = window.setTimeout("hideIt();", 100);
	return false;
}

function hideIt()
{
	myTimer = null;
	chapterNavi.style.display = "none";
//newNavi.style.display = "block";
}

function keepChapterNavi()
{
	if (myTimer != null)
	{
		window.clearTimeout(myTimer);
	}
	return false;
}

function showSubChapterNavi()
{
	if (mySubTimer)
		window.clearTimeout(mySubTimer);

	subChapterNavi.style.display = "block";
	if (chapterNavi)
		hideIt();
//newNavi.style.display = "none";
	return false;
}

function hideSubChapterNavi()
{
	mySubTimer = window.setTimeout("hideItSub();", 100);
	return false;
}

function hideItSub()
{
	mySubTimer = null;
	subChapterNavi.style.display = "none";
//newNavi.style.display = "block";
}

function keepSubChapterNavi()
{
	if (mySubTimer != null)
	{
		window.clearTimeout(mySubTimer);
	}
	return false;
}
