$(document).ready(function(){

    var isopen = false;

    $("#nav1 li:has(ul)").addClass("nav_arrow");

    $("#nav1 .selected").parent().css("background-color", "white");
    //$("#nav1 .selected").parent().css("border", "1px solid #999999");

    $("#nav1 li a").hoverIntent({
        sensitivity: 1,
        interval: 300,
        over:
            function(){
                var os = $(this).parent().offset();
                $(this).parent().find("ul").show();
                $(this).parent().find("ul").css("left", os.left + 105);
	$(this).parent().css("top", os.top);
            },
        timeout: 500,
        out:
            function(){
                if (!isopen)
                    $(this).parent().find("ul").hide();
            }
    });


    $("#nav1 a").hover(
        function(){
            $(this).parent().css("background-color", "#CCCCCC");
            //$(this).parent().css("border-color", "#999999");
        },
        function(){
            $(this).parent().css("background-color", "");
            //$(this).parent().css("border-color", "#f1f1f1");

            if ($(this).hasClass("selected")) {
                $(this).parent().css("background-color", "white");
                //$(this).parent().css("border", "1px solid #999999");
            }
        }


      );



    $("#nav1 li ul").hover(
        function(){
            isopen = true;
        },
        function(){
            isopen = false;
            $(this).hide();
        }


      );


});

