// Define some vars
var animate = true;


/*************************************************************
*
* shows and hides all nav-elements' contents
*
*
**************************************************************/
var runNav = function() {
  $('li.hassub').each(function(index){ // Bei jedem Navigationspunkt der Unterpunkte hat
    $(this).mouseover(function(){ // Beim überfahren des Menüpunktes
      if(animate) {
        if ($(this).children().is(":hidden")) {
          $(this).children().slideDown();
        }
      } else {
        $(this).children().show();
      }
    });
    $(this).mouseout(function(){ // Beim verlassen des Menüpunktes
      if(animate) {
        if (!$(this).children().next().is(":hidden")) {
          $(this).children().next().slideUp();
        }
      } else {
        $(this).children().next().hide();
      }
    });
    
  });
  
  /*$("li.hassub").hover(function(){
   $("li.hassub ul").hide();
    $(this).children("ul").slideDown();
  }, function(){
    $(this).children("ul").slideUp();
  });*/

  
  
}

$(document).ready(function () {
  // Config des Bildsliders im head
  $('#slider').nivoSlider({
    effect:                   'fade',
    slices:                   15,
    animSpeed:                1000,
    pauseTime:                7000,
    startSlide:               0, //Set starting Slide (0 index)
    directionNav:             false, //Next & Prev
    directionNavHide:         true, //Only show on hover
    controlNav:               true, //1,2,3...
    controlNavThumbs:         false, //Use thumbnails for Control Nav
    controlNavThumbsSearch:   '.jpg', //Replace this with...
    controlNavThumbsReplace:  '_thumb.jpg', //...this in thumb Image src
    keyboardNav:              false, //Use left & right arrows
    pauseOnHover:             true, //Stop animation while hovering
    manualAdvance:            false, //Force manual transitions
    captionOpacity:           0.0, //Universal caption opacity
    beforeChange:             function(){},
    afterChange:              function(){},
    slideshowEnd:             function(){} //Triggers after all slides have been shown
  });
  
/* FIX Headline Heights */
$('.subcolumns').each(function(index,value){
    var div = $(value);

    var h2 = div.find('h2');

    if(h2.length > 0){

        defaultHeight = $(h2[0]).height();

        h2.each(function(hindex, hvalue){
            var headline = $(hvalue);
            if(headline.height() > defaultHeight)
            {
                defaultHeight = headline.height();
            }
        });

        h2.each(function(hindex, hvalue){
            var headline = $(hvalue);
            if(headline.height() != defaultHeight)
            {
                headline.find('a').before('<br/>');
            }
        });

    }
});
});
