app.lvalid = {

	attachEvents : function(){
		
		var t = app.lvalid;	
		
		
			
		app.events.submitform = this.form.event('submit', function(e){ 
			
				sb.events.stopAndPrevent(e);	
				
				var getter = new sb.ajax({				
					data : sb.forms.serialize(t.form),
					format : 'json',
					handler : function(data){	
						
						if(data.uid){					
														
							if(data.active == 0){
								t.tries++;							
								app.errlog.add({
									id : "login_err",
									message : "Sorry, your account has not been activated yet.  Please check your inbox " +
									"and activate your account.",
									targ : t.form.uname 
								});	
							}else{
								window.location = '../app/';
							}
												
						}else{								
							t.tries++;							
							app.errlog.add({
								id : "login_err",
								message : "Sorry, some of your credentials don't check out. Please try logging in again.",
								targ : t.form.uname 
							});	
						}
						
					}
				}).fetch();	
		});		
	},
	
	tries : 0,
	
	init : function(){
			
		if(app.lform){			
			this.form = app.lform;
			this.events = app.events;
			this.attachEvents();
		}
		
	}
};