
(jQuery.noConflict())(function($) {
							   						   
	//Image swap
	$("#imgEn").hover(function() {
		$(this).attr("src","images/bulle-english-over.jpg");
	}, function() {
		$(this).attr("src","images/bulle-english.jpg");
	});  
	
	$("#imgAccueil").hover(function() {
		$(this).attr("src","images/bulle-accueil-over.jpg");
	}, function() {
		$(this).attr("src","images/bulle-accueil.jpg");
	}); 
		
	$("#imgContact").hover(function() {
		$(this).attr("src","images/bulle-contact-over.jpg");
	}, function() {
		$(this).attr("src","images/bulle-contact.jpg");
	}); 
	
	$("a#controle").fancybox({
		'titleShow'		: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'fade',
		'type'			: 'iframe'
	});
	
	$("a[rel=group]").fancybox({
		'titleShow'		: false,
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'fade'
	});
	
	$("#form-interesse").validate({
		ignoreTitle : true,
        rules: {
			prenom: "required", 
            nom: "required", 
            telephone: "required",
           	courriel: {
				required : true,
				email: true
			},
			ville: "required",
			province: "required",
			code_postal: "required"
        }, 
        messages: {
			prenom: {
        		required: 
        			function(){
        				$("#prenom").css({backgroundImage: 'url(images/field-error.png)'});
        				$("#prenom").attr("title", "Champ requis");
        			}
        	},
            nom: {
        		required: 
        			function(){
        				$("#nom").css({backgroundImage: 'url(images/field-error.png)'});
        				$("#nom").attr("title", "Champ requis");
        			}
        	}, 
            telephone: {
        		required: 
        			function(){
        				$("#telephone").css({backgroundImage: 'url(images/field_small-error.png)'});
        				$("#telephone").attr("title", "Champ requis");
        			}
        	},
           	courriel: {
                required:         			
                	function(){
						$("#courriel").css({backgroundImage: 'url(images/field_large-error.png)'});
						$("#courriel").attr("title", "Champ requis");
					},
                email: 
                	function(){
						$("#courriel").css({backgroundImage: 'url(images/field_large-error.png)'});
						$("#courriel").attr("title", "Votre courriel doit avoir ce format nom@domaine.com");
					}
            },
			ville: {
        		required: 
        			function(){
        				$("#ville").css({backgroundImage: 'url(images/field-error.png)'});
        				$("#ville").attr("title", "Champ requis");
        			}
        	},
			province: {
        		required: 
        			function(){
        				$("#province").css({backgroundImage: 'url(images/field-error.png)'});
        				$("#province").attr("title", "Champ requis");
        			}
        	},
			code_postal: {
        		required: 
        			function(){
        				$("#code_postal").css({backgroundImage: 'url(images/field_small-error.png)'});
        				$("#code_postal").attr("title", "Champ requis");
        			},
        		postalCode:
        			function(){
        				$("#code_postal").css({backgroundImage: 'url(images/field_small-error.png)'});
        				$("#code_postal").attr("title", "Champ requis");
        			}
        	}
        },
        success: 
        	function(label) {
        		var curID = label.attr('for');
        		$("#form-interesse input").each(function(){
        			if($(this).attr('id') == curID)
        			{
        				if($(this).hasClass("valid"))
        				{
	        				switch(curID)
	        				{
	        					case "telephone":
	        					case "code_postal":
	        						$(this).css({backgroundImage: 'url(images/field_small-valid.png)'});
	        						break;
	        					case "courriel":
	        						$(this).css({backgroundImage: 'url(images/field_large-valid.png)'});
	        						break;
	        					default:
	        						$(this).css({backgroundImage: 'url(images/field-valid.png)'});
	        						break;
	        				}
	        				$(this).attr("title", "");
        				}
        				else if(!$(this).hasClass("error"))
        				{
        					switch(curID)
	        				{
	        					case "telephone":
	        					case "code_postal":
	        						$(this).css({backgroundImage: 'url(images/field_small.png)'});
	        						break;
	        					case "courriel":
	        						$(this).css({backgroundImage: 'url(images/field_large.png)'});
	        						break;
	        					default:
	        						$(this).css({backgroundImage: 'url(images/field.png)'});
	        						break;
	        				}
        					$(this).attr("title", "");
        				}
        			}
        		});
        	}
    });
	
});




