$(document).ready(function(){
	jQuery.fx.off = false;
	
	// slideshow
	//$(".cycles").cycle({fx: 'fade'});
	/*
	// carousel
	$("#carousel").infiniteCarousel({
		transitionSpeed: 2000,
		displayTime: 4000,
		imgWidth: 128,
		imgHeight: 122
	});
                        
    // bind date picker
    $('.date').datepick();
    
    // init smoothAnchors
    $.smoothAnchors(1000, "easeInOut", false);
    
    // inputfill
    $(".inputfill").focus(function(){
        if ($(this).val() == $(this).attr("alt")) $(this).val("");
    }).blur(function(){
        if ($(this).val() == '') $(this).val($(this).attr("alt"));
    });
	
	//ajax	
	$("#ajax-content").load("aktuelle-angebote.php #aktuelle-angebote");
	*/
	
	// contact form
	$(".close-message").click(function(event){
		$(this).parent().parent().slideUp();
		event.preventDefault();
	});
		
	// shadowbox
	Shadowbox.init();
	
	//$("#close-message").click(function(event){$("#fehlermeldung").fadeOut(); event.preventDefault(); });
    
    // noSpam
    noSpam();
});

function form_validation(form){
	var errors_occured = 0;
	$(form).find("label.required").each(function(){
		if (
				// regular text inputs
				$(this).next().val() == '' ||
				// email address inputs
				$(this).hasClass("mail") && !$(this).next().val().match(/^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]+$/) ||
				// numeric inputs
				$(this).hasClass("number") && isNaN(parseInt($(this).next().val())) ||
				// name inputs
				$(this).hasClass("name") && $(this).next().val() == 'Vor- und Nachname' ||
				// textarea inputs
				$(this).hasClass("message") && $(this).next().val() == 'Ihre Nachricht'
		) {
			$(this).addClass("error");
			$(this).next().addClass("error");
			errors_occured = 1;
		}
		else {
			$(this).removeClass("error");
			$(this).next().removeClass("error");
		}
	});
	if (errors_occured === 0) {
		return true;
	}
	else {
		$("#fehlermeldung").slideDown(function(){
			window.location.href = "#fehlermeldung";
		});
		//$("#fehlermeldung").fadeIn();
		return false;
	}
}
