$(document).ready(function(){
	//-- AJAX ---------------------------
		$('form').submit(function(){
			$.ajax({
				url: "sendMail.php",
				dataType: "script",
				data: $("form").serialize(),
				type: "POST",
			})
		return false;
		});
//-----------------------------------

		$("#body").css("display", "none");	
		$('body > img').animate({
			width: "1500px",
			opacity: 0.0
		},{
			duration: 4000,
			easing: "linear",
			complete: function(){
				//Inhalt anzeigen
				$("#body").show("slow");
				//Start Presentation ausblenden
				$('body > img').css("display", "none");
				
				//Slideshow Starten
				$('.slideshow').cycle({ 
					fx: 'fade, zoom, shuffle, scrollRight, scrollDown', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
					prev:   '#zurueck',
			    	next:   '#weiter',
			    	timeout: 10000
				});
				//Steurung Programmierung
				$("#pause").click(function(e) { 
				    
					if($(this).css("background-position") == "0px 0px"){
						$(this).css("background-position", "-44px 0px");
						$('.slideshow').cycle('pause');
					} else {
						$(this).css("background-position", "0px 0px");
						$('.slideshow').cycle('resume');
					}
				});
				// ab hier kommen alle Menu einträge 
				//----------------------------
				$(".kontakt").click(function(){
					$('#haendler, #event').each(function(i){
						if ($(this).css("display") == "block") {
							$(this).slideToggle("slow");
						}
					});
					$('#kontakt').slideToggle("slow");
				});
				$(".event").click(function(){
					$('#kontakt, #haendler').each(function(i){
						if ($(this).css("display") == "block") {
							$(this).slideToggle("slow");
						}
					});
					$('#event').slideToggle("slow");
				});
				$(".haendler").click(function(){
					$('#kontakt, #event').each(function(i){
						if ($(this).css("display") == "block") {
							$(this).slideToggle("slow");
						}
					});
					$('#haendler').slideToggle("slow");
				});
				//------------------------------------
				$("#body").hover(
					function(){
						$(".menu_oben").slideDown("slow");
						$(".menu_unten").slideDown("slow");
						clearTimeout(interval); // Damit wird verhindert das sich das Menu wieder schliesst
					},
					function(){	
						var kontakt = $("#kontakt").css("display");
						var haendler = $("#haendler").css("display");
						var event = $("#event").css("display");
						var timeout = "";
						//Schlissen nur wenn keine menu offen ist
						if(kontakt != "block" & haendler != "block" & event != "block"){
							//geschlossen wird erst nach einem Sekunde
							interval = setInterval(function(){
								$(".menu_oben").slideUp("slow");
								$(".menu_unten").slideUp("slow");
								clearTimeout(interval);//Timeout löschen (Muss nur ein mal durchgeführt werden) 
							}, 1000);
								
						}
								
					}
				);
			}
		});
	//um das Landen der Webseite zu schonen
	interval2= stInterval(function(){
		$(".slideshow").append('');
		clearTimeout(interval2);
	}, 1000);
	}); 
