var browsername;
browsername = navigator.appName;
// alert(browsername);

////////////////////////////////////////////////////
// START Werte verschiedener Inputs etc. anpassen //
////////////////////////////////////////////////////
function changeMiscValues()
{
	var searchInput = cssQuery("#topsearch > form#search-theme-form > div > div#search > div.form-item > input.form-text");
	searchInput = searchInput[0];
	searchInput.value = "Ihr Suchbegriff";
	searchInput.onfocus = function() { this.value = ""; };

	var usernameInput = cssQuery("div#mainRight > div.block-user > div.content > form#user-login-form > div > div.form-item > input#edit-name");
	usernameInput = usernameInput[0];
	if(usernameInput)
	{
		usernameInput.value = "Benutzername";
		usernameInput.onfocus = function() { this.value = ""; };
	}

	var userpassInput = cssQuery("div#mainRight > div.block-user > div.content > form#user-login-form > div > div.form-item > input#edit-pass");
	userpassInput = userpassInput[0];
	if(userpassInput)
	{
		userpassInput.value = "Passwort";
		userpassInput.onfocus = function() { this.value = ""; };
	}
	
	var registerText = cssQuery("div#mainRight > div.block-user > div.content > form#user-login-form > div > div.item-list > ul > li");
	registerText = registerText[0];
	if(registerText)
	{
		// registerTextPre = unescape("Registrierten Usern stehen zahlreiche Zusatzfunktionen zur Verf%FCgung. ");
	}

	var registerLink = cssQuery("div#mainRight > div.block-user > div.content > form#user-login-form > div > div.item-list > ul > li > a");
	registerLink = registerLink[0];
	if(registerLink)
	{
		registerLinkOldValue = registerLink.firstChild.nodeValue;
		// registerLinkNewValue = registerTextPre + "Das will ich auch!";
		// registerLink.firstChild.nodeValue = registerLinkNewValue;
	}	
}
///////////////////////////////////////////////////
// ENDE Werte verschiedener Inputs etc. anpassen //
///////////////////////////////////////////////////



///////////////////////////////////////
// START topnav_right gffs. anzeigen //
///////////////////////////////////////
function fix_topnav() {
	var topnav = document.getElementById("topnav");
	var topnav_left = document.getElementById("topnav_left");
	var topnav_right = document.getElementById("topnav_right");
	topnav_W = topnav.offsetWidth;
	topnav_H = topnav.offsetHeight;
	topnav_left_W = topnav_left.offsetWidth;
	topnav_space = topnav_W - topnav_left_W;
	if(topnav_space > 0)
	{
		topnav_right.style.width = topnav_space + "px";
		topnav_right.style.height = topnav_H + "px";
		topnav_right.style.display = "block";
	}
	else
	{
		topnav_right.style.display = "none";
	}
}
//////////////////////////////////////
// ENDE topnav_right gffs. anzeigen //
//////////////////////////////////////



////////////////////////////////////////
// Start Fensterbreite etc. bestimmen //
////////////////////////////////////////
var x,y;
function getViewport()
{
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
}
///////////////////////////////////////
// Ende Fensterbreite etc. bestimmen //
///////////////////////////////////////



///////////////////////////////////////////////////
// START Content-Divs auf gleiche Höhe zu setzen //
///////////////////////////////////////////////////
function numSort(a, b)
{
	return a - b;
}

function equalColumns()
{
	var col1 = document.getElementById("mainLeft");
	var col2 = document.getElementById("mainRight");
	// var col3 = document.getElementById("col3");

	col1H = col1.offsetHeight;
	col2H = col2.offsetHeight;
	// col3H = col3.offsetHeight;

	var divHeights = new Array(col1H, col2H);
	divHeights.sort(numSort);		// kleinster / mittlerer / großer Wert
	divHeights.reverse();			// Array umkehren
	maxDivHeight = divHeights[0];
	
	// Alle Content-Divs auf die gleiche Höhe setzen
	col1.style.height = maxDivHeight + "px";
	col2.style.height = maxDivHeight + "px";
	// col3.style.height = maxDivHeight + "px";
}
//////////////////////////////////////////////////
// ENDE Content-Divs auf gleiche Höhe zu setzen //
//////////////////////////////////////////////////



//////////////////////////////////////////////
// mainContent-Div Höhe an Vieport anpassen //
//////////////////////////////////////////////
function resizeMainContent()
{
	getViewport();
	// Definition der verwendeten Divs
	var page_margins_container = document.getElementById("page_margins_container");
	var page_margins = document.getElementById("page_margins");
	var page = document.getElementById("page");
	var main = document.getElementById("main");
	var main_left = document.getElementById("mainLeft");
	var main_right = document.getElementById("mainRight");
	var footer = document.getElementById("footer");
	
	page_margins_container_Height = page_margins_container.offsetHeight;
	page_margins_Height	= page_margins.offsetHeight;
	page_Height	= page.offsetHeight;

	if(page_margins_container_Height < y)
	{
		// Wrapper-Divs auf Viewport-Höhe setzen
		page_margins_container.style.height = y - 1 + "px";
		page_margins.style.height = y - 1 + "px";
		page.style.height = y - 16 + "px";
		// Innere Divs auf max. Höhe setzen
		if(browsername == "Microsoft Internet Explorer")
		{
			ausgleich = "22";
		}
		else
		{
			ausgleich = "9";
		}
		main_left.style.height = y - main.offsetTop - footer.offsetHeight - ausgleich + "px";
		main_right.style.height = y - main.offsetTop - footer.offsetHeight - ausgleich + "px";
}
	else
	{
		return 0;
	}
}
///////////////////////////////////////////////////
// Ende mainContent-Div Höhe an Vieport anpassen //
///////////////////////////////////////////////////



function searchNow()
{
	var searchForm = document.getElementById("search-theme-form");
	searchForm.submit();
}
