(function()
{
	
	LOGIN = ({

		settings:{formid:null, errors:new Array()},
		
		processLogin: function()
		{	
			LOGIN.settings.formid = jQuery("#login_form");
			
			LOGIN.validateProcessLogin();
			
			if(LOGIN.settings.errors.length == 0)
			{
				/*
				jQuery.ajax({
					type	:LOGIN.settings.formid.attr("method"),
					url		:LOGIN.settings.formid.attr("action"),
					data	:LOGIN.settings.formid.serialize(),
					dataType: 'json',					
					success: function(rs)
					{
						if(rs.error=="false")
						{
							location.href = '/';
						}
						else
						{
							GSM_LOADER.hideWithMsg(rs.message);
						}
					},
					
					error: function(rs)
					{
						GSM_LOADER.hideWithMsg("Unable to process your request.");
					}							
				});	*/
				LOGIN.settings.formid.submit();
			}
			else
			{
				var str = "Following fields have invalid values.<br><br>";
				str +=  LOGIN.settings.errors.join("<br>");
				GSM_LOADER.hideWithMsg(str);				
			}
		},
		
	
		validateProcessLogin: function()
		{
			GSM_LOADER.show("Please wait...");
			
			LOGIN.settings.errors = new Array();
			
			if(jQuery.trim(jQuery("#email_address", LOGIN.settings.formid).val())=='')
			{
				LOGIN.settings.errors.push('- Email Address');	
			}
			
			if(jQuery.trim(jQuery("#password", LOGIN.settings.formid).val())=='')
			{
				LOGIN.settings.errors.push('- Password');	
			}						
		}
	
	});	

})(jQuery);


jQuery(document).ready(function()
{
	jQuery("#password").bind("keyup", function(e)
	{
		if(e.keyCode == 13 && jQuery.trim(jQuery("#password").val())!='')
		{
			LOGIN.processLogin();
		}
	})
});
