$(document).ready(
	function(){
		positionFooter();
		$("li.navBtn").mouseover(	function(){	nav_over(this, this.id);	});
		$("li.navBtn").mouseout(	function(){	nav_out(this, this.id);	});

		$("div#imgScrollBox").jCarouselLite({
			 btnNext: ".next",
			 btnPrev: ".prev",
			 vertical: true,
			 speed: 500,
			 visible: 4,
			 scroll: 4,
			 circular: false
		});
		
		$("img.th").click(	function(){ changeCurImg(this, this.src);	});
		
		if ($('div.oeffnungszeiten').html() != null){
			$('div.oeffnungszeiten').find('div.text').hide();
		}		
		
		if ($("#oeffnungszeiten-toggle") != null){
			$("#oeffnungszeiten-toggle").click( function(){
				$('div.oeffnungszeiten').find('div.text').toggle();
				if ($(document).height() > ($(window).height() - 25)){
					var newPos = $('div#headBox').height() + $('div#contBox').height() + 25;
					if (newPos >= $(window).height() - 25)
						$('div#footer').css({'top' :  newPos + 'px'});
					else
						$('div#footer').css({'top' :  $(window).height() - 25 + 'px'});
				}	
			});
		}
});


function positionFooter(){				//positioniert footer immer am Ende der Seite, bzw. am unteren Rand
	var yPos = $(window).height() - 25;
	var curPos = $("div#footer").position();
//	alert ("document: "+$(document).height() + ", window: " + $(window).height());
	if ($(document).height() <= $(window).height() && curPos)
		if (curPos.top <  yPos){
			$("div#footer").css({
				'top' : yPos + "px"
			});
		}
}


function nav_over(obj, objID){
	objID = objID.replace('nav_','');
	var hoverImgPath = "img/nav/"+objID+"_hover.png";
	$(obj).find("img").attr({
		src: hoverImgPath
	});
}

function nav_out(obj, objID){
	objID = objID.replace('nav_','');
	var hoverImgPath = "img/nav/"+objID+".png";
	$(obj).find("img").attr({
		src: hoverImgPath
	});
}

function slideFitness() {
    var $active = $('div#slideFitness IMG.active');

    if ( $active.length == 0 ) $active = $('div#slideFitness IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('div#slideFitness IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
     //var $sibs  = $active.siblings();
     //var rndNum = Math.floor(Math.random() * $sibs.length );
     //var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function slideKlettern() {
    var $active = $('div#slideKlettern IMG.active');

    if ( $active.length == 0 ) $active = $('div#slideKlettern IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('div#slideKlettern IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
     //var $sibs  = $active.siblings();
     //var rndNum = Math.floor(Math.random() * $sibs.length );
     //var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function slideTennis() {
    var $active = $('div#slideTennis IMG.active');

    if ( $active.length == 0 ) $active = $('div#slideTennis IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('div#slideTennis IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
     //var $sibs  = $active.siblings();
     //var rndNum = Math.floor(Math.random() * $sibs.length );
     //var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function slideWellness() {
    var $active = $('div#slideWellness IMG.active');

    if ( $active.length == 0 ) $active = $('div#slideWellness IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('div#slideWellness IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
     //var $sibs  = $active.siblings();
     //var rndNum = Math.floor(Math.random() * $sibs.length );
     //var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function slideOthers() {
    var $active = $('div#slideOthers IMG.active');

    if ( $active.length == 0 ) $active = $('div#slideOthers IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('div#slideOthers IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
     //var $sibs  = $active.siblings();
     //var rndNum = Math.floor(Math.random() * $sibs.length );
     //var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}


function changeCurImg(obj, objSrc){
	objSrc = objSrc.replace('th/', '');
	var pic = $("img#bigPhoto");
	pic.attr('src', objSrc);
	$(document).find('.thActive').attr('class', 'th');
	$(obj).attr('class', "thActive");
	positionFooter();
//	adjustScrollBoxHeight();
}



