$(document).ready(function() {

/* --- IE Trennlinien entfernen --- */
  $(".news .textblock:last").css("margin",0).css("padding",0).css("border-bottom","none");
  $(".content .textblock:last").css("margin",0).css("padding",0).css("border-bottom","none");
  $(".content table tr:first td").css("border-top","none");
  $(".content table tr").each(function(){$(this).find("td:first").css("border-left","none");$(this).find("td:last").css("border-right","none")});
  $(".content table tr:last td").css("border-bottom","none");

/* --- Kursanmeldung --- */
  if($("input[name=ismember]:radio:checked").val()=="member")
    $("#NOmember").hide();
  else
    $("#member").hide();
  $("input[name=ismember]").click(function(){
    $(".memtable").hide();
    $("#"+$(this).attr("value")).show();
  });

/* --- Close-Buttons --- */
  $(".all .close").click(function(){
    $(".results").slideUp(500);
  });
  $(".one .close").click(function(){
    $(".one").slideUp(500);
  });
  $(".trainerform").submit(function(){
    $(".results").hide().empty();
    $(".trainerform .load").show();
    $.ajax({
      type: "POST",
      url: "search.php",
      global: false,
      data:({mode:"all",lang:$("#searchlang").val(),region:$("#searchregion").val(),level:$("#searchlevel").val()}),
      success: function(msg){
        $(".trainerform .load").hide();
        if($.browser.msie) {
          $(".all").html(msg).show(function(){$('html,body').animate({scrollTop:$("#all").offset().top},'slow');});
        } else {
          $(".all").html(msg).slideDown(500,
   function(){$('html,body').animate({scrollTop:$("#all").offset().top},'slow');}
            );
        }
        $(".all .close").click(function(){
          $(".results").slideUp(500);
        });
        $(".all tr").click(function(){
          getoneinstructor($(this).attr("rel"));
        });
      }
    });
    return false;
  });
/* --- Trainersuche nur mit JS --- */
  $("form.trainerform").show();

/* --- URLS zu Links wandeln --- */
  $(".content .in").linkify();

/* --- Wechselbilder initialisieren --- */
  $("#stage .imgblock .mini a").click(function(){
    $("#stage .imgblock .big .sublay").attr("src",$(this).find("img").attr("src"));
    $("#stage .imgblock .big .overlay").fadeOut(800,function(){
      $("#stage .imgblock .big .overlay").attr("src",$("#stage .imgblock .big .sublay").attr("src")).show();
    });
    return false;
  });
});

/* --- Trainersuche --- */
function getoneinstructor(id) {
  $.ajax({
    type: "POST",
    url: "search.php",
    global: false,
    data:({mode:"one",id:id,lang:$("#searchlang").val()}),
    success: function(msg){
        $(".one").html(msg).slideDown(500,
 function(){$('html,body').animate({scrollTop:$("#one").offset().top},'slow')}
          );
        $(".one .close").click(function(){
          $(".one").slideUp(500)
        });
    }
  });
}
