/** Logged out Layout JS **/

$(document).ready( function() {
	YouFoot.init();
});

YouFoot.loggedOutLayout = {
	init : function () {
//		$('.header-top').corner('br bl');
	}
};
/**
 * 
 */
YouFoot.loginSidebarValidation = {
	init : function() {
		var self = this;
		//jQuery.validator.addMethod('');
	/*
		$("#SidebarLogin").validate({
			rules: {
				"data[User][email]": {
						required: true,
						minlength: 2
				},
				"data[User][passwd]": {
					required: true,
					remote: '/users/login'
				}
			},
			submitHandler: function(form) {
				return false;
			},
			debug: true
		});

		$("#SidebarLogin input[submit]").ajaxSubmit({
			url : '/users/login',
			//beforeSubmit : that.beforeSubmit,
			dataType : 'json'
			//success : that.doSuccess.bind(that)
		});
*/
		$('#SidebarLogin').submit(function() { 
			var $this = $(this);
			$this.ajaxSubmit({
				url:  window.basePath + 'users/login.json',
				dataType: 'json',
				success: self.handleLogin.bind(self)
			});
			return false;
		});
	},
	
	handleLogin : function(responseObj) {
		if (responseObj.status == 'error' || responseObj.data.location == undefined) {
			alert(responseObj.data.message);
			return false;
		}
		document.location = responseObj.data.location;
	}
};
