function closeMenu(){
     $(".link").find("a").css("color","#FFE0F8");
     $(".link").parent(".item").removeClass("menu_hover");
     $(".link").parent(".item").find(".left-border").removeClass("menu_hover_left_border"); 
     $(".link").parent(".item").find(".right-border").removeClass("menu_hover_right_border");
     $(".subnav:visible").slideUp("fast",function(){ 
         $("#subnav_container").hide(); 
     });
}

function closeTootip(){
	$("#bugz_dial_tooltip").fadeOut("slow");
}

$(document).ready(function(){
    var timeout;

    $(".link").bind("mouseenter",function(){
        clearTimeout(timeout);
        $(".link").find("a").css("color","#FFE0F8");
        $(this).find("a").css("color","white");
        $(".link").parent(".item").removeClass("menu_hover");
        $(this).parent(".item").addClass("menu_hover");
        $(".link").parent(".item").find(".left-border").removeClass("menu_hover_left_border");
        $(this).parent(".item").find(".left-border").addClass("menu_hover_left_border");
        $(".link").parent(".item").find(".right-border").removeClass("menu_hover_right_border");
        $(this).parent(".item").find(".right-border").addClass("menu_hover_right_border");
        var sectionname = $(this).attr("id").split("_")[1];
        if(!$("#subnav_container").is(':visible')){
            $("#subnav_container").show();
            $(".subnav").hide();
             $("#sub_"+sectionname).slideDown("fast"); 
        }else{
            $(".subnav").hide();
            $("#sub_"+sectionname).show();
        }
    });

    $("#main_menu").bind("mouseenter",function(){
        clearTimeout(timeout);
    });

    $("#main_menu").bind("mouseleave",function(){
        timeout = setTimeout('closeMenu()', 800);
    });
    
    
	$(".twitt").hover(function(){$(this).css("background-color","#C5DFD5")},function(){$(this).css("background-color","#C3E0EE")});
	
	$("#bugz_dial").bind("click",function(){
		$.get('/randtips.php', function(data) {
			$("#bugz_dial_tooltip").html(data);
			$("#bugz_dial_tooltip").fadeIn("fast");
		});
	});
	
	$("#header").bind("mouseleave",function(){
        timeout = setTimeout('closeTootip()', 1600);
	});
	
	

});

