// JavaScript Document

$(document).ready(function(){

	var doc_height = $(window).height();
	var doc_width = $(window).width();
	$("#galerie").css("height",$(document).height());
	$("#galerie").css("width",$(document).width());
	$("#gkopf").css("width",doc_width);
	$("#gcontent").css("height",(doc_height - 180));
	$("#gcontent").css("width",(doc_width - 350));
	if($(window).width() < 900){$("#gcontent").css("width","600px");}
	if($(window).height() < 600){$("#gcontent").css("height","500px");}
	$("#pane1").width($("#gcontent").width() - 40);
	$("#pane1").height($("#gcontent").height() - 0);
	
	//Colorbox
	/*$(function() {
		var galerien = $("#gcontent_scroll");
		var anzahl_galerien = galerien.length;
		$.each(galerien, function(){
			return $("a", $(this)).colorbox({slideshow:true});
			//transition:"none", width:"75%", height:"75%"/"fade"//slideshow:true
			});
	});*/
	$("a","#gcontent_scroll").colorbox({});
		
$(window).resize(function(){
	//Colorbox
	/*$(function() {
		var galerien = $("#gcontent_scroll");
		var anzahl_galerien = galerien.length;
		$.each(galerien, function(){
			return $("a", $(this)).colorbox({transition:"none", width:"75%", height:"75%"});
			//transition:"none", width:"75%", height:"75%"/"fade"//slideshow:true
			});
	});*/
	$("a","#gcontent_scroll").colorbox({});
	
	
		var doc_height = $(window).height();
		var doc_width = $(window).width();
		$("#galerie").css("width",$(document).width());
		$("#gkopf").css("width",doc_width);
		if(!(doc_height < 600)){
		$("#gcontent").css("height",($(window).height() - 180));
		$("#pane1").css("height",($(window).height() - 180));
		$("#gcontent > .jScrollPaneContainer").css("height",($(window).height() - 180));
		}
		
		if(!(doc_width < 900)){
		$("#gcontent").css("width",($(window).width() - 350));
		$("#pane1").css("width",($(window).width() - 390));
		$("#gcontent > .jScrollPaneContainer").css("width",($(window).width() - 390));
		}	
		
		//Scrollbar
		$('#pane1').jScrollPane(
						{
							showArrows: true, 
							scrollbarWidth: 30,
							bottomCapHeight: 10,
							topCapHeight: 10,
							dragMinHeight: 0,
							dragMaxHeight: 16,
							wheelSpeed : 18,
							arrowSize : 21,
							animateTo : false,
							animateInterval : 100,
							animateStep: 3,
							maintainPosition: true,
							scrollbarOnLeft: false,
							reinitialiseOnImageLoad: false,
							tabIndex : 0,
							enableKeyboardNavigation: true,
							animateToInternalLinks: false,
							observeHash: true
							
						}
					);//End Scrollbar
					
	});
	
	$("a","#foto").click(function(){
		$("#galerie").toggle(500);
		//Scrollbar ##########################
	$('#pane1').jScrollPane(
						{
							showArrows: true, 
							scrollbarWidth: 30,
							bottomCapHeight: 10,
							topCapHeight: 10,
							dragMinHeight: 0,
							dragMaxHeight: 16,
							wheelSpeed : 18,
							arrowSize : 21,
							animateTo : false,
							animateInterval : 100,
							animateStep: 3,
							maintainPosition: true,
							scrollbarOnLeft: false,
							reinitialiseOnImageLoad: false,
							tabIndex : 0,
							enableKeyboardNavigation: true,
							animateToInternalLinks: false,
							observeHash: true
						}
					);
			
	
	//Ende Scrollbar #####################
		});
	
	$("#gkopf").click(function(){
		$("#galerie").css("display","none");
	});
		
	$("li:not(#lkopf):not(#active)","#gmenue").live("mouseover", function(){
		$(this).css({	backgroundImage: "none"
						//backgroundImage: "url(template_images/glist_hover.jpg)",
						//backgroundRepeat: "repeat-x"
						});
		});
	
	$("li:not(#lkopf):not(#active)","#gmenue").live("mouseout", function(){
		$(this).removeAttr("style");
		});
	
	$("li:not(#lkopf)","#gmenue").live("click", function(){
		$("li:not(#lkopf)","#gmenue").removeAttr("id");
		$("li:not(#lkopf)","#gmenue").removeAttr("style");
		$(this).attr("id","active");
		$(this).css({	backgroundImage: "url(template_images/gblue_10x10.png)",
						//backgroundImage: "url(template_images/glist_active.jpg)",
						backgroundRepeat: "repeat"
						});
		});

//########################## AJAX ##########################################################################
//Bildabruf bei start
function bildabruf(auswahl_selektor){
var ordnername = auswahl_selektor.attr("title");
 
	$.post(
	"galerie.php",
	{ordnername: ordnername},
		function(data){
			$("#gcontent_scroll").html(data);
			$("#loading").hide();
			$("a","#gcontent_scroll").colorbox({});
			$('#pane1').jScrollPane(
								{
									showArrows: true, 
									scrollbarWidth: 30,
									bottomCapHeight: 10,
									topCapHeight: 10,
									dragMinHeight: 0,
									dragMaxHeight: 16,
									wheelSpeed : 18,
									arrowSize : 21,
									animateTo : false,
									animateInterval : 100,
									animateStep: 3,
									maintainPosition: true,
									scrollbarOnLeft: false,
									reinitialiseOnImageLoad: false,
									tabIndex : 0,
									enableKeyboardNavigation: true,
									animateToInternalLinks: false,
									observeHash: true
									
								}
			);
		}
	);
}

var first_gbutton = $("li#lkopf","#gmenue").next("li");

bildabruf(first_gbutton);

$(first_gbutton).attr("id","active");

$("li:not(#lkopf)","#gmenue").click(function(){$("#loading").show(); bildabruf($(this));});



});
