function checkForm(element) {
	var error = false;
	$(element).find("[required=true]").each(function(i) {
				console.log("tacg");
				if (this.value == '') {
					if (error != true)
						this.focus();
					$(this).addClass('error');
					error = true;
				} else
					$(this).removeClass('error');
			});
	if (error == true) {
		alert("Es wurden nicht alle benötigten Felder ausgefüllt!");
		return false;
	} else {
		return true;
	}
}
function rand (min, max) {
	return Math.floor(Math.random() * (max - min + 1)) + min;
}
$(function() {
		$(".needs_js").css('display', 'block');
		$("body").addClass("script").removeClass("noscript");


		// Bilderrotateur
		rotator_pics_todo = [];
		rotator_lastpic = "";
		
		rotate(); 
		setInterval ( rotate, rotator_config.delay);
		
});

function rotate()
{
		if ( rotator_pics_todo.length == 0 )
		{
			rotator_pics_todo = rotator_pics_todo.concat(rotator_config.pics);
		}
		
		div = document.createElement ( "div" );
		div.style.zIndex = 2;
		div.style.display = 'none';
		img = document.createElement ( "img" );
		
		i = rand(0,rotator_pics_todo.length-1);
		if ( rotator_pics_todo[i] == rotator_lastpic ) 
		{
			i = rand(0,rotator_pics_todo.length-1);
			if ( rotator_pics_todo[i] == rotator_lastpic ) 
			{
				i = rand(0,rotator_pics_todo.length-1);
			}
		}
		img.src = rotator_pics_todo[i];
		rotator_lastpic = rotator_pics_todo[i];
		rotator_pics_todo.splice(i, 1);
		
		img.onload = function ()
			{
				div.appendChild ( img );
				container = $("#"+rotator_config.container_div_id);
				container.find("div").css({zIndex:1 });
				container.append(div);
				$(div).fadeIn( rotator_config.duration_animation, function()
						{
							container.find("div").not(div).fadeOut(rotator_config.duration_animation, function(){
								$(this).remove();
							});
						}
					);
			};
}

