/* ================================================================ 
 Copyright (c) 2011 Stu Nicholls - stunicholls.com. All rights reserved.
 This script and the associated html may be modified in any
 way to fit your requirements.
 http://www.stunicholls.com/menu/jquery-anywidth-flyout.html
 =================================================================== */
$(document).ready(function(){
    timer = 0;
    collapse = 100;
	
    $('#hauptnavi').height($('#hauptnavi > ul').height()); 
    
    $('#hauptnavi li a').mouseover(function(event){
        if (this == event.target) {
            $(this).parent().toggleClass('clicked').children('ul').animate({
                width: 'show'
            });
            $(this).siblings().children().removeClass('clicked').find('ul').animate({
                width: 'hide'
            });
            $(this).parent().siblings().removeClass('clicked').find('ul').animate({
                width: 'hide'
            });
        }
    }).addClass('fly');
    
    $('#hauptnavi li:not(:has(ul)) a').mouseout(function(event){
        if (this == event.target) {
            $(this).parent().removeClass('clicked');
            $(this).siblings().children().removeClass('clicked').find('ul').animate({
                width: 'hide'
            });
            $(this).parent().siblings().removeClass('clicked').find('ul').animate({
                width: 'hide'
            });
        }
    }).removeClass('fly');
    
    $("#hauptnavi").mouseover(function(){
        clearTimeout(timer);
    });
    
    $("#hauptnavi").mouseout(function(){
        timer = window.setTimeout(function(){
            $('#hauptnavi li > a').siblings().children().removeClass('clicked').find('ul').fadeOut();
            $('#hauptnavi li > a').parent().siblings().removeClass('clicked').find('ul').fadeOut();
        }, collapse);
    });    
});

/*
function getSomeElementsByClassName(class_name,knoten){
    var all_obj;
    var ret_obj=new Array();
    var j=0;
    var i;		  
    if(document.getElementsByTagName){
	all_obj=knoten.getElementsByTagName("*");
      	for(i=0;i<all_obj.length;i++){
        	if(all_obj[i].className==class_name){
          		ret_obj[j]=all_obj[i];
          		j++;
        	}
      	}
	}
    return ret_obj; //!!!! Array
}
*/
