/*
Site: Landen auf Wasser
HTTP: www.landen-auf-wasser.de
Date: 2008-05-11
*/




/*
Site - Initialize
*/
$(document).ready(
  function() {

    // GLOBAL
    global_element_title_remove();

    // LOCAL
    local_naviMain_link_highlight();
    local_naviMain_menuSub_display();
    local_panelSide_menuSub_position();

    // LOCAL - HOERSTUECKE
    local_hoerstuecke_links_move();

  }
);




/*
GLOBAL
Element - Title (and Tooltip) - Remove
*/
function global_element_title_remove() {

  // REMOVE ATTRIBUT "TITLE" FROM LINKS
  $("a").removeAttr("title");

};


/*
LOCAL
Navigation Main - Link - Highlight
*/
function local_naviMain_link_highlight() {

  // HIGHLIGHT MENUE ITEM
  $("#block-menu-2").find("a.active").parents("ul").siblings().addClass("active");

  // SPECIAL CASE: REVIEWS WITH ADDITIONAL MENUE
  if ($("body").attr("class") == "node flexinode-2") {
    // Set link in Main Navigation on "active"
    $("#block-menu-2").find("ul:eq(0)").children("li:eq(2)").children("a").addClass("active");
    // Set link in Nice Menu 3 on "active"
    $("li.menu-path-node-24").children().addClass("active");
  }

};


/*
LOCAL
Navigation Main - Menu Sub - Display
*/
function local_naviMain_menuSub_display() {

  var menuSub_display_trigger = $("#block-menu-2 li");

  // POSITION SUB MENU
  menuSub_display_trigger.children("ul").css("margin-top", - menuSub_display_trigger.outerHeight() + "px");
  menuSub_display_trigger.children("ul").css("left", menuSub_display_trigger.width() - 1 + "px");
  /*
  ** A cleaner alternative would be to use "top", but this is not IE compatible.
  ** So we use negative "margin-top" instead.
  */

  // SELECT ELEMENTS IN SIDEPANEL TO FADE OUT
  if ($("body").attr("class") == "node flexinode-1") {
    var block_fadeOut = $("#sidebar-right div.block-nice_menus");
  }
  else {
    var block_fadeOut = $("#sidebar-right div.block");
  }

  // DISPLAY SUB MENU AND FADE OUT SIDE PANEL ON MOUSEOVER, MOUSEOUT
  menuSub_display_trigger.children("a").each(
    function() {
      if ($(this).attr("class") != "active") {
        $(this).mouseover(
          function() {
            $(this).addClass("mouse_over");
            $(this).parents("li").addClass("mouse_over");
            // FADE
            block_fadeOut.addClass("fadeOut");
          }
        );
        $(this).mouseout(
          function() {
            $(this).removeClass("mouse_over");
            $(this).parents("li").removeClass("mouse_over");
            // FADE
            block_fadeOut.removeClass("fadeOut");
          }
        );
      }
    }
  );

};


/*
LOCAL
Panel Side - Menu Sub - Position
*/
function local_panelSide_menuSub_position() {

  var panelSide_trigger = $("#block-menu-2").find("a.active").eq(0).parent("li");
  var panelSide_display = $("#sidebar-right"); /* .find("div.block-nice_menus") */

  var panelSide_trigger_height = 0;

  // GET POSITION (HEIGHT) OF TRIGGER ELEMENT
  panelSide_trigger.each(
    function() {
      var node_active = this.previousSibling;
      while (node_active != undefined) {
        if (node_active.nodeName == "LI") {
          var node_active_height = $(node_active).height();
          panelSide_trigger_height = panelSide_trigger_height + node_active_height + 1;
        }
        node_active = node_active.previousSibling;
      }
    }
  );

  // SET PADDING OF SIDE PANEL - POSITION SUB MENU
  panelSide_display.css("padding-top", panelSide_trigger_height + "px");

};


/*
LOCAL - HORSTUECKE
Hoerstuecke - Links - Move
*/
function local_hoerstuecke_links_move() {

  // MOVE CONTENT FROM MAIN PANEL TO SIDE PANEL
  if ($("body").attr("class") == "node flexinode-1") {
    var local_hoerstuecke_links_content = $("div.flexinode-textarea-3");
    var local_hoerstuecke_links_location = $("#block-block-7");
    local_hoerstuecke_links_location.append(local_hoerstuecke_links_content);
  }

};