jQuery(function( $ ){
	/**
	 * Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://flesler.demos.com/jquery/scrollTo/
	 * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
	 */	var target = $('#content').get(0);//the scrolled div
	
	
	
	// The default axis is 'y', but in this demo, I want to scroll both
	// You can modify any default like this
	$.localScroll.defaults.axis = 'xy';
	
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: '#content', // Could be a selector or a jQuery object too.
		queue:true,
		duration:1500
	});
	var $last = $([]);//save the last link
	
	/**
	 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
	 * also affect the >> and << links. I want every link in the page to scroll.
	 */
	$.localScroll({
		target: '#content', // could be a selector or a jQuery object too.
		queue:true,
		duration:1000,
		hash:true,
		onBefore:function( e, anchor, $target ){
			// The 'this' is the settings object, can be modified
		},
		onAfter:function( anchor, settings ){
			// The 'this' contains the scrolled element (#content)
		}
	});
	$("ul.navigation").show();
	$(".menu_head").show();
			

	/**
	 * NAVIGATION STUFF
	 * 
	 */
	$("h1 a").click(
		function(){
			$("#home_nav").siblings().removeClass("active");
			$("#home_nav").addClass("active");
			$("#home_nav").siblings().children().animate({ opacity: 0.7, marginTop: "2px"}, 100 );
			$("#home_nav a").animate({ opacity: 1, marginTop: "0px"}, 100 );
		}
	);
	
	
	$("#footer ul li a").css({ opacity: 0.7 });
	//$("#footer ul li:first").addClass("active").children().css({ opacity: 1, marginTop: "0px"});

	$("#footer ul li").click(
		function(){
			$(this).addClass("active");
			$(this).siblings().removeClass("active");
			$(this).siblings().children().animate({ opacity: 0.7, marginTop: "2px"}, 100 );
		}
	);
	$("#footer ul li").click(
		function(){
			if($(this).hasClass("showroom")){
				$("p.fullsize_link").animate({ height: "2"}, 140 );
			}else{
				$("p.fullsize_link").animate({ height: "0px"}, 140 );
			}
		}
	);
	$("#footer ul li").click(
		function(){
			if($(this).hasClass("videoroom")){
				$("p.fullsize_link").animate({ height: "2"}, 140 );
			}else{
				$("p.fullsize_link").animate({ height: "0px"}, 140 );
			}
		}
	);

	$("#footer ul li a").hover(
		function(){
			if($(this).parent().hasClass("active")){
				
			}else{
				$(this).animate({ opacity: 1, marginTop: "0px"}, 100 );
			}
		},
		function(){
			if($(this).parent().hasClass("active")){
			}else{
				$(this).animate({ opacity: 0.7, marginTop: "2px"}, 100 );
			}
		}

	);
	
	$("#footer ul li a").click(
		function(){
			$("ul.navigation li").siblings().removeClass("active");
			$("ul.navigation li a").addClass("active");
			$("ul.navigation li").siblings().children().animate({ opacity: 0.7}, 100 );
			$("ul.navigation li a").animate({ opacity: 1}, 100 );
			$("#firstpane p.menu_head").siblings().children().animate({ opacity: 0.7}, 100 );
			$("#firstpane p.menu_head").siblings("div.menu_body").slideUp("slow");
		}
	);

	
	
	
	
	//Target examples bindings
			var $paneTarget = $('.section');	
			
			$('#profil_nav').click(function(){
						$("#overlay_showroom").hide();
						$("#overlay_videoroom").hide();
			});
			
			$('h1 a').click(function(){
						$("#overlay_showroom").hide();
						$("#overlay_videoroom").hide();
			});

			$('#sponsoren_nav').click(function(){
						$("#overlay_showroom").hide();
						$("#overlay_videoroom").hide();
			});
			
			$('#termine_nav').click(function(){
						$("#overlay_showroom").hide();
			});
			
			$('#bilder_nav').click(function(){
						$("#overlay_showroom").show();
						$("#overlay_videoroom").hide();
			});
			$('#videos_nav').click(function(){
						$("#overlay_videoroom").show();
						$("#overlay_showroom").hide();
			});
			
			$('#links_nav').click(function(){
						$("#overlay_showroom").hide();
			});
			
			$('#kontakt_jochen_nav').click(function(){
						$("#overlay_showroom").hide();
						$("#overlay_videoroom").hide();
			});
			
			$('#footer ul li a').click(function(){
						$("#overlay_showroom").hide();
						$("#overlay_videoroom").hide();
			});

			
			
