$(function() {
	$('#login').validate({
		rules: { 
			lNumber: { required: true, rangeLength: [12, 12] },
			lPassword: { required: true }
    },
		showErrors: function() { }
	});					 
					 
	$('#registration').validate({
		rules: { 
			number: { required: true, rangeLength: [12, 12] },
			password: { required: true },
			passwordConf: { required: true, equalTo: '#password' },
			objectType: { required: true },
			direction: { required: true },
			parts_min: { required: true },
			parts_max: { required: true },			
			budget: { required: true, digits: true },
			duration: { required: true },
			disclaimer: { required: true }
    },
		showErrors: function() { }
	});
	
	$('#final').validate({
		rules: { 
			confId: { required: true, rangeLength: [4, 4] }
    },
		showErrors: function() { }
	});	
	
	$('#lost').validate({
		rules: { 
			pNumber: { required: true, rangeLength: [12, 12] }
    },
		showErrors: function() { }
	});		
	
	$('#update').validate({
		rules: { 
			password: { required: true },
			passwordConf: { required: true, equalTo: '#password' },
			objectType: { required: true },
			direction: { required: true },
			parts_min: { required: true },
			parts_max: { required: true },
			budget: { required: true, digits: true },
			duration: { required: true }
    },
		showErrors: function() { }
	});	
	
	$('.form input[type="text"], .form input[type="password"], .form select').focus(function() {
		$(this).parent().addClass('focus');
	});
	$('.form input[type="text"], .form input[type="password"], .form select').blur(function() {
		$(this).parent().removeClass('focus');
	});	
	
	$('#lNumber, #number, #pNumber').mask('+99999999999');
	
	$('body').prepend('<div class="jqmWindow" id="modal"></div>');
	$('#modal').jqm({
		modal: false,
		ajax: '@href',
		onLoad: function(hash) {
			if (hash.w.height() > $(window).height()) {
				$(hash.w).height($(window).height()-60).css('overflow', 'auto');
			}	
		}		
	});
	
	$('#switchLost').click(function() {
		$('#lost').slideToggle();
		return false;
	});
});
