var programbook = {
	register:function() {
		var inputs = $('#register-form :input');
		var submit=1;
	    inputs.each(function() {
	    	if (this.type == 'text' || this.type == 'password') {
		    	if ($(this).val().length) {
		    	  	document.getElementById(this.id+'_error').style.display='none';
		    	}
		    	else {
		    		document.getElementById(this.id+'_error').style.display='';
		    		submit = 0;
		    	}
	    	}
	    });
	   	
	    if (submit) {
	    	document.getElementById('register-form').submit();
	    }
	},
	login:function() {
		var submit = 1;
		var app_username = document.getElementById('app_login').value;
		var app_password = document.getElementById('app_password').value;
		
		if (app_username.length > 0) {
			if (validate(app_username)) {
				document.getElementById('app_login_error').style.display='';
				submit = 0;
			}
			else {
				document.getElementById('app_login_error').style.display='none';
			}
		}
		else {
			document.getElementById('app_login_error').style.display='none';
		}
		if (app_password.length == 0 || app_password.length > 10) {
			document.getElementById('app_password_error').style.display='';
			submit =0;
		}
		else {
			document.getElementById('app_password_error').style.display='none';
		}
		if (submit) {
			document.getElementById('login-form').submit();
		}
	},
	status:function() {
		document.getElementById('app_login_fail').style.display='';
	}
}
