$(function(){

});
//Sexy Menu
$(document).ready(function() {

    $("ul.subnav").parent().addClass("hasSubMenu"); //Adds hasSubMenu to parent <li>
    if (Modernizr.touch) {
        $("ul.topnav").children("li").click(function() {
            //Close all subnavs
            $("ul.topnav li").find("ul.subnav").hide();
        });
        $("ul.topnav li.hasSubMenu").click(function() { //When trigger is clicked...  $("ul.topnav li span").click(function()  
            //Following events are applied to the subnav itself (moving subnav up and down)
            $(this).find("ul.subnav").slideDown(200).show(); //Drop down the subnav on click

            $(this).click(function() {
            }, function() {
            $(this).find("ul.subnav").hide(); //slideUp('fast')
            });
        })
    }
    else {
         $("ul.topnav").children("li").mouseenter(function() { 
            //Close all subnavs
            $("ul.topnav li").find("ul.subnav").hide();
         });
        $("ul.topnav li.hasSubMenu").mouseenter(function() {
            //Following events are applied to the subnav itself (moving subnav up and down)
            $(this).find("ul.subnav").slideDown(200).show(); //Drop down the subnav on hover  

            $(this).mouseleave(function() {
                $(this).find("ul.subnav").hide(); //When the mouse moves out of the subnav, close it.  
            });
        })
    }
});  
