$(document).ready(function () {

	$('#form2_submit').click(function() {
		var is_ok = 1;
		
		if ($('#nom_contact').val() == "" )
		{
			is_ok = 0;
			$('#nom_contact').parents('tr').find('.error').empty().append("champ obligatoire");
		}
		else
		{
			$('#nom_contact').parents('tr').find('.error').empty();
		}
		
		if ($('#prenom_contact').val() == "" )
		{
			is_ok = 0;
			$('#prenom_contact').parents('tr').find('.error').empty().append("champ obligatoire");
		}
		else
		{
			$('#prenom_contact').parents('tr').find('.error').empty();
		}
		
		if ($('#email_contact').val() == "" )
		{
			is_ok = 0;
			$('#email_contact').parents('tr').find('.error').empty().append("champ obligatoire");
		}		
		else
		{
			$('#email_contact').parents('tr').find('.error').empty();
		}
		
		if ($('#mdp_contact').val() == "" )
		{
			is_ok = 0;
			$('#mdp_contact').parents('tr').find('.error').empty().append("champ obligatoire");
		}
		else
		{
			$('#mdp_contact').parents('tr').find('.error').empty();
		}	
		
		if ($('#confirmation_email_contact').val() != $('#email_contact').val())
		{
			is_ok = 0;
			$('#confirmation_email_contact').parents('tr').find('.error').empty().append("doit avoir la meme valeur que le champ precedent");
		}
		else
		{
			$('#confirmation_email_contact').parents('tr').find('.error').empty();
		}
		
		if ($('#confirmation_mdp_contact').val() != $('#mdp_contact').val())
		{
			is_ok = 0;
			$('#confirmation_mdp_contact').parents('tr').find('.error').empty().append("doit avoir la meme valeur que le champ precedent");
		}		
		else
		{
			$('#confirmation_mdp_contact').parents('tr').find('.error').empty();
		}
		
		if ( $('#conditions').is(':checked') == 'false' )
		{
			alert("Les conditions g\351n\351rales doivent \352tre valid\351es");
			is_ok = 0;
		}
		else if ( $('#contrat').is(':checked')  == 'false' )
		{
			alert("La demande de contrat doit \352tre valid\351e");
			is_ok = 0;
		}				
		
		if(is_ok == 0)
		{
			return false;
		}
			
	});
	
	$('#form2bis_submit').click(function() {
		if ($('input[name="type_paiement"]:checked').attr("value") == "cheque" )
		{
			$("#form_editeur").attr('action',"/");
			alert("Votre demande a ete prise en compte");
		}
	});

});
