// onload, page ready
$(document).ready(function () {

  // Menü Level 1 fading
  $(".menu-lvl-1 a img.me").hover(
    function () {
      $(this).fadeTo("fast", 0.9);
    },
    function () {
      $(this).fadeTo("fast", 1);
    }
  );

  // Menü Level 3 fading
  $("#menu-lvl-3 li").hover(
      function () {
        $(this).fadeTo("fast", 0.5);
      },
      function () {
        $(this).fadeTo("fast", 1);
      }
  );

  // Menü Level 4 fading
  $("#content .sidebar ul.menu-lvl-4 li").hover(
      function () {
        $(this).fadeTo("fast", 0.5);
      },
      function () {
        $(this).fadeTo("fast", 1);
      }
  );

  // Links in Sidebar fading
  $("#content .sidebar ul.links li").hover(
      function () {
        $(this).fadeTo("fast", 0.9);
      },
      function () {
        $(this).fadeTo("fast", 1);
      }
  );

  // Links in Sidebar fading
  $("#content .overview-entry").hover(
      function () {
        $(this).fadeTo("fast", 0.7);
      },
      function () {
        $(this).fadeTo("fast", 1);
      }
  );
  
  // Breadcrumb automatisch zusammen fahren lassen
  $(".breadCrumb").jBreadCrumb();

  // Flash Header-Image initialisieren
  if ( headerImg == true )
  {
    var flashvars = {
        height: "200",
        width: "982",
        file: "/imagerotator/index/folder/" + headerFolder,
        transition: "fade",
        shownavigation: "false"
    };
    var params = {
      wmode: "transparent"
    };
    swfobject.embedSWF( "/flash/imagerotator.swf", "header-img", "982", "200", "7", "http://ivf-saar/flash/expressInstall.swf", flashvars, params);
  }
  
  // Alle Links die die Klasse "nyro" besitzen werden über nyroModal dargestellt
  $('a.nyro').nyroModal();

  // Breadcrumb-Icon-Bar Hover-Img
  $('.icons a img').imghover({suffix: '_hover'});
});


// Menu Level-3: Link auf kompletten li legen
function setMenuClick()
{
  var container = $( '#menu-lvl-3 ul' );
  var containerElements  = jQuery( container ).find( 'li' );
  
  $( containerElements ).each(
      function( i, listElement )
      {
        $( listElement ).click(function() {
          document.location.href = $( listElement ).find( 'a' ).attr( 'href' );
        });
      });
  
  if ( containerElements.length > 10 )
  {
    $('#menu-lvl-3-holder').css( 'position', 'absolute' );
  }
}


function checkInputValue( iv, defVal )
{
  if ( iv.value == defVal )
  {
    iv.value = '';
  }
}


function checkInputValueOut( iv, defVal )
{
  if ( iv.value == '' )
  {
    iv.value = defVal;
  }
}
