;(function($){
  $(document).ready(function(){
    
    DD_roundies.addRule('.block', '2px 2px 8px 8px', false);
    DD_roundies.addRule('#wrapper, #content', '10px', false);
    DD_belatedPNG.fix('.block');
    
    /* Layer sidebar blocks so that they overlap properly */
    $('.region').each(function(){
      var i = $('.block', this).size();
      $('.block', this).each(function(){
        $(this).css('z-index', Math.abs(i));
        i--;
      });
    });
    
    /* Enable front-page release sliders */
  $('.slider').each(function(){
	thisSlider = $(this);
	$('.slider-releases', thisSlider).cycle({
	  timeout: 10000,
	  fx: 'scrollUp',
	  pause: true,
	  pauseOnPagerHover: true,
	  next: $('.release-next', thisSlider)
	});

	$('.release-images', thisSlider).cycle({
	  next: $(this)
	});

	$(thisSlider).hover(function(){
	  $('.caption', this).css('visibility', 'visible');
	}, function(){
	  $('.caption', this).css('visibility', 'hidden');
	});
  });

	$(".slider a").click(function(e) {
		e.stopPropagation();
	});
	
    $(".release-page-images").cycle({
      fx: "fade",
      timeout: 10000,
      speed: 500,
      next: $(".release-page-images"),
      pause: 1,
      fit: 1
    });
    $('.block').each(function(){
    	if ($(this).children('.title').children('a').length) {
    		text = $('.title a', this).attr('title');
    		$(this).append('<div class="shade"></div>').css({'position':'relative'});
    		$('.shade', this).append('<div class="liner">'+text+'</div>').css('opacity',0).click(function(){
	    		link = $(this).parent().children('.title').children('a').attr('href');
 				window.open (link, "newwindow");
    		});
    		$(this).hover(function(){
			$('.shade', this).stop().animate({
				opacity: 1
				}, 300);
			}, function(){
				$('.shade', this).stop().animate({
				opacity: 0
				}, 300);
			});
		}
	});
        
});
  
	setTimeout(function(){
		$(".status_message").slideUp("slow", function(){
			$(this).remove();
		});
	}, 5000);
	
	$(".status_message").click(function(){
		$(this).slideUp("slow", function(){
			$(this).remove();
		});
	});
	$("#backend .threecolumn:last").css("margin-bottom", "1em");
	
	$(".form_panel .form_handle").click(function(){
		$(this).siblings(".backend_panel").slideToggle("slow");
	});
	
	var c = $(".column .block").length;
	$(".column .block").each(function(){
		$(this).css("z-index", c);
		c--;
	});
	
	$("li", "#block_subnav").click(function(){
		window.location.href = $("a", this).attr("href");
	});
	
	$("li", "#block_nraonews").click(function(){
		window.location.href = $("a", this).attr("href");
	});
		
	$("li", "#block_auinews").click(function(){
		window.location.href = $("a", this).attr("href");
	});
	window.onload = function(){
		$("#cover img").animate({
			left: "-30em"
		}, 8000);
	}
})(jQuery);
