var navigation_li_hover = new Array();
var timeToWait = 500;
function NavigationTimer( j, id )
{
    var _id = id.substring(7,id.length); 

	navigation_li_hover_bis = navigation_li_hover;

	/* if( navigation_li_hover_bis[j] == false || $('#navigation_block_top > #nav > li > .subCategory:visible').length == 0 ){ */
		if( !detectIsOpen( $('#'+id) )) {
            $('#navigation_block_top > #nav > li > .subCategory:not(".is_open")').hide();
        }
        for (var i in navigation_li_hover_bis) {   
			if(navigation_li_hover_bis[i] == true){
				if( $('#sub_category_'+_id).children('div').length == 0 ){
					$.ajax({
						url: baseDir+"modules/nq_navigation/menu.php",
						data: "menu="+_id+"&page=gen&id_lang="+id_lang,
						success: function( html ) { 
							$('#sub_category_'+_id).html( html );
							replaceHiddenLinks2();
						}
					});              
				}
				$('#navigation_block_top > #nav > li:eq('+i+') > .subCategory').show();
            }
        }
   /* } */
}


function detectIsOpen(_obj)
{
    return _obj.find('div').eq(0).hasClass('is_open');
}

function replaceHiddenLinks2() {
    $("span[rel^='hdn']").attr('class', function(){
        $(this).wrap('<a href="'+$.base64Decode(($(this).attr('class')).substring(1) )+'" class="'+$(this).attr('title')+'" style="'+$(this).attr('style')+'" id="'+$(this).attr('id')+'" />');
        $(this).before($(this).html());
        $(this).remove();
    });
}

$(document).ready(function()
{                    
    $('#nav li').each(function(j){
        navigation_li_hover[j] = false;
        $(this).hover(function(){
            navigation_li_hover[j] = true;
            setTimeout("NavigationTimer("+j+",'"+$(this).attr('id')+"')", timeToWait);
        }, function(){
            navigation_li_hover[j] = false;
            setTimeout("NavigationTimer("+j+",'"+$(this).attr('id')+"')", 0);
        });
    });
    
    //  Ouverture menu category
    if( page_name == 'category' && insanep ) {
        $('.subCategory').each( function() {
            if( $(this).html() != '' && $(this).hasClass('is_open') )
                $(this).show();    
        });
    }
    
   // mainmenu(id_lang);
});

/* 
function mainmenu(id_lang)
{
    $("#nav ul").css({display: "none"}); // Opera Fix
    $("#nav li").hover(
        function(){  
            if( !detectIsOpen( $(this) )) {
                $('.subCategory[class$!="is_open"]').hide();
                if($(this).find('div:first').html() == ''){
                    id = $(this).attr('id');
                    id = id.substring(7,id.length);
                    $.ajax({
                        url: "modules/nq_navigation/menu.php",
                        data: "menu="+id+"&page=gen&id_lang="+id_lang,   
                        context: document.body,
                        success: function(html){
                            $('#sub_category_'+id).html(html);
                            replaceHiddenLinks2();
                            $('#sub_category_'+id).show(); 
                        }
                    });
                }
                else{    
                    $(this).find('div:first').show();
                }
            }
        },
        function(){ 
            if( !detectIsOpen( $(this) )) {     
                $(this).find('div:first').hide();
            }
        }
    );
    
    //  Ouverture menu category
    if( page_name == 'category' && insanep ) {
        $('.subCategory').each( function() {
            if( $(this).html() != '' && $(this).hasClass('is_open') )
                $(this).show();    
        });
    }
}

function returnposition(cssvalue){
    if(cssvalue){
        var exploded = cssvalue.split(' ');
        exploded[0]=Number(exploded[0].substring(0,(exploded[0].length-2)));
        exploded[1]=Number(exploded[1].substring(0,(exploded[1].length-2))); 
        return exploded;
    }
} 
*/
