function rendSelectSensible() {
//    document.getElementById("type").onchange = afficheCacheInput;
    document.getElementById("siret").style.display = "none";
    document.getElementById("labelsiret").style.display = "none";
    document.getElementById("societe").style.display = "none";
    document.getElementById("labelsociete").style.display = "none";
}
function afficheCacheInput() {
//    document.getElementById("type").onchange = afficheCacheInput;
//    if ( document.getElementById("type").value == "Professionnel" ) {
        document.getElementById("siret").style.display = "inline";
		document.getElementById("labelsiret").style.display = "inline";
        document.getElementById("societe").style.display = "inline";
		document.getElementById("labelsociete").style.display = "inline";
/*    } else {
        document.getElementById("siret").style.display = "none";
		document.getElementById("labelsiret").style.display = "none";
    	document.getElementById("societe").style.display = "none";
    	document.getElementById("labelsociete").style.display = "none";
    }
*/
}
//window.onload = rendSelectSensible;

function verifcontact(){
	error = 0;
	v = document.formcontact.nom;
	v.style.backgroundColor = "";
	if (v.value == "")
		{
			error = error + 1;
			v.style.backgroundColor = "EDE652";
		}
	p = document.formcontact.prenom;
	p.style.backgroundColor = "";
	if (p.value == "")
		{
			error = error + 1;
			p.style.backgroundColor = "EDE652";
		}
		
	s = document.formcontact.societe;
	s.style.backgroundColor = "";
	if (s.value == "")
		{
			error = error + 1;
			s.style.backgroundColor = "EDE652";
		}
	
	t = document.formcontact.telephone;
	t.style.backgroundColor = "";
	if (t.value == "")
		{
			error = error + 1;
			t.style.backgroundColor = "EDE652";
		}
	e = document.formcontact.email;
	e.style.backgroundColor = "";
	if (e.value == "")
		{
			error = error + 1;
			e.style.backgroundColor = "EDE652";
		}	
	c = document.formcontact.commentaire;
	c.style.backgroundColor = "";
	if (c.value == "")
		{
			error = error + 1;
			c.style.backgroundColor = "EDE652";
		}
	s = document.formcontact.codepostal;
	s.style.backgroundColor = "";
	if (s.value == "")
		{
			error = error + 1;
			s.style.backgroundColor = "EDE652";
		}
	
	s = document.formcontact.ville;
	s.style.backgroundColor = "";
	if (s.value == "")
		{
			error = error + 1;
			s.style.backgroundColor = "EDE652";
		}	
		
	if (error != 0)
		{
			alert("Veuillez remplir les champs obligatoires !")
			return false;
		}
	else{
			return true;
		}
}

function verifreferencement(){
	error = 0;
	v = document.formcontact.nom;
	v.style.backgroundColor = "";
	if (v.value == "")
		{
			error = error + 1;
			v.style.backgroundColor = "EDE652";
		}
	p = document.formcontact.prenom;
	p.style.backgroundColor = "";
	if (p.value == "")
		{
			error = error + 1;
			p.style.backgroundColor = "EDE652";
		}
		
	s = document.formcontact.societe;
	s.style.backgroundColor = "";
	if (s.value == "")
		{
			error = error + 1;
			s.style.backgroundColor = "EDE652";
		}
	
	t = document.formcontact.tel;
	t.style.backgroundColor = "";
	if (t.value == "")
		{
			error = error + 1;
			t.style.backgroundColor = "EDE652";
		}
	e = document.formcontact.email;
	e.style.backgroundColor = "";
	if (e.value == "")
		{
			error = error + 1;
			e.style.backgroundColor = "EDE652";
		}	
	c = document.formcontact.numpersonnel;
	c.style.backgroundColor = "";
	if (c.value == "")
		{
			error = error + 1;
			c.style.backgroundColor = "EDE652";
		}
	s = document.formcontact.adresse;
	s.style.backgroundColor = "";
	if (s.value == "")
		{
			error = error + 1;
			s.style.backgroundColor = "EDE652";
		}
	
	s = document.formcontact.version;
	s.style.backgroundColor = "";
	if (s.value == "")
		{
			error = error + 1;
			s.style.backgroundColor = "EDE652";
		}
		
	if (error != 0)
		{
			alert("Veuillez remplir les champs obligatoires !")
			return false;
		}
	else{
			return true;
		}
}

