var if_height = 300;

$(document).ready(function(){

  $("input#kontaktart1").click(function(){
      $("label#faxL,label#street,label#zip,label#country").removeClass("required");
  });

  $("input#kontaktart2").click(function(){
      $("label#faxL,label#street,label#zip,label#country").removeClass("required");
  });

  $("input#kontaktart3").click(function(){
      $("label#street,label#zip,label#country").removeClass("required");
      $("label#faxL").addClass("required");
  });

  $("input#kontaktart4").click(function(){
      $("label#faxL").removeClass("required");
      $("label#street,label#zip,label#country").addClass("required");
  });

  var elmt = $("div#footer");
  var position = elmt.position();
  $("p.posInfo").text( "left: " + position.left + ", top: " + position.top );

  var nav = $("#macronav li.active").parents("li").attr("id");
  if(nav){
     nav = nav.slice(1);
  }else{
     nav=-1;
  }

  $(".anfNews a").replaceWith("<span class=\"reisePopup\" onClick=\"javascript\:Popup()\;\">Reiseinfos</span>");

  $("#detailsearch").tabs(".pane", {tabs: 'span', effect:'slide'});
  $("#detailsearch2").tabs("div.description", {event:'mouseover'});

  $("ul.searchtabs").tabs("div.anfBtm > div.amen", {effect:'fade'});

  $("#resultList #newsInfo ul#news").tabs("#resultList #newsInfo div#newsblock > ul", {effect:'fade'});

  $("#macronav.filter ul").addClass("filter");
  $(".filter li input").addClass("hideInput");
  $(".filter li").mouseenter(function(){$(this).addClass("hover");}).mouseleave(function(){$(this).removeClass("hover");});
  $(".filter form").click(function(){
    $(".filter li").removeClass("checked");
    $("input:checked",this).parents("li").addClass("checked");
  });

  if ($("ul.filter li input.radio").is("input:checked")) {
    $("input:checked",this).parents("li").addClass("checked");
  };

  $(".filter li input.radio").click(function(){
    $("input:checked",this).parents("li").addClass("checked");
    $(".filter form").submit();
  });

  $("div.tippT a[rel]").overlay({
    onBeforeLoad: function() {
      var vidID = this.getTrigger().attr("class");
      $.ajax({type:"POST", url:"getVidInfo", data: "vidID="+vidID, cache:"false", dataType:"text/html", success:function(html){
        $("#ytVid").html(html);
      }});
    }
  });



  $("input#category48").click(function(){
        if ($("input#category48").is("input:checked")) {
            $("div.category input:not(#category48)").attr("disabled", "disabled");
            $("div.category input:not(#category48)").attr("checked", "");
            $("div#rooms").slideUp('slow', function () {
                $("div#camping").slideDown('slow');
                $("div#rooms select").val('');
            });
        } else {
            $("div.category input:not(#category48)").attr("disabled", ""); 
            $("div#camping").slideUp('slow', function () {
                $("div#rooms").slideDown('slow');
                $("div#camping input:checkbox").attr("checked", "");
                $("div#camping input:radio").attr("checked", "");
            });
        };
  });

 if($.receiveMessage){
   $.receiveMessage(function(e){
     // Get the height from the passsed data.
     var h = Number( e.data.replace( /.*if_height=(\d+)(?:&|$)/, '$1' ) );
     if ( !isNaN( h ) && h > 0 && h !== if_height ) {
      // Height has changed, update the iframe.
      // checking min and max height
      h=(h<300)?300:h;
      $("#TB_iframeContent").height( if_height = h+5 );
     }
   });
 }

});
