
var docObj = (document.all) ? "document.all." : "document."; 
var OldColor; 
var OldBorderColor; 

function overCouleurTR(rowNum){
	thisRow = document.getElementById(rowNum);
	OldColor = thisRow.className;
	thisRow.className = "menu_haut_over";
}

function overCouleurTROrange(rowNum){
	thisRow = document.getElementById(rowNum);
	OldColor = thisRow.className;
	thisRow.className = "menu_haut_over";
}

function outCouleurTR(rowNum){
	thisRow = document.getElementById(rowNum);
	thisRow.className = OldColor;
}



var docObj = (document.all) ? "document.all." : "document."; 
var OldColor; 
var OldBorderColor;

function activ_champ(rowNum){
	thisRow = document.getElementById(rowNum);
	OldColor = thisRow.className;
	thisRow.className = "textfield_over";
}

function changement(rowNum){
	thisRow = document.getElementById(rowNum);
	thisRow.className = OldColor;
}

function activ_champ_txt(rowNum){
	thisRow = document.getElementById(rowNum);
	OldColor = thisRow.className;
	thisRow.className = "areatextfield_over";
}

function changement_txt(rowNum){
	thisRow = document.getElementById(rowNum);
	thisRow.className = OldColor;
}





function focus_champs(champ){
	if(champ=="login"){
		document.mon_compte.login.value="";
		document.mon_compte.login.focus();
	}else{
		document.mon_compte.pass.value="";
		document.mon_compte.pass.focus();
	}	
}

// -------------------------------------------------------------
// Verifier si les champs du bloc "mon compte" ne sont pas vide
// -------------------------------------------------------------

function verif_compte(num){
	var num;
	if (document.forms[num].login.value == "" || document.forms[num].login.value == "votre email") {
		alert("Veuillez bien remplir l'identifiant !");						
		document.forms[num].login.focus();
		return false;		
	}
	var login   = document.forms[num].login.value;
    var verif   = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,4}$/
    if (verif.exec(login) == null){
       	alert("Votre Identifiant est incorrect");
        document.forms[num].login.focus();	
		return false;			
    }
	if (document.forms[num].pass.value == "" || document.forms[num].pass.value == "pass") {
		alert("Veuillez bien remplir le mot de passe !");						
		document.forms[num].pass.focus();
		return false;		
	}
}

function recherche(choix){
	if(choix=='categorie' && document.form_rech.rech_rubrique.value!="null"){
		document.location.href=document.form_rech.rech_rubrique.value;
	}else if(choix=='fabricant' && document.form_rech.rech_rubrique.value!="null"){
		document.location.href=document.form_rech.rech_fabricant.value;
	}else if(choix=='categorie_top' && document.form_top.categorie_top.value!="null"){
		document.location.href=document.form_top.categorie_top.value;		
	}
}

// ------------------------------------------------------
// Ouverture de la fenetre pour le mot de passe de perdu
// ------------------------------------------------------

function new_window(){
	myWindow = window.open("pass_perdu.htm", "Preview", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=300,height=150,left=100,top=100");
}

// ------------------------------------------------------
// Ouverture de la fenetre pour le mot de passe de perdu
// ------------------------------------------------------

function imprime_article(url){
	myWindow = window.open(url, "Preview", "toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width='100%',height='100%',left=0,top=0");
}

// ------------------------------------------
// Test sur la quantité du Panier
// ------------------------------------------

var form;
var quantite;
var id;
var num;

function test_qte(form, quantite, id, num)
{
	if (quantite<=0){
		alert("Quantité non valide !");
		num.value = id;
		return false;
	} else {
		form.submit();
		return true; 
	}
}

// -------------------------------------------------------
// Afficher une image dans une pop up qui se retaille en 
// automatique en fonction de la taille de l'image
// -------------------------------------------------------

var popupImage;
var popupImage;
function ImageMax(chemin)
   {
   if ((popupImage) && (!popupImage.closed)){
	popupImage.close();
   }
   
   i1 = new Image;
   i1.src = chemin;
          
   html = '<html><head><title>Zoom sur image</title></head><body scroll="no" leftmargin="2" marginwidth="0" topmargin="2" marginheight="0"><table border="0" CELLPADDING=0 CELLSPACING=0 width="100%" height="100%"><tr><td background="../images/anim_charg.gif"><IMG src="'+chemin+'" BORDER=0 NAME=ImageMax onLoad="window.resizeTo(document.ImageMax.width+10,document.ImageMax.height+30)"></td></tr></table></body></html>';
   popupImage = window.open('','popupImage','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0, width=400, height=350, top=50, left=100');
   popupImage.document.open();
   popupImage.document.write(html);
   popupImage.document.close();
}


// -------------------------------------------------------
// Tests sur les champs du formulaire Recommandation 
// -------------------------------------------------------

function recommandation()
{
	if (document.recommand.nom_envoyeur.value == "") {
		alert("Veuillez bien remplir votre Nom !");						
		document.recommand.nom_envoyeur.focus();
		return false;		
	}
	if (document.recommand.email_envoyeur.value == "") {
		alert("Veuillez bien remplir votre Email !");						
		document.recommand.email_envoyeur.focus();
		return false;		
	}
	var email_envoyeur   = document.recommand.email_envoyeur.value;
    var verif   = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,4}$/
    if (verif.exec(email_envoyeur) == null){
       	alert("Votre email est incorrect");
        document.recommand.email_envoyeur.focus();	
		return false;			
    }
	if (document.recommand.nom_dest.value == "") {
		alert("Veuillez bien remplir le nom du destinataire !");						
		document.recommand.nom_dest.focus();
		return false;		
	}
	if (document.recommand.email_dest.value == "") {
		alert("Veuillez bien remplir l'email du destinataire !");						
		document.recommand.email_dest.focus();
		return false;		
	}
	var email_dest   = document.recommand.email_dest.value;
    var verif   = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,4}$/
    if (verif.exec(email_dest) == null){
       	alert("L'email du destinataire est incorrect");
        document.recommand.email_dest.focus();	
		return false;			
    }	
	return;		
}

