// JavaScript Document

if ((browser.isIE5x || browser.isIE4x) && location.pathname+location.search != "/index.php?id=1477") {
	location.href = "/index.php?id=1477";
}

var suchfeldtext = "Suchbegriff eingeben";
var maxNewsHHeight = 0;
var maxNewsPHeight = 0;

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
}

$(document).ready(function(){
	$("#suchfeld").val(suchfeldtext);
	$("#suchfeld").focusin(function() {
			if ($(this).val()==suchfeldtext)
				$(this).val("");													
	});
	
	$("#suchfeld").focusout(function() {
			if ($(this).val()=="" || $(this).val()==suchfeldtext)
				$(this).val(suchfeldtext);
	});
	
	// HeaderNews Container-Height Update 
	
	$(".news-latest-item").each(function() {
		if ($(this).find("h1").height() > maxNewsHHeight)
			maxNewsHHeight = $(this).find("h1").height();
		if ($(this).find("p").height() > maxNewsPHeight)
			maxNewsPHeight = $(this).find("p").height();
	});

	$(".news-latest-item").each(function() {
		$(this).find("h1").height(maxNewsHHeight);
		$(this).find("p").height(maxNewsPHeight);
	});
	
	$("#nl-anmeldung").submit(function() {
		if ($("#nl-email").val().length < 1) {
			$("#nl-email").addClass("error");
			$("#nl-email-error").html("Bitte Emailadresse eingeben");
			return false;
		} else {			
			if (!isValidEmailAddress($("#nl-email").val())) {				
				$("#nl-email").addClass("error");
				$("#nl-email-error").html("Bitte gültige Emailadresse eingeben");
				return false;
			} else {
				$("#nl-email").removeClass("error");
				$("#nl-email-error").html("");
				return true;
			}
		}
	});
	
});