function verifclient(){
	error = 0;
	soc = document.formclient.societe;
	soc.style.backgroundColor = "";
	if (soc.value == "")
		{
			error = error + 1;
			soc.style.backgroundColor = "EDE652";
		}
	v = document.formclient.nom;
	v.style.backgroundColor = "";
	if (v.value == "")
		{
			error = error + 1;
			v.style.backgroundColor = "EDE652";
		}
	p = document.formclient.prenom;
	p.style.backgroundColor = "";
	if (p.value == "")
		{
			error = error + 1;
			p.style.backgroundColor = "EDE652";
		}
	
	//if ( document.getElementById("type").value == "Professionnel" ) {	
		s = document.formclient.societe;
		s.style.backgroundColor = "";
		if (s.value == "")
			{
				error = error + 1;
				s.style.backgroundColor = "EDE652";
			}
	//	}
	adr = document.formclient.adresse;
	adr.style.backgroundColor = "";
	if (adr.value == "")
		{
			error = error + 1;
			adr.style.backgroundColor = "EDE652";
		}
	cp = document.formclient.codepostal;
	cp.style.backgroundColor = "";
	if (cp.value == "")
		{
			error = error + 1;
			cp.style.backgroundColor = "EDE652";
		}
	v = document.formclient.ville;
	v.style.backgroundColor = "";
	if (v.value == "")
		{
			error = error + 1;
			v.style.backgroundColor = "EDE652";
		}
	t = document.formclient.telephone;
	t.style.backgroundColor = "";
	if (t.value == "")
		{
			error = error + 1;
			t.style.backgroundColor = "EDE652";
		}
	e = document.formclient.email;
	e.style.backgroundColor = "";
	if ((e.value == "")||!verifmail(e.value))
		{
			error = error + 1;
			e.style.backgroundColor = "EDE652";
		}	
	//if ( document.getElementById("type").value == "Professionnel" ) {
		s = document.formclient.siret;
		s.style.backgroundColor = "";
		if (s.value == "")
			{
				error = error + 1;
				s.style.backgroundColor = "EDE652";
			}
	//}
	pwd = document.formclient.pwd;
		
	pwd.style.backgroundColor = "";
	if ((pwd.value == "")||!verifmdp(pwd.value))
		{
			error = error + 1;
			pwd.style.backgroundColor = "EDE652";
		}
	pwdb = document.formclient.pwdbis;
	
	pwdb.style.backgroundColor = "";
	if (pwdb.value == "")
		{
			error = error + 1;
			pwdb.style.backgroundColor = "EDE652";
		}
	if (pwdb.value != pwd.value)
		{
			error = error + 1;
			pwdb.style.backgroundColor = "EDE652";
		}
	ckcgv = document.formclient.cgv;
	ckcgv.style.backgroundColor = "";
	if (ckcgv.checked == false)
		{
			error = error + 1;
			ckcgv.style.backgroundColor = "EDE652";
		}
		
	if (error != 0)
		{
			alert("Veuillez remplir les champs obligatoires !")
			return false;
		}
	else{
			return true;
		}
}

function verifmail(mailteste)

{
			var email 	= mailteste;
   			var verif 	= /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]{2,}[.][a-zA-Z]{2,3}$/
   			if (verif.exec(email) == null)
			{
				//alert("Votre email est incorrecte");
				return false;
			}
			else
			{
				//alert("Votre email est correcte");
				return true;
			}
}

function verifmdp(motpasse)

{
	var mdp 	= motpasse;
	var verif 	= /^[a-zA-Z0-9]{4,}$/

	//if (mdp.length()>0)
		if (verif.exec(mdp) != null)
		{
			//alert("Votre mot de passe est correct.");
			return true;
		}

	alert("Votre mot de passe est incorrect (minimum 4 caractères, seuls les chiffres et les lettres sont acceptés).");
	return false;

}

function verifcgv(){
	error = 0;
	ckcgv = document.formpaiement.cgv;
	ckcgv.style.backgroundColor = "";
	if (ckcgv.checked == false)
		{
			error = error + 1;
			ckcgv.style.backgroundColor = "EDE652";
		}
		
	if (error != 0)
		{
			alert("Veuillez remplir les champs obligatoires !")
			return false;
		}
	else{
			return true;
		}
}

// ::::::::::::::: popup :::::::::::::::::::::::::::::::::::::
function affiche(id,plusx,plusy,image,tailleimg)
	{
	//Recherche du tableau du produit
	tab = document.getElementById("tab"+id);
	
	x = tab.offsetLeft;
	y = tab.offsetTop;

	d = document.getElementById("zoom");
	
	tableau = d.getElementsByTagName("table");
	//Recherche des lignes du tableau
	ligne = tableau[0].getElementsByTagName("tr");
	//Recherche des cellules de la ligne [0] -> pr la premier, [1] -> pr la secondes, etc
	cell = ligne[1].getElementsByTagName("td");
	//Recherche des images dans la cellule [0] -> pr la premier, [1] -> pr la secondes, etc
	img = cell[0].getElementsByTagName("img");
	
	
	d.style.top = parseInt(y) + parseInt(plusy);
	d.style.left = parseInt(x) + parseInt(plusx);	
	
	d.className = "affiche";

	d.style.visibility="visible";
	
	img[0].setAttribute("src", image);
	
	//Si l'onn'a pas définit de largeur à l'image
	if (parseInt(tailleimg) != 0)
		{
		img[0].style.width = tailleimg+"px";
		}
	else
		img[0].style.width=window.screen.width-80;
		
	}
	
function cacher()
	{
	z = document.getElementById("zoom");
	z.className = "cache";
	}

