//Non-logged in homepage

jQuery.noConflict();


/* Homepage rollovers */
jQuery(document).ready(function(){
	jQuery('.hoverblock').hoverIntent(
		function(event) {
			jQuery(this).find('.static').fadeOut(300);
			jQuery(this).addClass('active');
		},
		function(event) {
			jQuery(this).find('.static').fadeIn('fast');
			jQuery(this).removeClass('active');
		}
	);
});


/* Right Now ticker */
Event.observe(window,"load",function(){
	
    var container = $$('.activity-flashes .activities')[0];
	var items = $$('.activity-flashes .activities li');
    var comments = $$('.activity-flashes .activities li label');
    var images = $$('.activity-flashes .activities li a img');

	var flashes = items.length; 

    // hide everything but the first item
    items.each(function(item,count){
        if(count>0)
        {
            item.hide();
        }
    });

    // hide all the images
    images.each(function(image,count){
        image.hide();
    });
    
    // set the comments to display:inline (normally block on the dash & profile)
    comments.each(function(comment,count){
            comment.setStyle({
                display: 'inline'
            });
    });
    
    container.show();
    
	function flash()
	{
		items.each(function(item,count){
		
			if(item.visible()){
				
				Effect.Fade(item.identify(),{
					delay:0.0,
					from:1.0,
					to:0.0,
					duration:0.4,
					afterFinish:function(){
					
						Effect.Appear((count+1==flashes)?items[0].identify():item.next().identify(),{
							delay:0.0,
							from:0.0,
							to:1.0,
							duration:0.4
						});
					}
				});
				throw $break;
			}
					
		});	
	}
	
	new PeriodicalExecuter(flash, 6);
	
});