//----------------------------------------------------------------------------------------

// Author : Guillaume Quimper, Influenza marketing http://www.influenza.ca
// Version 1.0
// Created: July 2011

//----------------------------------------------------------------------------------------

//------------------------------------------------------------------------
// Form Validation
//------------------------------------------------------------------------

	//Add Regex for Phone
	$.validator.addMethod("phone", function (value, el, params) {
    	return this.optional(el) || /^[01]?[- .]?\(?[2-9]\d{2}\)?[- .]?\d{3}[- .]?\d{4}$/.test(value);
    }, "Le numéro de téléphone est invalide");
    
	//Add Regex for Postal Code
	jQuery.validator.addMethod('postalCode', function (value) {
	return /^([ABCEGHJKLMNPRSTVXYabceghjklmnprstvxy]\d[ABCEGHJKLMNPRSTVWXYZabceghjklmnprstvwxyz])\ {0,1}(\d[ABCEGHJKLMNPRSTVWXYZabceghjklmnprstwvxyz]\d)$/.test(value);
	}, 'Le code poste est invalide.');


$(function() {
	
	
	var validator = $("#newsletterOptIn form").bind("invalid-form.validate", function() {
		
	}).validate({
		messages: {
			FormValue_CustomField6: "Nom obligatoire",
			FormValue_Email: {
				required: "Courriel obligatoire",
				email: "Courriel invalide"
			}
		},
   		//errorContainer: container,
      	/*submitHandler: function(form) {
              jQuery(form).ajaxSubmit({
                  success: function(data) {
                  	var message = $(data).find('#message');
                  	$('#newsletter').remove();
                  	$('#newsletterOptIn').append(message);
                  }
              });
        }*/
	});
	
	

});

$(function() {
	
	
	var validator = $("#contactForm form").bind("invalid-form.validate", function() {
		
	}).validate({
		messages: {
			nom: "Nom obligatoire",
			courriel: {
				required: "Courriel obligatoire",
				email: "Courriel invalide"
			},
			message: "Message obligatoire"
		}/*,
   		//errorContainer: container,
      	submitHandler: function(form) {
              jQuery(form).ajaxSubmit({
              target: "#signupForm form",
                  success: function() {
                  		var confirmationMessage = '<h3>Votre compte est créé!</h3><p>Votre compte est maintenant activé. Nous vous avons envoyé un courriel de confirmation qui contient votre mot de passe. Il ne vous reste plus qu’à entrer des NIP!</p><a href="pages/pin.php?locale=fr_FR" class="getStarted">Commencer</a>';                  		
                  		$("#signupForm").html("<div id=\"confirmationMessage\" class=\"en\"></div>");
                  		$("#confirmationMessage").html(confirmationMessage).hide();
                  		Cufon.refresh();
                  		$("#confirmationMessage").fadeIn(800);
                  		$("#getStarted").click(function(){
                  			window.location = "pages/pin.php";
                  		});
                  }
              });
        }*/
	});
	
	

});