//var myVideosrc = 'video_pimp.swf';
	
	//$('#videoroom').flash(
	//{ src: myVideosrc,
	//width: 746,
	//height: 580,
	//wmode: 'transparent',
	//allowfullscreen: 'true'}, 
	//{ update: false }
	//);		




var myGallerysrc = 'gallery.swf';
	
	$('#showroom').flash(
	{ src: myGallerysrc,
	width: 746,
	height: 580,
	wmode: 'transparent',
	allowfullscreen: 'true'}, 
	{ update: false }
	);
	
	var mysrc = 'flash/schnee.swf';
	$('div#header h1').after('<div id="schnee"></div>');
	$('div#header h1').after('<div id="schnee_active"></div>');
	
	$('#schnee').flash(
	{ src: mysrc,
	width: 200,
	height: 150,
	wmode: 'transparent'}, 
	{ update: false }
	);
	
	$("#schnee").css({ left: "-180px", width: "160px", top:"100px", height:"60px"});
	
	$("h1 a").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top:"100px", height:"60px"});
			$("#firstpane p.menu_head:first").addClass("active").children().css({ opacity: 1});
			$(this).siblings("div.menu_body").removeClass("active");
			$(this).siblings().children().animate({ opacity: 0.7});
			/*$("ul.navigation li").siblings().removeClass("active");
			$("ul.navigation li").addClass("active");
			$("ul.navigation li").siblings().children().animate({ opacity: 0.5, marginTop: "8px"}, 100 );
			$("ul.navigation li a").animate({ opacity: 1, marginTop: "6px"}, 100 );
			$("home").siblings().removeClass("active");
			$("home").addClass("active");
			$("home").siblings().children().animate({ opacity: 0.5, marginTop: "8px"}, 100 );
			$("home a").animate({ opacity: 1, marginTop: "6px"}, 100 );*/

		}
	);
	
	
	$("#konzept_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top:"100px", height:"65px"});
		}
	);
	
	$("#partner_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top:"135px", height:"65px"});
		}
	);
	$("#guides_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top: "175px", height:"400px" });
		}
	);
	$("#sponsoren_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top:"125px", height:"65px"});
		}
	);
	$("#projekte_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top: "165px", height:"65px" });
		}
	);
	$("#leistungen_inhalte_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top: "270px", height:"200px"  });
		}
	);
	$("#bilder_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top: "200px", height:"65px"  });
		}
	);
	$("#aktionen_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top: "200px" , height:"400px" });
		}
	);
	$("#videos_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top: "230px" , height:"65px" });
		}
	);
		$("#locations_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top: "235px", height:"400px"  });
		}
	);
		$("#kontakt_jochen_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top: "260px", height:"65px"  });
		}
	);
		$("#termine_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top: "290px", height:"65px"   });
		}
	);
		$("#anmelden_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top: "320px", height:"65px" });
		}
	);
		$("#links_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top: "355px", height:"65px" });
		}
	);
		$("#kontakt_nav").click(
		function(){
			$("#schnee").css({ left: "-180px", width: "160px", top: "385px" , height:"65px" });
		}
	);

	$("#agb_nav").click(
		function(){
			$("#schnee").css({ left: "560px", width: "80px" , top: "725px", height:"65px"});
		}
	);
	$("#impressum_nav").click(
		function(){
			$("#schnee").css({ left: "620px", width: "140px" , top: "725px", height:"65px"});
		}
	);
	




	 $("#overlay_projekte div").css({ opacity: 0 });
	 $("#overlay_projekte h3 a").click(
		function(){
			$(this).addClass("projekte_active");
			$(this).parent().siblings("h3").children("a").removeClass("projekte_active");
			$(this).parent().siblings("div").animate({ opacity: 0}, 100 );
			$(this).parent().next("div").animate({ opacity: 0.7}, 400 );
			return false;
		}
	);
	 
	
});


 // Global flags
var sdbIntervalID = 0;
var awardsIntervalID = 0;
var _loading = false;
var _historyInit = false;
var _fromTransition = false;
var _pageloadXHR = null;
var _domain = "root";
$.easing.def = "easeInOutQuint";
