/*
BT_FRAMEWORK
(C) 2010
Version alpha 1
Uses jQuery 1.4.2
*/

$(document).ready(function(){		
		
		/*
		Dropdownnavigation, zwei Ebenen, Mouseover.
		Zur benutzung wird eine einfache Liste mit "UL->LI" erstellt. Diese bekommt den Stil ".bt_framework_navigation_mouseover"
		Weitere Formatierungen folgen dann Ÿber CSS...
		*/
		
		$(".bt_framework_navigation_mouseover").css("list-style-type", "none");
		$(".bt_framework_navigation_mouseover>li>ul").css("display", "none");
		
		var toppoint=$(".bt_framework_navigation_mouseover>li");
		toppoint.css("float", "left");
		toppoint.css("position", "relative");
		toppoint.css("list-style-type", "none");
		toppoint.css("cursor", "pointer");
		
		
		var subpoint=$(".bt_framework_navigation_mouseover>li>ul");
		subpoint.css("position", "absolute");
		subpoint.css("left", "0px");
		subpoint.css("white-space", "nowrap");
		subpoint.css("list-style-type", "none");
		
		$(".letzter").css("left", "-134px");
		
					
		$(".bt_framework_navigation_mouseover>li").mouseover(function(event){
			$(".bt_framework_navigation_mouseover>li>ul").hide();
			$(this).find("ul").show();
			
			$(this).find("ul").css("padding-top", 220-$(this).find("ul").height()+"px");
			$(this).find("img:first").attr("src", $(this).find("img:first").attr("src").replace("_i.", "_a."));
		});
		
		//$(".bt_framework_navigation_mouseover>li>ul").mouseout(function(event){
			//$(".bt_framework_navigation_mouseover>li>ul").hide();
			//$(this).find("img:first").attr("src", $(this).find("img:first").attr("src").replace("_a.", "_i."));
		//});
		$(".bt_framework_navigation_mouseover>li").mouseout(function(event){
			$(".bt_framework_navigation_mouseover>li>ul").hide();			
			$(this).find("img:first").attr("src", $(this).find("img:first").attr("src").replace("_a.", "_i."));
			setzeaktuellenav();
		});
		
		/*
		Akkordeon mit Slide-Effekt
		ACHTUNG! ANGEPASSTE VERSION FÜR GOLFCLUB-AUKRUG! ERSTER OFFEN UND BILDERWECHSEL!
		Weitere Formatierungen folgen dann Ÿber CSS...
		*/
		
		letztershow_akkordeon=$(".bt_framework_akkordeon_slide>div:first");		
		$(".bt_framework_akkordeon_slide>div>h2").click(function(event){
			var eigenesrc=$(this).find("img:first").attr("src");
			
			
			if($(this).parent().find("div").is(":hidden")) {
				if(letztershow_akkordeon!="none"){
					var letztesrc=letztershow_akkordeon.find("img:first").attr("src");
					var letzteneuesrc=letztesrc.replace("_a.png", "_i.png");
					letztershow_akkordeon.find("img:first").attr("src", letzteneuesrc);
					letztershow_akkordeon.find("div").slideUp("slow")
					
				};
				var neuesrc=eigenesrc.replace("_i.png", "_a.png");
				$(this).find("img:first").attr("src", neuesrc);
				$(this).parent().find("div").slideDown("slow");
			}
			else{
				var neuesrc=eigenesrc.replace("_a.png", "_i.png");
				$(this).find("img:first").attr("src", neuesrc);
				$(this).find("div").slideUp("slow");
			}
			letztershow_akkordeon=$(this).parent();
		});		
		$(".bt_framework_akkordeon_slide>div>div").hide();
		$(".bt_framework_akkordeon_slide>div>div").hide();
		$(".bt_framework_akkordeon_slide>div>div:first").show();
		$(".bt_framework_akkordeon_slide>div>div").css("border", "solid 1px transparent");
		
		
		/*
		Einfacher Mouseover
		*/
		

		$(".bt_framework_mouseover").mouseover(function(event){
			$(this).attr("src", $(this).attr("src").replace("_i.", "_a."));
		});
		$(".bt_framework_mouseover").mouseout(function(event){
			$(this).attr("src", $(this).attr("src").replace("_a.", "_i."));
		});
		
		/*
		Inhaltsverzeichnis
		*/
		
		// bt_framework_inhalt
		var allefliesstexth2=$("#fliesstext").find("h2");
		var zaehler=0;
		jQuery.each(allefliesstexth2, function() {
			//console.log("key", key, "value", value);
			//alert($(this).html());
			zaehler+=1;
			$(this).append('<a name="inhaltsanker'+zaehler+'"></a>');
			$('.bt_framework_inhalt').append('<li><a href="#inhaltsanker'+zaehler+'">'+$(this).html()+'</a></li>');
		});
		
		/*
		Linke Seite anpassen
		*/

		//$('#bg_links').css('height', $('#hauptrahmen').height()+0+"px");
		
		
		/* Lightbox */
		
		$(function() {
			// Use this example, or...
			//$('a[@rel*=lightbox]').lightBox(); // Select all links that contains lightbox in the attribute rel
			// This, or...
			//$('#gallery a').lightBox(); // Select all links in object with gallery ID
			// This, or...
			$('a.lightbox').lightBox(); // Select all links with lightbox class
			// This, or...
			//$('a').lightBox(); // Select all links in the page
			// ... The possibility are many. Use your creative or choose one in the examples above
		});
		
		
		/* Schrift in Imputs rein, raus */
		
		$('.suchfeldinhalt').click(function(event){
			$(this).attr("value", "");
		});		
		
		/* Sitebarhoehe */
		
		if($('.sidebar').height()>$('#fliesstext').height()) {
			$('#fliesstext').css("height", $('.sidebar').height()+"px");
		}
		
		//alert($('.sidebar').height());
		
});

