//Fokusiert erstes sichtbares Formularfeld
window.onload=function()
{
  var forms = document.forms || [];
  for(var i = 0; i < forms.length; i++)
  {
    for(var j = 0; j < forms[i].length; j++)
    {
      if(forms[i][j].type != "hidden" && forms[i][j].disabled != true && forms[i][j].style.display != 'none')
      {
        forms[i][j].focus();
        forms[i][j].focus();
        return true;
      }
    }
  }
}

$(document).ready(function(){

  //$(".subnavi").hide();

  $(".subnavi").hover(
    function(){
      che = false;
    },
    function(){
      che = true;
      if($("#cat"+objk).attr('id'))
      {
        $(".subnavi").stop().slideUp(300);
        $("#cat"+objk).hide();
      }
    }
  );

  $.fn.wait = function(time, type) {
        time = time || 1200;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
  };

  $(".navi a").hover(
    function(){
      che = true;
      if($("#cat"+objk).attr('id'))
      {
        $(".subnavi").stop().slideUp(300);
        $("#cat"+objk).hide();
      }
      objk = $(this).attr('id');
      if($("#cat"+objk).attr('id'))
      {
        $(".subnavi").wait().stop().height('auto').slideDown(100);
        $("#cat"+objk).wait().show();
        che = false;
      }
    },
    function(){
      objk = $(this).attr('id');
      if($("#cat"+objk).attr('id') && che == true)
      {
        $(".subnavi").stop().slideUp(300);
        $("#cat"+objk).hide();
      }
    }
  );

});

