var register = {
	init : function()
	{
		
		$(window).bind('load', function() {
			$("#tform").validate({
			   rules: {
			     checkbox: {
				   required: true	
				 },
				 timie: {
				   required: true
				 },
				 temail: {
			       required: true,
			       email: true
			     }
			   },
			   messages: {
			     checkbox: {
				   required: "Pole wyrażenia zgody na newsletter jest obowiązkowe<br />"
				 },
			     timie: {
				   required: "Podaj swóje imię, bez polskich znaków<br />"
				 },				 
				 temail: {
			       required: "Podaj swój adres email<br />",
			       email: "Niepoprawny adres email<br />"
			     }
			   },
			   errorLabelContainer: $("#terr"),
			   submitHandler: function(form) {
					$.post('http://'+location.host+'/code/register1/mail.php', {t: $('#checkbox').val(), p: $('#timie').val(), m: $('#temail').val(), i: $('#tinfo').val()}, trainingConfirm);
		       }
			});
			
			$('#checkbox').click( function(event) {
	 			$('#tnfo').html('');
			});

			$('#checkbox').keydown( function(event) {
	 			$('#tnfo').html('');
			});
			
			
			$('#timie').keydown( function(event) {
	 			$('#tnfo').html('');
			});
			
			$('#temail').keydown( function(event) {
	 			$('#tnfo').html('');
			});			

			$('#tinfo').keydown( function(event) {
	 			$('#tnfo').html('');
			});		
			
			$('#tsend').click( function(event) {
	 			$('#tnfo').html('');
			});

			$('#tsend').keydown( function(event) {
	 			$('#tnfo').html('');
			});
				
		});			
	}
};

function trainingConfirm(data, textStatus) {
	if (textStatus == 'success')
	{
		$('#tnfo').html('Dziękujemy za rejestrację. Na twój adres email został wysłany link aktywacyjny.');
	}
}
