function changeText( object, text, color )
{
	object.fadeOut( "fast", function()
	{
		object.css( "color", color );
		object.text( text );
	} ).fadeIn( "fast" );
}

$(document).ready
(
	function()
	{
		$("#button").click
		(
			function()
			{
				var login = $('#login').attr( 'value' );
				var password = $('#pass').attr( 'value' );
				var msg = $('#message');

				if ( login.length == 0 )
				{
					changeText( msg,'Proszę podać login.', 'red' );
					return false;
				}
				if ( password.length == 0 )
				{
					changeText( msg, 'Proszę podać hasło.', 'red' );
					return;
				} 
				
				changeText( msg, 'Logowanie...', 'green' );

				$.post( 'seoraporty.php', "login=" + login + "&password=" + password, function( data )
				{
					switch( $( 'status', data ).text() )
					{
						case '1':
							changeText( msg, 'Zalogowano w nowym oknie.', 'green' );
							$('#seoraporty').submit();
							break;
						case '2':
							changeText( msg, 'Konto zablokowane z powodu zbyt wielu nieudanych prób logowania.', 'red' );
							break;
						default:
							changeText( msg, 'Błędne dane uwierzytelniające!', 'red' );
							break;
					
					}
				}, "xml" );
			}
		)
	}
)

