$(document).ready(function(){
	_Messages	=	Messaging.getMessages();
	
	if (_Messages.length > 0) {
		$('div.message').css('display', 'none');
		window.setTimeout("Messaging_Message_FloaterShow()", 500);
	}
	
	ZebraTables();
	
	$('form.search #q').click(function(e) {
		
		if (!$(this).attr('restore') || $(this).attr('restore') == '') {
			$(this).attr('restore', $(this).val());
			$(this).val('');
		}
	});
	
	$('form.search #q').blur(function(e) {
		
		if ($(this).val() == '') {
			$(this).val($(this).attr('restore'));
			$(this).attr('restore', '');
		}
	});
});

function Messaging_Message_FloaterShow ( ) {
	
	if (_Message = _Messages.shift()) {
		_Message.display();
	}
	else {
		$('#messaging_contentlayer').remove();		
		$('#messaging_backlayer').fadeOut('fast');
		
		var body		=	$(document.getElementsByTagName('body')[0]);
		body.css('overflow', 'scroll');
	}		
}

function ZebraTables ( ) {

	$('table').each(function(e){
		
		var loop	=	0;
		
		$(this).find('tbody tr').removeClass('odd');
		$(this).find('tbody tr').removeClass('even');
		
		$(this).find('tbody tr').each(function(e) {
			var className	=	++loop % 2 == 0 ? 'even' : 'odd';
			
			$(this).addClass(className);
		});
	});
}
