$(function (){
	var f = new FormJS('auth_form');
	f.setAllMessages(false);
	
	var submit = $("#submit");
	$("#submit")
	.click(function(){
		f.setIndicator($(this));
		f.registerCallback(function() {
			submit.unbind('click');
			submit.click();
		});
		f.validate('auth');
		return false;
	});
	
	$('.auth input.data').each(function(){
		if ($(this).val()) $(this).css('background-position', '0 -36px');
	});
	$('.auth input.data').focus(function(){
		$(this).css('background-position', '0 -36px');
	});
	$('.auth input#login').change(function(){
		var pass = $(".auth input#password");
		if (pass.val()) pass.css('background-position', '0 -36px');
	});
	$('.auth input.data').blur(function(){
		if (!$(this).val()) $(this).removeAttr('style');
	});
	$('#register').click(function(){
		location.href = '/registration/';
	});
});

