function ImageLoadFailed() {
	window.event.srcElement.style.display = "None";
}

function afficheForm(id){
	var a = document.getElementById("montant"+id);
	var m = document.getElementById("bOrdre"+id);
	  
	if (a.style.display == "none"){
		a.style.display = "block";
		m.style.display = "block";
	} else {
		a.style.display = "none";
		m.style.display = "none";
	}
	
	return false;
}

function sendNavForm(){
	var form = document.getElementById("nav");
	form.submit();
}

function afficheImage(source){
	var div = document.getElementById("divZoom");
	var img = document.getElementById("imageZoom");
	if (div.style.display == "none"){
		//affichage de l'image
		img.src = source;
		div.style.display = "block";
		img.onload = function(){
			if (img.width < 410){
				img.width = 410;
			}			
			//div.style.display = "block";
		}
	} else {
		//on cache l'image
		div.style.display = "none";
	}	
	return false;
}

function validate(){
	var msg="";
	
	with(document.form1){
		if (nom.value == "") msg += "Le champ Nom est obligatoire\n";
		if (prenom.value == "")	msg += "Le champ Prenom est obligatoire\n";
		if (tel.value == "") msg += "Le champ Téléphone est obligatoire\n";
		if (adresse.value == "") msg += "Le champ Adresse est obligatoire\n";
		if (adresse_banque.value == "") msg += "Le champ Nom et adresse de votre banque est obligatoire\n";
		if (responsable.value == "") msg += "Le champ Nom du responsable de votre compte est obligatoire\n";
		if (responsable_tel.value == "") msg += "Le champ Téléphone de votre banque est obligatoire\n";
		if (banque.value == "") msg += "Le champ Code banque est obligatoire\n";
		if (guichet.value == "") msg += "Le champ Code guichet est obligatoire\n";
		if (compte.value == "") msg += "Le champ Numéro de compte est obligatoire\n";
		if (clef.value == "") msg += "Le champ Clé rib est obligatoire\n";
		
		if (mail.value == ""){
			msg += "Le champ email est obligatoire\n";
		} else {
			if (!echeck(mail.value)){
				msg += "Mail invalide\n";
			}
		}
		if (!cgv.checked){
			msg += "Vous devez accepter les conditions de vente\n";
		}
	}
	if (msg.length> 0){
		alert(msg);
	} else {
		//envoi du formulaire
		//alert("le formulaire va etre envoyé");
		document.form1.submit();
	}
}

function echeck(str) {
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
			
	if (str.indexOf(at)==-1) return false;
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
	if (str.indexOf(at,(lat+1))!=-1) return false;
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
	if (str.indexOf(dot,(lat+2))==-1) return false;
	if (str.indexOf(" ")!=-1) return false;
	 		
	return true;
}


