$(document).ready(function() {
 
	//EXTERNES FENSTER ÖFFNEN 
	$("a[rel='external']").click(function(event){
				window.open($(this).attr("href"));
				event.preventDefault();
	});
	
	//SCROLL	
	if ( this.location.href.indexOf("?") > -1){ 
 	$target = $("#contentInner");
	var targetOffset = $target.offset().top;
    $('html,body').animate({scrollTop: targetOffset}, 1000);
    }
  
    
	 //LIGHTBOX
    $('a[rel*=lightbox]').lightBox();
	
	//IMAGE SLIDER
	$('#banner1').cycle({ 
		fx: 'fade'
	});
	
	//ACCORDION - ONE TICKET
	$(".accordion1 div").hide();
	$(".accordion2 div").hide();
	$(".accordion3 div.guestbook").hide();
	
	$(".accordion1 h5").click(function(){
	  $(this).next("div").slideToggle("slow")
	  .siblings("div:visible").slideUp("slow");
    });
	$(".accordion2 h5").click(function(){
	  $(this).next("div").slideToggle("slow")
	  .siblings("div:visible").slideUp("slow");
    });
    $(".accordion3 h1").click(function(){
	  $(this).next("div.guestbook").slideToggle("slow")
	  .siblings("div.guestbook:visible").slideUp("slow");
    });
    
    //GALERIE ACCORDION
    $('.gallery').each(function() {
        gallery($(this));
    })
    
    /*FORM CHECKBOX ACTIVATE / DEACTIVATE TEXTBOX*/
    $(".disabled").attr("disabled", true);    
    $(".disabled").css("background","#eee")
    
    $("#chb_resRechnCh").click(function() { 
       checked("#chb_resRechnCh");       
    });
    
    $("#chb_aboRechnCh").click(function() { 
        checked("#chb_aboRechnCh");
    });
    
   /*TOOL TIP*/
   //$('.toolTipStyle').css('visibility','visible');  
   $('.toolTipStyle').hide();
   $('.toolTipStyle').css("visibility","visible");
   var t;   
   $('.toolTip').hover(function(){
     t = setTimeout("showTT('"+this.hash+"',"+($(this).offset().left + $(this).width()+15)+","+$(this).offset().top+")",800);
   },
   function(){
        clearTimeout(t);
        $(this.hash).hide();
   });
 
});

    //ToolTip
   function showTT(target,left,top){
        $(target)
        .css({
            "left":left,
            "top":top      
        })
        .show();        
   }

   //Checkbox
    function checked(target) {
       if ($(target).attr("checked"))
       {
        $(".disabled").removeAttr("disabled");
        $(".disabled").css("background","#fff")
       } else {
       $(".disabled").attr("disabled", true);
       $(".disabled").css("background","#eee")
       $(".disabled").val("");
       } 
       
    }
    
    //Galerie
    function gallery(target) {

    $(".images", target ).height($(".bg .img", target ).outerHeight() + 10);
    $(".status a", target).click(function(e) {
        e.preventDefault();
        if ($(".images", target).height() == $(".bg .img", target).outerHeight() + 10) {
            $(".images", target).animate({
                height: $(".bg", target).height()
            });
            $(".status a", target).text("Bilder verstecken");
        } else {
            $(".images", target).animate({
                height: $(".bg .img", target).outerHeight() + 10
            });
            $(".status a", target).text("alle Bilder zeigen");
        }
    })

}