$(document).ready(function(){

	// ======================================================= When document is ready
	$(".listAlternate li:even").css("background-color","#fefedc");
//	$("#pageContent").css({"opacity":"0.0"}).animate({"opacity":"1.0"},1500);

	// =================================================================== Navigation
	$("#navigation li a").wrapInner('<span class="buttonMiddle"></span>');
	$("#navigation li a").prepend('<span class="buttonLeft"></span>');
	$("#navigation li a").append('<span class="buttonRight"></span>');
	$("#navigation li a").hover(
		function(){
			if($(this).parent(this).attr("class") != "active"){
				$(".buttonMiddle",this).animate({width:"+=20px"},250);
			}
		},
		function(){
			if($(this).parent(this).attr("class") != "active"){
				$(".buttonMiddle",this).animate({width:"-=20px"},250);
			}
		}
	)

	// ================================================================ Footer Bubble
	$("#social a").mouseenter(
		function(){
			var vHref = $(this).attr("href");
			var vTitle = $(this).attr("title");
			
			$("#social .bubble").animate({opacity:"0.0"},250).remove();
			$("#social").stop().append('<div class="bubble"><span class="bubbleHorizontalLeft"></span><span class="bubbleHorizontalMiddle"><a href="'+vHref+'" title="'+vTitle+'">'+vTitle+'</a></span><span class="bubbleHorizontalRight"></span></div>');
			$("#social .bubble").css({opacity:"0.0",visibility:"visible"}).animate({opacity:"1.0"},500);
		}
	)
	$("#footer").mouseleave(
		function(){
			$("#social .bubble").animate({opacity:"0.0"},500).remove();
		}
	)
	
	// ========================================================= Action Notifications
	$(".notificationGood,.notificationBad").animate({opacity:"1.0"},8000).animate({opacity:"0.0"},500).animate({height:"hide"},500);
	
	// ========================================================= Formvalidation
	$('#fContact').submit(function(){
		$('.formStar, .notificationBad',this).remove();
		var vValidation = 0;
		var vErrorMessage = '<span class="formStar" style="color:#7a0212;float:left;margin-left:-20px;">*</span>';
		if($('input[name="aName"]').val() != ''){
			vValidation = 1;
		}else{
			$('input[name="aName"]').parent().parent().prepend(vErrorMessage);
			vValidation = 0;
		}
		if($('input[name="aEmail"]').val() != ''){
			vValidation = 1;
		}else{
			$('input[name="aEmail"]').parent().parent().prepend(vErrorMessage);
			vValidation = 0;
		}
		if($('input[name="aSubject"]').val() != ''){
			vValidation = 1;
		}else{
			$('input[name="aSubject"]').parent().parent().prepend(vErrorMessage);
			vValidation = 0;
		}
		if($('textarea[name="aMessage"]').val() != ''){
			vValidation = 1;
		}else{
			$('textarea[name="aMessage"]').parent().parent().prepend(vErrorMessage);
			vValidation = 0;
		}
		if(vValidation == 1){
			return true;
		}
		$(this).prepend('<p class="notificationBad"><strong>Es sind Fehler aufgetreten.</strong> Bitte &uuml;berpr&uuml;fen und korrigieren Sie die mit einem <span style="color:#7a0212;font-size:22px;">*</span> gekennzeichneten Eingabefelder und senden Sie das Formular erneut ab.</p>');
		return false;
	});
	
	var vMessageHeight = $('textarea[name="aMessage"]').height();
	$('textarea[name="aMessage"]').focus(function(){
		$(this).animate({height:vMessageHeight+200+'px'},500);
	});
//	$('textarea[name="aMessage"]').focusout(function(){
//		$(this).animate({height:vMessageHeight+'px'},500);
//	});
});
