jQuery(document).ready(function() {
	var $slideshow = jQuery(".slides");
	var initialLoad = true;
	
	$slideshow
		.cycle({
			fx: 'fade',
			timeout: 7000,
			speed: 500,
			pause: 1,
			before: function(currentSlideElement, nextSlideElement) {
				if(!initialLoad) $slideshow.parent().children(".slides_description").animate({ "bottom": "-392px" });
				else initialLoad = false;
			},
			after: function(currentSlideElement, nextSlideElement) {
				var desc = jQuery(nextSlideElement).find("img").attr("alt");
				
				if(desc.replace(" ", "") != "") $slideshow.parent().children(".slides_description").html(desc).animate({ "bottom": "0px" });
			}
		})
	.end();
	
	jQuery("#sidebar")
		.find("img#mag")
			.css({ "cursor": "pointer" })
			.hover(
				function() {
					jQuery(this).parent().parent().find("a[rel='mag']").addClass("active");
				}, function() {
					jQuery(this).parent().parent().find("a[rel='mag']").removeClass("active");
				}
			)
			.click(function() {
				window.location = jQuery(this).parent().parent().find("a[rel='mag']").attr("href");
			})
		.end()
	.end();
});