/**
 * @author Wrzasq <wrzasq@gmail.com>
 * @copyright 2008 - 2009 (C) by Wrzasq
 * @package WrzasqCMF
 * @version 0.0.1
 */

// initializes JavaScript interface
document.observe("dom:loaded", function() {
	$("loginForm").observe("submit", function(event) {
    	// background login
		new Ajax.Request("/ajax.php", {
			parameters: $H( this.serialize(true) ).merge( {
				action: "Logon"
			} ),
			onSuccess: function(transport) {
			    if( displayFirstMessage(transport.responseJSON) )
			    {
			        top.location = "/account";
			    }

				this.enable();
			}.bindAsEventListener(this)
		} );

    	this.disable();
    	
    	event.stop();
    } );
} );
