$(document).ready(function() {
$("#nav li").hover(function() {
	var $this = $(this);

	$this.addClass('active');
	if ($this.children("ul").length > 0) {
		$this.children("ul").slideDown("fast");
	}
}, function() {
	var $this = $(this);

	if ($this.children("ul").length > 0) {
		$this.children("ul").stop(true, true).slideUp("fast", function() {
			$this.removeClass('active');
		});	
	}
	else {
		$this.removeClass('active');
	}
});
});
