/* <![CDATA[ */
$(function(){
	
	initBgImage();
	$('a[rel*=facebox]').facebox();
	
	jQuery('#changebg1').click(function(){
		jQuery('body').css({backgroundImage: "url(http://mooti.de/wp-content/themes/mooti2/images/bgpage.jpg)"})
		$.cookie("bgImage", 1, { expires: 90 });
		});
	jQuery('#changebg2').click(function(){
		jQuery('body').css({backgroundImage: "url(http://mooti.de/wp-content/themes/mooti2/images/bgpage2.jpg)"})
		$.cookie("bgImage", 2, { expires: 90 });
		});
	jQuery('#changebg3').click(function(){
		jQuery('body').css({backgroundImage: "url(http://mooti.de/wp-content/themes/mooti2/images/bgpage3.jpg)"});
		});
	jQuery('#changebg4').click(function(){
		jQuery('body').css({backgroundImage: "url(http://mooti.de/wp-content/themes/mooti2/images/bgpage4.jpg)"});
		});
	jQuery('#changebg5').click(function(){
		jQuery('body').css({backgroundImage: "url(http://mooti.de/wp-content/themes/mooti2/images/bgpage5.jpg)"});
		});
	jQuery('#changebg6').click(function(){
		jQuery('body').css({backgroundImage: "url(http://mooti.de/wp-content/themes/mooti2/images/bgpage6.jpg)"});
		});
		
	var options = { target: '#form_notification', resetForm: true}
	$('#postform').ajaxForm({ beforeSubmit:validate });
	
})

function validate(formData, postform, options){

	var form = postform[0];
	if (!form.name.value || !form.email.value || !form.nachricht.value){
	$('#form_notification').html('Nachricht konnte nicht verschickt werden!').slideDown(200).animate({opacity:1}, 2500).slideUp(200);
	return false;	
	}
	$('#form_notification').html('<img src="http://mooti.de/wp-content/themes/mooti2/images/loader2.gif" alt="" /> Nachricht wird verschickt...')
	.slideDown(200).animate({opacity:1}, 3000, function(){
		$(this).html('Plubb! Nachricht wurde verschickt. Vielen Dank!').animate({opacity:1},3000).slideUp(200);
	});
	
}

function initBgImage(){

	if (!$.cookie("bgImage")) {$('body').css({backgroundImage: "url(http://mooti.de/wp-content/themes/mooti2/images/bgpage.jpg)"});
	} else {
		
	if ($.cookie("bgImage") == 2){
		$('body').css({backgroundImage: "url(http://mooti.de/wp-content/themes/mooti2/images/bgpage2.jpg)"});
	}
		
	if ($.cookie("bgImage") == 3){
		$('body').css({backgroundImage: "url(http://mooti.de/wp-content/themes/mooti2/images/bgpage3.jpg)"});
	}
		
	if ($.cookie("bgImage") == 4){
		$('body').css({backgroundImage: "url(http://mooti.de/wp-content/themes/mooti2/images/bgpage4.jpg)"});
	}
		
	if ($.cookie("bgImage") == 5){
		$('body').css({backgroundImage: "url(http://mooti.de/wp-content/themes/mooti2/images/bgpage5.jpg)"});
	}
		
	if ($.cookie("bgImage") == 6){
		$('body').css({backgroundImage: "url(http://mooti.de/wp-content/themes/mooti2/images/bgpage6.jpg)"});
	}
			
	}
	
}
/* ]]> */
