$(function() {
    
    var newsOverlay = function () {
    	var item = $(this).closest('.news');
    	var image = item.children('.news_image').html();
    	var title = item.children('.news_content').children('h2').html();
    	var body = item.children('.news_content').children('.news_body').html();
    	var links = item.children('.news_content').children('.news_links').children('p').html();
    	
    	var content = '';
    	content += '<div class="news">';
    	content += image;
    	content += '<h2>' + title + '</h2>';
    	content += body;
    	content += '<p class="modal_news_links">' + links + '</p>'
    	content += '</div>';
    	
    	$.modal(content, {overlayId: 'modal_overlay',
    		              containerId: 'modal_container',
    		              onOpen: function(dialog){
    						  dialog.overlay.fadeIn('slow', function () {
    								dialog.container.slideDown('slow', function () {
    									dialog.data.fadeIn('slow');
    								});
    							});
						  },
    		              onClose: function(dialog){
    						  dialog.data.fadeOut('slow', function () {
	  								dialog.container.slideUp('slow', function () {
	  									dialog.overlay.fadeOut('slow', function () {
	  										$.modal.close();
	  									});
	  								});
  								});
						  }
    	});
    }
    
    $("#pl_1_1").scrollable({items:'div.entries', size:4, clickable:false}).circular().autoscroll();
    
    $('.news_link_full_story').click(newsOverlay);
    $('.news_image').click(newsOverlay).mouseover(function(){
    	$(this).css({
    		'opacity' : '0.8',
    		'filter' : 'alpha(opacity = 80)'});
    }).mouseout(function(){
    	$(this).css({
    		'opacity' : '1',
    		'filter' : 'alpha(opacity = 100)'});
   	});;
});
