$(document).ready(function(){   
		
	$("#send").click(function () {
		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
		var emailToVal = $("#email").val();
		var nameVal = $("#name").val();
		var subjectVal = $("#subject").val();
		var messageVal = $("#message").val();
		var copyVal = $("#copy").attr("checked");
		if(!emailReg.test(emailToVal) || emailToVal=='' || nameVal=='' || subjectVal=='' || messageVal=='') {
			if(!emailReg.test(emailToVal) || emailToVal==''){
				$("#contact-email").replaceWith('<label id="contact-email" style="color:#F00;">' + getText('contact_email2') + '</label>');
			}else{
				$("#contact-email").replaceWith('<label id="contact-email" style="color:#000;">' + getText('contact_email') + '</label>');
			}
			if(nameVal==''){
				$("#contact-name").replaceWith('<label id="contact-name" style="color:#F00;">' + getText('contact_name2') + '</label>');
			}else{
				$("#contact-name").replaceWith('<label id="contact-name" style="color:#000;">' + getText('contact_name') + '</label>');
			}
			if(subjectVal==''){
				$("#contact-subject").replaceWith('<label id="contact-subject" style="color:#F00;">' + getText('contact_subject2') + '</label>');
			}else{
				$("#contact-subject").replaceWith('<label id="contact-subject" style="color:#000;">' + getText('contact_subject') + '</label>');
			}
			if(messageVal==''){
				$("#contact-message").replaceWith('<label id="contact-message" style="color:#F00;">' + getText('contact_message2') + '</label>');
			}else{
				$("#contact-message").replaceWith('<label id="contact-message" style="color:#000;">' + getText('contact_message') + '</label>');
			}
		}else{
			$("#contact-success").replaceWith('<p style="color:#0B0; font-weight:bold;">Veuillez patientez...</p>');
			$("#send").remove();
			$("#copy").remove();
			$("#contact-copy").remove();
			
			$.post(
				   baseUrl,
				   {
					   ajax: 'contact-us',
					   name: nameVal,
					   email: emailToVal,
					   subject: subjectVal,
					   message: messageVal,
					   copy: copyVal
					},
					
					function(data){
						
						if(data.success == 1)
						{
							$("#form1").replaceWith('<p>' + getText('textNotice') + '</p><div class="sent-info"><label>' + getText('textSuccessName')
								+'</label><p class="sent-info" >'+data.name
								+'</p><label>' + getText('textSuccessEmail') + '</label><p class="sent-info" >' + data.email
								+'</p><label>' + getText('textSuccessSubject') + '</label><p class="sent-info" >' + subjectVal
								+'</p><label>' + getText('textSuccessMessage') + '</label><p class="sent-info" >' + data.message
								+'</p></div><p style="color:#0B0; font-weight:bold;">' + getText('textSuccess') + '</p>');
						}
						else
						{
							$("#contact-success").replaceWith('<p style="color:#F00;>' + getText('textError') + '</p>');
						}
					},
					'json'
				);
		}
	});	
});