$(document).ready(function(){  
	
	if ($('#flashMessage').length > 0 ) {
		$('#flashMessage').animate({opacity: 1.0}, 3000).fadeOut();
	}
	
	// Moblog sort order form
	if($('#MoblogIndexForm').length) {
		$('#MoblogIndexForm div.submit').hide();
		$('.refresh .animated').hide();	
		$('#MoblogOrder').change(function() {
			$('.refresh .static').hide();
			$('.refresh .animated').show();
			var url = '/moblogs/index';
			switch ($('#MoblogOrder option:selected').val()) {
				case 'modified':
					url += '/page:1/sort:modified/direction:desc/';
					break;				
				case 'id':
					url += '/page:1/sort:id/direction:desc/';
					break;
				case 'commented':
					url += '/page:1/sort:commented/direction:desc/';
					break;
				case 'moblog_comment_count':
					url += '/page:1/sort:moblog_comment_count/direction:desc/';
					break;
				case 'rand()':
					url += '/page:1/order:rand()/';
					break;
				default : url += '/page:1/sort:modified/direction:desc/';
			}
			window.location = url;
		});
		$('.refresh').click(function() {
			$('.refresh .static').hide();
			$('.refresh .animated').show();
		});
	}
	
	if($('.comment').length) {
		$('.comment-functions').hide();
		$('.comment').bind('mouseenter', function () {
			$('.comment-functions',this).fadeIn('200');
		});
		$('.comment').bind('mouseleave', function () {
			$('.comment-functions',this).fadeOut('400');
		});
	
	};		
	
});

