$(document).ready(function(){

	var menuLeft;
	var anzSichtbar;
	var leftPosition;
	var leftPositionPx;
	var infoText;
	var menuAktiv = true;

	// Prüfen ob imgBox, textBox, downloadBox vorhanden
	if ($("div.main div.content div.contentRight").html().length <= 32) { // KEINE Boxen vorhanden
		$("div.main div.content div.contentLeft").css({'width' : '720px'});
		$("div.main div.content div.contentRight").css({'width' : '0px', 'marginLeft' : '0px'});
		// 2 Spalten anpassen
		$("div.main div.content div.contentLeft div.spalteR").css({'width' : '550px'});
	}
	else { // Boxen vorhanden
		$("div.main div.content div.contentLeft").css({'width' : '540px'});		
		$("div.main div.content div.contentRight").css({'width' : '170px', 'marginLeft' : '12px'});
		// 2 Spalten anpassen
		$("div.main div.content div.contentLeft div.spalteR").css({'width' : '370px'});
	}
	
	// Aktiver Ordner
	var aktOrdnerID = $("div.navigation ul.lev_1 li.lev_1_act").attr("ID");
	if (aktOrdnerID != undefined) {
		$("div.navigation ul.lev_1 li.lev_1_act").css({'paddingTop' : '10px'});
	}

	// Aktive Seite (Subnavi)
	var aktSubnaviID = $("div.navigation ul.lev_1 li.lev_1_act").children("ul").attr("ID");
	if (aktSubnaviID != undefined) {
		menuLeft = $("div.navigation ul.lev_1 li.lev_1_act");
		leftPosition = menuLeft.position();
		leftPositionPx = (leftPosition.left + 10) + 'px';
		$("div.navigation ul.lev_1 ul#" + aktSubnaviID).css({ 'left' : leftPositionPx });
		$("div.navigation ul.lev_1 ul#" + aktSubnaviID).css({ 'display' : 'block' });
		$("div.navigation ul.lev_1 ul#" + aktSubnaviID).fadeTo(0, 1.00);
	}
	
	// Navigation
	var config = {sensitivity: 3, interval: 130, over: mausOver, timeout: 110, out: mausOut};

	$("div.navigation ul.lev_1 li.lev_1").hoverIntent(config);

	function mausOver() {
		menuAktiv = true;
		menuLeft = $("div.navigation ul.lev_1 li#" + $(this).attr("ID"));
		leftPosition = menuLeft.position();
		leftPositionPx = (leftPosition.left + 10) + 'px';
		$("ul#" + $(this).children("ul").attr("ID")).css({ 'left' : leftPositionPx });
		$("ul#" + $(this).children("ul").attr("ID")).css({ 'display' : 'block' });
		$("div.navigation ul.lev_1 ul#" + aktSubnaviID).fadeTo(150, 0.00);
		$("div.navigation ul.lev_1 li#" + $(this).attr("ID")).animate({paddingTop: "10px"},150);
		$("ul#" + $(this).children("ul").attr("ID")).fadeTo(150, 1.00);
	}

	function mausOut() {
		menuAktiv = false;	
		$(this).delay(1000, function(){
			if (menuAktiv == false) {$("div.navigation ul.lev_1 ul#" + aktSubnaviID).fadeTo(150, 1.00);}				
		});
		$("div.navigation ul.lev_1 li#" + $(this).attr("ID")).animate({paddingTop: "4px"},150);
		$("ul#" + $(this).children("ul").attr("ID")).fadeTo(150, 0.00);			
	}

	$("div.zeigLogin").click(function () {
		$("div.zeigLogin").css("display", "none");
		$("div.login").slideDown(500); 
	});

	$("input.closeButton").click(function () {
		$("div.login").slideUp(500); 
		$("div.zeigLogin").css("display", "inline");
		$("div.errorMsg").css("display", "none");
	});
	
	$("div#loginBenutzername input").focus(function () {
		if ($(this).attr("value") == "Benutzername") {$(this).attr("value", "");}
	});

	$("div#loginBenutzername input").blur(function () {
		if ($(this).attr("value") == "") {$(this).attr("value", "Benutzername");}
	});

	$("div#loginPasswort input").focus(function () {
		if ($(this).attr("value") == "Passwort") {$(this).attr("value", "");}
	});

	$("div#loginPasswort input").blur(function () {
		if ($(this).attr("value") == "") {$(this).attr("value", "Passwort");}
	});

	$("form.suche input.suchEingabe").focus(function () {
		if ($(this).attr("value") == "Suche") {$(this).attr("value", "");}
	});

	$("form.suche input.suchEingabe").blur(function () {
		if ($(this).attr("value") == "") {$(this).attr("value", "Suche");}
	});

	// Kontaktformular
	$("input.kontaktformText").focus(function () {
		$(this).css("border", "1px solid #2e99e1");
		$(this).css("color", "#2e99e1");
	});

	$("input.kontaktformText").blur(function () {
		$(this).css("border", "1px solid #A1A1A1");
		$(this).css("color", "#A1A1A1");
	});

	$("textarea.kontaktformTextarea").focus(function () {
		$(this).css("border", "1px solid #2e99e1");
		$(this).css("color", "#2e99e1");
	});

	$("textarea.kontaktformTextarea").blur(function () {
		$(this).css("border", "1px solid #A1A1A1");
		$(this).css("color", "#A1A1A1");		
	});

	$("select.kontaktformSelect").focus(function () {
		$(this).css("border", "1px solid #2e99e1");
		$(this).css("color", "#2e99e1");
	});

	$("select.kontaktformSelect").blur(function () {
		$(this).css("border", "1px solid #A1A1A1");
		$(this).css("color", "#A1A1A1");		
	});


	// Newsletter
	$("input.fld_input").focus(function () {
		if ($(this).attr("value") == "Newsletter") {
			$(this).attr("value", "");
		}
		$("div.option").fadeTo(350, 1.00);	
		$("input[name='el_flgSumbit']").attr("value","0");
		$("p#el_msg").remove();
		$("div.kurse img").css("visibility", "hidden");		
	});

	$("input.fld_input").blur(function () {
		if ($(this).attr("value") == "") {
			$(this).attr("value", "Newsletter");
			$("div.option").fadeTo(350, 0.00);			
			$("input[name='el_flgSumbit']").attr("value","1");
			$("div.kurse img").css("visibility", "visible");
		}
	});

});
