$(document).ready(function () {
    //do jQuery stuff when DOM is ready

    $("#menu ul li a").each(function ()
    {
        $(this).css("background-image", "url(imgmenu/" + $(this).html().toLowerCase().replace(/\s/g,'') + ".png)");
        console.log($(this).html());
    });
    $("#menu>ul>li").click(function (e) {
   
        var submenu = $(this).children("ul"); 
if(submenu.is(':visible')) {
    $("#menu>ul>li>ul").hide();
	$(".pico").remove(); 
}else{    
        $("#menu>ul>li>ul").hide();
submenu.after("<div class='pico'></div>");
submenu.show("slow");
$(".pico").css("left",e.pageX-15);
 
    }
    });

    $("#menu>ul>li>ul>li a").hover(
            function () {
                 $(this).css("background-size","90%");
				 					$(this).css("z-index","2");

                $(this).animate({width: "150px", "padding-top": "140px", left: "-25px"}, 600, function () {
                });
            }, function () {
				$(this).css("background-size","67%");
					$(this).css("z-index","1");
        $(this).animate({width: "100px", "padding-top": "90px", left: "0"}, 300, function () {
        });

    }
    );
});
  