// jQuery Ready-Handler
$(function() {

	// Fly in content with jFlow
	$("#nav").jFlow({
		slides: "#jFlowContent",
		controller: ".jFlowControl", // must be class, use . sign
		slideWrapper : "#jFlowSlide", // must be id, use # sign
		selectedWrapper: "jFlowSelected",  // just pure text, no sign
		width: "100%",
		height: "370px",
		duration: 400,
		jlink: ".jFlowLink"
	});
	
	// Hover-States of Navigation
	$("#nav li").hover(
		function(event){
			if(!$(this).hasClass("jFlowSelected"))
			{
				$(this).children(".name").css("background", "transparent url(public/images/icon_arrow_nav.gif) center left no-repeat");
				$(this).children(".desc").animate({color: "#bdcd00"}, "normal");
			}
		},
		function(event){
			if(!$(this).hasClass("jFlowSelected"))
			{
				$(this).children(".name").removeAttr("style");
				$(this).children(".desc").animate({
					color: "#ec7218"},
					function(){$(this).removeAttr("style");
				});
			} else {
				$(this).children(".desc").removeAttr("style");
				$(this).children(".name").removeAttr("style");
			}
		}
	);
	
	
	// track page change with urchinTracker
	$("li.jFlowControl").click(function(){
		
		var site = $(this).attr("id");
		
		// console.log(site);
		
		pageTracker._trackPageview("/" + site);
		
	});
	
	// Initialise jScrollPane
	// $('.jFlowContent div').jScrollPane();
	
	// Hide Reasons
	$(".reason").hide();

	// SlideToggle for Reason-List
	$("a.show_reason").click(function(event){  

		event.preventDefault();
		
		var target = $($(this).attr("href"));
		
		if(target.is(":hidden"))
		{
			
			$(".reason").slideUp();
			$(".show_reason").slideDown();
			
			$(this).slideUp();						// Hides link "(mehr erfahren...)" if target was closed
			target.slideToggle("slow");				// Shows target
			
		} else {
			
			// Hides target and display link "(mehr erfahren...)" again
			target.slideToggle("slow", function(){
				
				$(this).prev().children(".show_reason").slideDown();

			});
			
		}

	
	});
	
	// Hide Sidebar and extend Content
	// 22.03.09: Runs into conflicts with jFlow, which would have to be somehow reinitialised -> V2
	$("#more_room").click(function(event){
		
		event.preventDefault;
		
		$("#column-two-inner-inner").css("margin", "0px");
		$("#column-three").hide();
		$(".inner_content").css("width", "700px");
		$(".jFlowSlideContainer").css("width", "700px");
				
	});
	

});