$(document).ready( function(){
	$('.main-menu ul.sub-menu:not(.expanded)').hide();
	
	$('.main-menu li').bind("mouseenter", function() {
		var elem = $(this).find("a.expandable").next();
		if (elem.is(":hidden")) {
			elem.slideDown(400);
		}
	})
	
	.bind("mouseleave", function() {
		var elem = $(this).find("a.expandable").next();
		if (!(elem.is(":hidden")) && !elem.hasClass("expanded")) {
			elem.slideUp("slow");
		}
	});
	
	
	$("#slider").easySlider({
			auto: true,
			continuous: true,
			controlsShow: false,
			pause: 4000
		}
	);	
	$('a[rel*=facebox]').facebox();	
	$("li.expandable li.toggle a").click(function () {
		$(this).parent().children().filter("ul").toggle();
	});
});

function destroy(url) {
	if (confirm("Are you sure you want to delete this news item?")) {
		$.ajax({
			type: 'DELETE', 
			url: url,
			success: function() {
				url_parts = url.split("/");
				elem_id = "item-" + url_parts[3];
				$("#" + elem_id).slideUp();
			}
		});
	}
}