$(function(){
	var maxAnzahl = $(".imageContainer ul li").length; // muss dringend vor dem Karussel-Aufruf definiert werden da sonst die DOM-Elemente nicht stimmen
    var i = 1; // stellt den "zähler" auf 1
	
	$(".bigImageContainer").jCarouselLite({ // ruft das karussel auf
        btnNext: ".next",
        btnPrev: ".prev",
		speed: 500,
		start: 0,
		visible: 1,
		btnGo: [".0big", ".1big", ".2big", ".3big", ".4big", ".5big", ".6big", ".7big", ".8big", ".9big", ".10big", ".11big", ".12big", ".13big", ".14big", ".15big", ".16big", ".17big", ".18big", ".19big"]
    });
	$(".imageContainer").jCarouselLite({ // ruft das karussel auf
        btnNext: ".next",
        btnPrev: ".prev",
		speed: 500,
		start: 0,
		visible: 1,
		btnGo: [".0big", ".1big", ".2big", ".3big", ".4big", ".5big", ".6big", ".7big", ".8big", ".9big", ".10big", ".11big", ".12big", ".13big", ".14big", ".15big", ".16big", ".17big", ".18big", ".19big"]
    });
	$(".galleryLayer").hide(); // versteckt den Layer
	$(".modalBackground").hide(); // versteckt den Modal
	$(".galleryCounter").text(i+"/"+maxAnzahl);
	$(".next").click(function(){ // inkrementiert den zähler + imagechange
		i++;
		if(i > maxAnzahl){
			i = 1;
		}
		$(".galleryCounter").html(i+"/"+maxAnzahl);
	});
	$(".content_teaser_thumb next").mouseover(function(){
		this.src = "art/b_pfeilrechts_hi.gif";
	}).mouseout(function(){
		this.src = "art/b_pfeilrechts_lo.gif";
	});
	$(".prev").click(function(){ // dekrementiert den zähler + imagechange
		i--;
		if(i == 0){
			i = maxAnzahl;
		}
		$(".galleryCounter").html(i+"/"+maxAnzahl);
	});
	$(".content_teaser_thumb prev").mouseover(function(){
		this.src = "art/b_pfeillinks_hi.gif";
	}).mouseout(function(){
		this.src = "art/b_pfeillinks_lo.gif";
	});
	$(".imageContainer ul li img").click(function(){
		$(".modalBackground").show();
		$(".galleryLayer").css({position: "absolute", left: "270px"});
		$(".galleryLayer").fadeIn(500);
		/*
		$(".bigPager li span").click(function(){ // setzt den aktiven punkt auf "bold"	
			$.each( $(".bigPager li span"), function() {
				$(this).css("font-weight", "normal");
			});
			$(this).css("font-weight", "bold");
		});
		*/
		
	});
	
	$(".closeCross").click(function(){
		$(".galleryLayer, .modalBackground").fadeOut(500);
	});
	
	$(".bigPager li span").click(function(){
		i = parseInt($(this).text());
		$(".galleryCounter").html(i+"/"+maxAnzahl);
	});
});