function initializeSubmenue() {
	// Submenues einblenden bei mouseenter
	var mainNavLI = $('#navigation ul li');
	mainNavLI.children('ul').css('display', 'none');
	mainNavLI.mouseenter(function() { $(this).children('ul').slideDown('fast'); });//css('display', 'block'); });
	mainNavLI.mouseleave(function() { $(this).children('ul').slideUp('fast'); })// css('display', 'none'); });
	
	// Submenues positionieren
	var websiteWidth = $('#website').width();
	var headerWidth = $('#header').outerWidth(true);
	$('#navigation ul:has(ul)').css('position', 'relative');
	var mainNavWithSubNav = $('#navigation ul li:has(ul)')
	mainNavWithSubNav.css('position', 'static');
	mainNavWithSubNav.each(function() {
		var position = $(this).position();
		var width		 = websiteWidth - position.left;
		// IE6 Box-Model-Hack...
		if ($.browser.msie && $.browser.version.substr(0,1) < 7) { width += position.left }
		$(this).children('ul').css({
			'padding-left': position.left,
			'width': width
		});
	});
}

function initForms() {
	var bodyClass = $('body').attr('class');
	$('form select').not('.submit-bg select').wrap('<div class="submit-bg"></div>');
	$('form .submit-bg select').not('form .submit-bg .submit-bg-text + select').each(function() {
		var children = $(this).children();
		if (children.length > 0) {
			var selectedChild = 0;
			for (var i=0; i<children.length; i++) {
				if (children[i].selected) {
					selectedChild = i;
				}
			}
			$(this).parent().prepend('<span class="submit-bg-text">'+$(children[selectedChild]).text()+'</span>');
			$(this).css('opacity', '0');
			
			// onChange-Event registrieren
			$(this).change(function() {
				$(this).prev().text($(this).children('option[selected]').text());
			});
		}
	});

	// Formular-Input-Texte onfocus austauschen
	$('#teaser input[type=text]').attr('rel', $('input[type=text]').attr('value'));
	$('#teaser input[type=text]').focus(function(){ if ($(this).attr('value') == $(this).attr('rel')) $(this).attr('value', ''); })
	/*$('input[type=text]').blur(function() { if ($(this).attr('value') == '') $(this).attr('value', $(this).attr('rel')); })*/
	
	// Border um input-Felder bei focus
	var formSelector = 'input,textarea';
	$(formSelector).focus(function() { $(this).css('border-color', $('h1').css('color')); });
	$(formSelector).blur(function()  { $(this).css('border-color', '#3D3D3D'); });
	
	// Login-Formular-Submitbutton anpassen
	$('.tx-felogin-pi1 input[type=submit]').addClass('submit');
}

$(document).ready(function() {
	// invert-Klassen durchgehen und Inhaltsfarben umdrehen
	$('.invert').each(function() {
		var color = $(this).css('color');
		var backgroundColor = $(this).css('background-color');
		$(this).css({
			backgroundColor: color,
			borderColor: backgroundColor,
			color: backgroundColor
		});
	});
	
	// Submenue initialisieren
	initializeSubmenue();
	
	// Formular-Hintergruende ersetzen
	initForms();
});
