$(document).ready(function(){	
	$("#slide").easySlider({
		nextId: 'next',
		prevId: 'previous',
		auto: true,
		continuous: true,
		pause: 5000
	});

	// Navigation Dropdown Menu

	$("#nav li ul").animate({
		'opacity': 0,
		'height': 0
	}, 0);
	$("#nav li").hover(function() {
		var z = $(this).children("ul").children("li").length;
		$(this).children("ul").css('top', '40px').stop().animate({
			'opacity': 1,
			'height': z*28 + 'px'
		}, 200);
	}, function() {
		$(this).children("ul").stop().animate({
			'opacity': 0,
			'height': 0
		}, 200).css('top', '-999px');
	});
	$('#nav li ul li').hover(function() {
		$(this).addClass('hovered');
	}, function() {
		$(this).removeClass('hovered');
	});

	// Sidebar Accordion Menu

	$("#subnav li ul").animate({
		'opacity': 0,
		'height': 0
	}, 0);
	var n = $("#subnav li.down ul").children("li").length;
	$("#subnav li.down ul").animate({
		'opacity': 1,
		'height': n*27 + 'px'
	}, 0);
	$("#subnav li").hover(function() {
		if (!$(this).hasClass('down')) {
			var i = $(this).children("ul").children("li").length;
			$(this).children("ul").stop().animate({
				'opacity': 1,
				'height': i*27 + 'px'
			}, 300);
		}
	}, function() {
		if (!$(this).hasClass('down')) {
			$(this).children("ul").stop().animate({
				'opacity': 0,
				'height': 0
			}, 300);
		}
	});
});
