$(document).ready(function(){
			setPropsBG();
			$('#anreise').datepicker({monthNames: ['Januar','Februar','M&auml;rz','April','Mai','Juni','Juli','August','September','Oktober','November','December'], dateFormat : 'dd/mm/yy'});
			$('#abreise').datepicker({monthNames: ['Januar','Februar','M&auml;rz','April','Mai','Juni','Juli','August','September','Oktober','November','December'], dateFormat : 'dd/mm/yy'});
			$('.tip').delay(10000).fadeOut(10000);
			$('.mediaplayer .close_player').click(function(){
				$('.mediaplayer').slideUp(5000);
				$('.mediaplayer .bg_player').fadeOut(1000);
				
			});
			
			/*$('.main_container').hover(function(){
				$(this).stop().animate({ "opacity": 1});
			}, function(){
				$(this).stop().animate({ "opacity": .7});
			});*/
			
			$('.img_show').click(function(){
			$('.header .slideshow').fadeOut();
			$('body').css({"background-image" : "url('"+this.src+"')"}).animate({"opacity": 0, "background-position" : "-200px"},5000).delay(5000).animate({"opacity" : 1},function(){$('body').css({"background-position" : "0px"})});
			$(".stretch").attr("src",this.src);
			if (($(this).attr("width") / $(this).attr("height")) > ($(window).width() / $(window).height())) {$('#background img').removeClass('stretch1').addClass('stretch2')} else {$('#background img').removeClass('stretch2').addClass('stretch1')};
			});
					
		setInterval('gallery()',5000);
		
		});
		
		function setPropsBG() {
		if (($('#background img').attr("width") / $('#background img').attr("height")) > ($(window).width() / $(window).height())) {$('#background img').removeClass('stretch1').addClass('stretch2')} else {$('#background img').removeClass('stretch2').addClass('stretch1')};
		}
/*		function gallery() {
		
			var current = ($('.slideshow a.show')? $('.slideshow a.show') : $('.slideshow a:first'));
			var next	= ((current.next().length) ? ((current.next().hasClass('nav_main'))? $('.slideshow a:first') :current.next()) : $('#gallery a:first'));
			next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0},1000);
			current.animate({opacity: 0.0},1000).removeClass('show');
		}
*/
		function gallery () {
		var $active = $('.main_container .header .slideshow a.show');
		 if ( $active.length == 0 ) $active = $('.main_container .header .slideshow a:last');
		var $next = $active.next().length ? $active.next() : $('.main_container .header .slideshow a:first');    
		$next.css({opacity : 0.0}).addClass('show').animate({opacity : 1.0}, 1000, function(){
			$active.removeClass('show');
		});
		}

	function sendForm(){
		var name = $('input#name').val(); 
		var email = $('input#email').val(); 
		var anreise = $('input#anreise').val(); 
		var abreise = $('input#abreise').val();
		//var dataString = 'name='+ name + '&email=' + email + '&anreise=' + anreise + '&abreise=' + abreise + '&wohnung=';
		var dataString = '';
		$('input:checkbox').each(function() {
		if ($(this).is(':checked') == true) {dataString = dataString + '1'} else {dataString = dataString + '0'} ;
		});
		var nachricht = $('textarea#feedback').val();
		if (name == '' || email == '' || anreise == '' || abreise == '') { $('.box .require').show("slow"); return false };
		 $.post("fileadmin/template/php/gateway.php", { name: name, email: email, anreise: anreise, abreise: abreise, 
wohnung: dataString, nachricht: nachricht } );
		$("#messageSent").show("slow");
        setTimeout('$("#messageSent").hide();$(".box").slideUp("slow")', 2000);
		return false;
	}

