/*
------------------------------------------------------------------------------*/
var preloaded = new Array();
function preload_images()
{
	for (var i = 0 ; i < arguments.length ; i++)
	{
		preloaded[i] = document.createElement("img");
		preloaded[i].setAttribute("src",arguments[i]);
		preloaded[i].setAttribute("alt","");
	};
};
preload_images(
	"./img/menu/inscrivez-vous_on.png",
	"./img/menu/inscrivez-vous_off.png",
	"./img/menu/nos_produits_on.png",
	"./img/menu/nos_produits_off.png",
	"./img/menu/conditions_legales_on.png",
	"./img/menu/conditions_legales_off.png"
);
/*
------------------------------------------------------------------------------*/
var champ_obligatoire = '<small>Ce champ est obligatoire.</small>';
var champ_mal_remplit = '<small>Ce champ est mal remplit.</small>';
var erreur_confirmation_mdp = '<small>Les mots de passe doivent être identiques.</small>';
var erreur_confirmation_email = '<small>Les adresses email doivent être identiques.</small>';
var obligatoire = '&nbsp;<sup>*</sup>';
/*
------------------------------------------------------------------------------*/
$(function(){
	if ($("#inscription form").length)
	{
		$("#inscription form").validate({
			rules:{
				identifiant:"required",
				mot_de_passe:"required",
				mot_de_passe_confirmer: {
					equalTo: "#mot_de_passe"
				},
				profession:"required",
				domaine_d_activite:"required",
				nom:"required",
				prenom:"required",
				societe:"required",
				adresse:"required",
				code_postal:"required",
				pays:"required",
				telephone:"required",
				e_mail:{
					required:true,
					email:true
				},
				e_mail_confirmer: {
					equalTo: "#e_mail"
				}
			},
			messages:{
				identifiant:champ_obligatoire,
				mot_de_passe:champ_obligatoire,
				mot_de_passe_confirmer:erreur_confirmation_mdp,
				profession:champ_obligatoire,
				domaine_d_activite:champ_obligatoire,
				nom:champ_obligatoire,
				prenom:champ_obligatoire,
				societe:champ_obligatoire,
				adresse:champ_obligatoire,
				code_postal:champ_obligatoire,
				pays:champ_obligatoire,
				telephone:champ_obligatoire,
				e_mail:{
					required:champ_obligatoire,
					email:champ_mal_remplit
				},
				e_mail_confirmer: erreur_confirmation_email
			}
		});
	}
	$("input.text").each(function(){
		var tmp = $(this).attr("title");
		$(this).val(tmp);
		$(this).focus(function(){
			if($(this).val() == tmp)
				$(this).val("");
		});
		$(this).blur(function(){
			if($(this).val() == "")
				$(this).val(tmp);
		});
	});
/*
------------------------------------------------------------------------------*/
	$("a.roll").hover(function(){
		if($(this).children("img").length && !$(this).parents("strong").length)
			$(this).children().attr("src",$(this).children().attr("src").replace("_off","_on"));
	},function(){
		if($(this).children("img").length && !$(this).parents("strong").length)
			$(this).children().attr("src",$(this).children().attr("src").replace("_on","_off"));
	});
	$("a.roll").focus(function(){
		if($(this).children("img").length && !$(this).parents("strong").length)
			$(this).children().attr("src",$(this).children().attr("src").replace("_off","_on"));
	});
	$("a.roll").blur(function(){
		if($(this).children("img").length && !$(this).parents("strong").length)
			$(this).children().attr("src",$(this).children().attr("src").replace("_on","_off"));
	});
});

// verif que l'user a bien coché "installateur sinon alerte js + focus sur le champ
function check_installateur() {
	if (document.getElementById('installateur').checked != true) {
		document.getElementById('installateur').focus();
		alert('Seuls les installateurs peuvent bénéficier de la garantie 5 ans Salmson');
		return false;
	}
	return true;
}
/* EOF
------------------------------------------------------------------------------*/
