var menuShowId = null;
var hoverable = new Array();
	hoverable["menu_home"] = 1;
	hoverable["menu_cybooks"] = 1;
	hoverable["menu_news"] = 1;
	hoverable["menu_ebooks"] = 1;
	hoverable["menu_support"] = 1;
	hoverable["menu_shop"] = 1;
	hoverable["menu_about"] = 1;


$(document).ready(function(){
	$('#menu_nav li a').hover(function() {
        //check if an other submenu is show, if it : hide it
        if(menuShowId != null) {
            //show
            $("#sub"+menuShowId).stop().hide();
            //change color
            if($("#"+menuShowId+" a").attr('class') != 'selected') {
                $("#"+menuShowId+" a").css('color', "#75726f");
            }
        }
         //get id sub
        var parentId = $(this).parent().get(0).id;
        if($("#" + parentId + " a").attr('class') != 'selected') {
            if(hoverable[$("#" + parentId).attr('id')] != 0)
                $(this).css('color', '#bfd75b');
        }
        menuShowId = parentId;
 
        //position
        $("#sub"+menuShowId).css(
            'left',
            $("#"+menuShowId).offset().left
        );
        //show sub menu
        $("#sub"+menuShowId).stop().show();
        
	});
    //stop display sub item on out
    $('#menuTop_sub').hover(function() {}, function() {
        $('#menuTop_sub ul').hide();
    });
    $('#menuTop_sub ul').hover(function() {}, function() {
      // $(this).css('display', 'none');
       $('#menuTop_sub ul').hide();
		if($('#'+$(this).attr('id').split("sub")[1]+" a").attr('class') != 'selected') {
			$('#'+$(this).attr('id').split("sub")[1]+" a").css('color', '#75726f');
		}else {
			$('#'+$(this).attr('id').split("sub")[1]+" a").css('color', '#ffffff');
		}
    });
});