// -------------------------------------------------------
// Tests sur les champs du formulaire Inscription
// -------------------------------------------------------

function inscription_test(action)
	{
	if (document.inscription.nom.value == "") {
		alert("Veuillez bien remplir le nom !");						
		document.inscription.nom.focus();
		return false;		
		}
	if (document.inscription.prenom.value == "") {
		alert("Veuillez bien remplir le prénom !");						
		document.inscription.prenom.focus();
		return false;		
		}
	if (document.inscription.email.value == "") {
		alert("Veuillez bien remplir l'email !");						
		document.inscription.email.focus();
		return false;		
		}
	if (document.inscription.adresse.value == "") {
		alert("Veuillez bien remplir l'adresse !");						
		document.inscription.adresse.focus();
		return false;		
		}	
	if (document.inscription.ville.value == "") {
		alert("Veuillez bien remplir la ville !");						
		document.inscription.ville.focus();
		return false;		
		}
	
	if(action=="insert"){
		if (document.inscription.pass.value.length < 6) {
			alert("Votre mot de passe doit contenir au moins 6 caractères !");						
			document.inscription.pass.value="";
			document.inscription.pass2.value="";
			document.inscription.pass.focus();
			return false;		
			}
		if (document.inscription.pass2.value != document.inscription.pass.value) {
			alert("La confirmation du Mot de passe ne convient pas !");
			document.inscription.pass.value = "";	
			document.inscription.pass2.value = "";				
			document.inscription.pass.focus();
			return false;		
			}
	}
	return;		
}




// ------------------------------------------------------
// Test si l'adresse de livraison est complète
// ------------------------------------------------------

function test_adresse_livraison(){

	if (document.form_livraison.prenom.value == "") {
		alert("Veuillez bien remplir le champs Prénom !");						
		document.form_livraison.prenom.focus();
		return false;		
	}
	if (document.form_livraison.nom.value == "") {
		alert("Veuillez bien remplir le champs Nom !");						
		document.form_livraison.nom.focus();
		return false;		
	}
	if (document.form_livraison.adresse.value == "") {
		alert("Veuillez bien remplir votre adresse !");						
		document.form_livraison.adresse.focus();
		return false;		
	}
	if (document.form_livraison.ville.value == "") {
		alert("Veuillez bien remplir la Ville !");						
		document.form_livraison.ville.focus();
		return false;		
	}
	return;

}



// -------------------------------------------------------------
// Verifier si les champs du bloc "mon compte" ne sont pas vide
// -------------------------------------------------------------

function verif_compte(num){
	var num;
	if (document.forms[num].login.value == "") {
		alert("Veuillez bien remplir l'identifiant !");						
		document.forms[num].login.focus();
		return false;		
	}
	var login   = document.forms[num].login.value;
    var verif   = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,4}$/
    if (verif.exec(login) == null){
       	alert("Votre Identifiant est incorrect");
        document.forms[num].login.focus();	
		return false;			
    }
	if (document.forms[num].pass.value == "") {
		alert("Veuillez bien remplir le mot de passe !");						
		document.forms[num].pass.focus();
		return false;		
	}
	document.forms[num].submit();
	return;
}



function contact_test()
	{
	if (document.formcontact.prenom.value == "") {
		alert("Veuillez bien remplir le prénom !");						
		document.formcontact.prenom.focus();
		return false;		
		}
	if (document.formcontact.nom.value == "") {
		alert("Veuillez bien remplir le nom !");						
		document.formcontact.nom.focus();
		return false;		
		}	
	if (document.formcontact.email.value == "") {
		alert("Veuillez bien remplir l'email !");						
		document.formcontact.email.focus();
		return false;		
		}
	var email   = document.formcontact.email.value;
    var verif   = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,4}$/
    if (verif.exec(email) == null){
       	alert("Veuillez bien remplir l'email !");
        document.formcontact.email.focus();	
		return false;			
    }
	document.formcontact.submit();
	return;		
}
