
function checkMandatories(formular){
		var fehler=false;
		$(formular).find(".mandatory").each(function(i){
			if($(this).attr("type")=="checkbox"){
				if($(this).attr("checked")== false && $(this).attr("disabled")==false){
					fehler=true;
					try {
						$(this).next().animate( { backgroundColor:"#3d434a", color:"#ffffff" }, { queue:true, duration:250 } );
						$(this).next().animate( { backgroundColor:"#ac0a26", color:"#ffffff" }, { queue:true, duration:250 } );
						$(this).next().animate( { backgroundColor:"#3d434a", color:"#ffffff" }, { queue:true, duration:250 } );
						$(this).next().animate( { backgroundColor:"#ac0a26", color:"#ffffff" }, { queue:true, duration:300 } );
					} catch(e){}
					show_hinweis("Bitte überprüfen Sie die Pflichtfelder.");
				} else {
					try {	
						$(this).next().animate( { backgroundColor:"#3d434a", color:"#ffffff" }, { queue:true, duration:250 } );
					} catch(e){}
				}
			} else {
				if($(this).val()=="" && $(this).attr("disabled")==false){
					fehler=true;
					try{
						$(this).animate( { backgroundColor:"#3d434a", color:"#ffffff" }, { queue:true, duration:250 } );
						$(this).animate( { backgroundColor:"#ac0a26", color:"#ffffff" }, { queue:true, duration:250 } );
						$(this).animate( { backgroundColor:"#3d434a", color:"#ffffff" }, { queue:true, duration:250 } );
						$(this).animate( { backgroundColor:"#ac0a26", color:"#ffffff" }, { queue:true, duration:300 } );
					} catch(e){}
					show_hinweis("Bitte überprüfen Sie die Pflichtfelder.");
				} else {
					try{
						$(this).animate( { backgroundColor:"#3d434a", color:"#ffffff" }, { queue:true, duration:500 } );
					} catch(e){}
				}
			}
		});
		return fehler;
}
function calcPaddingMenue(){
		var sum=0;
		var count=$(".box_main_navi_inner").children("a").size();
		$(".box_main_navi_inner").children().each(function(i){
			sum+=$(this).width();
		});
		
		var padding = $(".box_main_navi_inner").width() - sum;
		padding /= count * 2;
		padding = Math.floor(padding);
		
		var padding_first_left = ($(".box_main_navi_inner").width() - sum - (padding * (count-1) * 2)) / 2;
		var padding_first_right = ($(".box_main_navi_inner").width() - sum - (padding * (count-1) * 2) - padding_first_left);
		$(".box_main_navi_inner").children("a").css("padding-left",Math.ceil(padding));
		$(".box_main_navi_inner").children("a").css("padding-right",Math.ceil(padding));
		$(".box_main_navi_inner").children("a:first").css("padding-left",Math.ceil(padding_first_left));
		$(".box_main_navi_inner").children("a:first").css("padding-right",Math.ceil(padding_first_right));
}
$(document).ready(function() {
	$(".box_main_left_imagecontainer_item a.iframe").fancybox({
		'zoomSpeedIn'	:	300, 
		'zoomSpeedOut'	:	300,
		'overlayShow'	:	true, 
		'overlayOpacity': 	.5,
		'padding'		: 	3,
		'centerOnScroll':   false,
		'hideOnContentClick': false,
		'frameWidth' 	: 	1090,
		'frameHeight' 	: 	670		
	});
	
		$("#newsletter_anmeldung").submit(function(){
		
			var fehler=checkMandatories(this);

			if(!fehler){
			 
			 var inhalte = $(this).find("input, textarea").serialize();
			 $.ajax({
			   type: "POST",
			   url: "/lib/js_functions.php",
			   async: false,
			   data: "function=addNewsletterUser&"+inhalte,
			   success: function(data_str){
			   	 var data = eval('('+data_str+')');
			   	 if(data.hinweis != "")show_hinweis(data.hinweis);
			   	 if(data.fehler != "")show_hinweis(data.fehler);
			   	 if(!data.fehler) $(".form_newsletter_input").find("input, textarea").val("");
			   	 //else $("#kontaktformular").find("input, textarea").val("");
			   }
			 });	
	
			}
			return false;
	});	
	
		if($("#hinweis_text").text() != "")show_hinweis($("#hinweis_text").html());
		calcPaddingMenue();
});


function hinweis_aus() {
  document.getElementById("hinweis").style.visibility = "hidden";
}

function show_hinweis(hinweis){
	$("#hinweis_text").html(hinweis);
	document.getElementById("hinweis").style.visibility = "visible";
}
