﻿
window.onload = function() {

	preload();
	setActivePage();
	
	var mainbody = document.getElementById("mainbody");
	mainbody.style.minHeight = "100%";
	
}


/**
* Preloads a couple of images.
**/
function preload() {

	var images = new Array();
	images[0] = root+"gfx/navi-left-active.gif";
	images[1] = root+"gfx/navi-middle-active.gif";
	images[2] = root+"gfx/navi-right-active.gif";
	images[3] = root+"gfx/benefits_uncheck.gif";
	
	for (var i = 0; i < images.length; i++) {
		var image = new Image();
		image.src = images[i];
	}

}


/**
* Sets the highlight of the active page in the navigation.
**/
function setActivePage() {
	
	var item = document.getElementById(page);
	if (item) item.firstChild.className = "active";
	
	for (var i=0; i<parents.length; i++) {
		item = document.getElementById(parents[i]);
		if (item) item.firstChild.className = "subactive";
	}
	
}


/**
* Event function of mouse over on the navi.
**/
function onNaviOver(me) {
	if (page != me.id && !isParent(me.id)) me.firstChild.className = "over";
}


/**
* Event function of mouse out on the navi.
**/
function onNaviOut(me) {
	if (page != me.id && !isParent(me.id)) me.firstChild.className = "inactive";
}


/**
* Event function of mouse click on the navi.
**/
function onNaviClick(me) {
	if (page != me.id) link(me.firstChild.firstChild.href, me.firstChild.firstChild.target);
}


/**
* Returns, if the object of the given id is a parent.
*
* @param	id		an id of a sitemap object
* @return	boolean
**/
function isParent(id) {
	for (var i=0; i<parents.length; i++) {
		if (id == parents[i]) return true;
	}
	return false;
}


/**
* Opens a window.
*
* @param	link	the url
* @param	target	the target window
**/
function link(link, target) {
	window.open(link, target);
}


/**
* Returns false.
*
* @return	false
**/
function getFalse() {
	return false;
}


/**
* Event function for the search button.
* Checks, if a word to search for got provided.
*
* @return	boolean
**/
function onSearch() {
	
	var search = document.getElementById("search");
	
	if (search.value == "Suchen ..." || search.value.replace(/ /g, "") == "") {
		search.value = "";
		search.focus();
		return false;
	}
	
	return true;
}


/**
* Event function for the focus event of the search input field.
*
**/
function onSearchFocus() {
	
	var search = document.getElementById("search");
	
	if (search.value == "Suchen ...") search.value = "";	
	
}


/**
* Event function for the blur event of the search input field.
*
**/
function onSearchBlur() {
	
	var search = document.getElementById("search");
	
	if (search.value.replace(/ /g, "") == "") search.value = "Suchen ...";
	
}
