function reset_nav ()
{
 $(".navi_ul").not($(".activated").next("ul")).slideUp("fast");
 $(".activated").next("ul").slideDown("fast");
}

$(function() 
{
	
  // Tab Navigation
  var curr_pos = 0;
  $(".headernav div").each(function() {

    var left_pos = -6*curr_pos;
    $(this).css("position", "relative").css("left", left_pos + "px").css("z-index", $(this).hasClass("headernavactive") ? 101 : 100-curr_pos);
     curr_pos++;
  });
  
  var left_pos = -6*curr_pos;
  $(".suche-home").css("position", "relative").css("left", left_pos + "px");

 // Left Navigation 
 for(var level=1; level<=2; level++)
 {
  $(".navi_button"+level).attr("rel", level).bind('mouseover', function() {
   $(this).oneTime('300ms', 'accTimer', function() {
    $("html").stopTime("closeNavTimer"); // stop close sub nav timer
    var curr_level = $(this).attr("rel");
    $(".navi_button"+curr_level).next("ul").not($(this).next("ul")).slideUp("fast");
    $(this).next("ul").slideDown("fast");
   }).bind("mouseout", function() {
    $(this).stopTime('accTimer');
   });
  }).bind("mouseout", function() {
   $("html").oneTime("2s", "closeNavTimer", function() {
    reset_nav(); // close sub navs after 2 Seconds
   });
  }).next(".navi_ul").hide();
 }

 $(".navi_ul").bind('mouseover', function() {
  $("html").stopTime("closeNavTimer"); // stop close sub nav timer
 }).bind("mouseout", function() {
  $("html").oneTime("2s", "closeNavTimer", function() {
   reset_nav(); // close sub navs after 2 Seconds
  });
 });
 
 // prevent activated frame in Firefox
 $(".navi_button").click(function() {
  $(this).blur();
 });

 // Open activated sub navigation
 $(".activated").parent("li").parent("ul").show(); 
 
});

