$(document).ready(function(){
  $("#mainnavi div").bind("mouseenter", function(e){
      $(this).css("background-image", "url(images/button_hover.gif)");
  });
  
  $("#mainnavi div").bind("mouseleave", function(e){
      $(this).css("background-image", "url(images/button_non-activ.gif)");
  });
  
  $("#mainactive div").unbind("mouseenter", "mouseleave");
  
  active_element();
  
  
  // Login
  $("#username").attr("value", "username");
  $("#passwort").attr("value", "passwort");
  
  $("#username").focus(function(e){
    var text = $(this).attr("value");
    if(text == "username") {
      $(this).attr("value", "");
    }
  });
  
  $("#username").blur(function(e){
    var text = $(this).attr("value");
    if(text == "") {
      $(this).attr("value", "username");
    }
  });
  
  $("#passwort").focus(function(e){
    var text = $(this).attr("value");
    if(text == "passwort") {
      $(this).attr("value", "");
    }
  });
  
  $("#passwort").blur(function(e){
    var text = $(this).attr("value");
    if(text == "") {
      $(this).attr("value", "passwort");
    }
  });
  
  // Suche
  $("div.suche").css({'display' : 'inline', 'visibility' : 'visible'}); 
  $("#suchstring").attr("value", "Dein Suchwort");
  
  $("#suchstring").focus(function(e){
    var text = $(this).attr("value");
    if(text == "Dein Suchwort") {
      $(this).attr("value", "");
    }
  });
  
  $("#suchstring").blur(function(e){
    var text = $(this).attr("value");
    if(text == "") {
      $(this).attr("value", "Dein Suchwort");
    }
  });
  
  $("#videosuche").click(function () { set_destination('video'); });
  $("#camsuche").click(function () { set_destination('cam'); });
  
  $("#suchform").submit(function(){
      var text = $("#suchstring").attr("value");
      if(text == 'Dein Suchwort') {
        return false;
      }
  });
  
  $("#suchstring").change(function(){
    var mode = $("#mode").attr("value");
    var text = $("#suchstring").attr("value");
    
    if(mode == "cam") {
      if(isNaN(text)) {
        $("#suchstring").attr("name", "k");
      }
      else {
        $("#suchstring").attr("name", "p");
      }
    }
  });
  
  // left navigation bottom height
  var clubcontent = $("#content .clubcontent");
  if(clubcontent.attr("class")) {
    var contentEnd = clubcontent.position().top + clubcontent.height();
    var naviBottomHeight = contentEnd - $(".leftnavigation .bottom:last").position().top - $(".leftnavigation .bottom:last").height();
    if(naviBottomHeight > 0) {
      $(".content_bottom").height(naviBottomHeight);
    } 
  }
});
