// JavaScript Document

  function LancerComparaison()
  {
  	ok = 0;
	cpt = 1;
  	for (i=1;i<=4;i++)
  	{
  		ideuh = "compare"+i;
  		var t = document.getElementById(ideuh);
  		var t2 = t.getElementsByTagName("li");
  	
  		if (t2.length > 0)
  		{
  			nomChamp = "Case"+cpt;
  			document.getElementsByName(nomChamp)[0].value = t2[0].id;
  			ok = 1;
			cpt++;
  		}
  	}
  	if (ok == 1) { document.formulaire.submit(); }
	else
	{
		document.getElementById("erreur_comparaison").innerHTML = "Sélectionnez au moins 1 marchand";
	}
  }
  
  	window.onload = function() {
          
  		var list = document.getElementById("Sup");
  		DragDrop.makeListContainer( list, 'g1' );
  		list.onDragOver = function() { this.style["background"] = "#EEF"; };
  		list.onDragOut = function() {this.style["background"] = "none"; };
  
  		list = document.getElementById("compare1");
  		DragDrop.makeListContainer( list, 'g1' );
          list.onDragOver = function() { this.style["background"] = "#EEF"; };
  		list.onDragOut = function() {this.style["background"] = "none"; };
  
  		list = document.getElementById("compare2");
  		DragDrop.makeListContainer( list, 'g1' );
          list.onDragOver = function() { this.style["background"] = "#EEF"; };
  		list.onDragOut = function() {this.style["background"] = "none"; };
  
  		list = document.getElementById("compare3");
  		DragDrop.makeListContainer( list, 'g1' );
          list.onDragOver = function() { this.style["background"] = "#EEF"; };
  		list.onDragOut = function() {this.style["background"] = "none"; };
  
  		list = document.getElementById("compare4");
  		DragDrop.makeListContainer( list, 'g1' );
          list.onDragOver = function() { this.style["background"] = "#EEF"; };
  		list.onDragOut = function() {this.style["background"] = "none"; };
  
  		list = document.getElementById("Bio");
  		DragDrop.makeListContainer( list, 'g1' );
          list.onDragOver = function() { this.style["background"] = "#EEF"; };
  		list.onDragOut = function() {this.style["background"] = "none"; };
                  
          list = document.getElementById("Cav");
  		DragDrop.makeListContainer( list, 'g1' );
          list.onDragOver = function() { this.style["background"] = "#EEF"; };
  		list.onDragOut = function() {this.style["background"] = "none"; };
  
          list = document.getElementById("Hyg");
  		DragDrop.makeListContainer( list, 'g1' );
          list.onDragOver = function() { this.style["background"] = "#EEF"; };
  		list.onDragOut = function() {this.style["background"] = "none"; };

		document.formulaire.Case1.value='';
		document.formulaire.Case2.value='';
		document.formulaire.Case3.value='';
		document.formulaire.Case4.value='';
  	};
  	
function rechercheCP()
  {
  	
  	if (isNaN(document.form_code_postal.Code_Postal.value)){
      document.getElementById("erreur_comparaison").innerHTML = "Votre code postal doit &ecirc;tre un nombre.";
      return false;
    }
    if (document.form_code_postal.Code_Postal.value==""){
      document.getElementById("erreur_comparaison").innerHTML = "Vous devez rentrer votre code postal.";
      return false;
    }
    return true;
  }
  
function verifAvis()
  {
  	
  	if (document.formAvis.pseudo.value==""){
      document.getElementById("erreur_comparaison").innerHTML = "Vous devez entrer votre pseudo.";
      return false;
    }    
    if (document.formAvis.email.value==""){
      document.getElementById("erreur_comparaison").innerHTML = "Vous devez entrer votre email.";
      return false;
    }
	else
	{
		adresse = document.formAvis.email.value;
		var place = adresse.indexOf("@",1);
		var point = adresse.indexOf(".",place+1);
		num = adresse.substring(point,adresse.length);
		if ((place > -1)&&(adresse.length >2)&&(point > 1)&&(place+1 != point)&&(num.length >= 3))
		{ }
		else
		{
			document.getElementById("erreur_comparaison").innerHTML = "Vous devez entrer un email valide.<br><br>";
			return false;
		}
	}
    if (document.formAvis.marchand.value=="..."){
      document.getElementById("erreur_comparaison").innerHTML = "Vous devez séléctionner un marchand.";
      return false;
    }    
    if (document.formAvis.text_opinion.value==""){
      document.getElementById("erreur_comparaison").innerHTML = "Vous n'avez pas donné votre avis.";
      return false;
    }
    if (document.formAvis.note.value==""){
      document.getElementById("erreur_comparaison").innerHTML = "Vous n'avez pas donné votre note.";
      return false;
    }
	else if (isNaN(document.formAvis.note.value)||(document.formAvis.note.value < 0)||(document.formAvis.note.value > 20))
	{
	  document.getElementById("erreur_comparaison").innerHTML = "Votre note n'est pas correcte.";
      return false;
	}
    if (document.formAvis.Crypto.value==""){
      document.getElementById("erreur_comparaison").innerHTML = "Vous n'avez pas renseigné le champs de vérification.";
      return false;
    }
    return true;
  }

function verifNews()
{
	tab = document.forms["formAvis"].elements;
	choix = 0;
	for (i=0; i<tab.length; i++)
	{
		if (tab[i].type == "checkbox" && tab[i].checked == true)
		{ choix = 1; }
	}
	if (choix == 0)
	{
	  document.getElementById("erreur_comparaison").innerHTML = "Vous devez sélectionner au moins un marchand.<br><br>";
      return false;
	}
   if (document.formAvis.email.value==""){
      document.getElementById("erreur_comparaison").innerHTML = "Vous devez entrer votre email.<br><br>";
      return false;
    }
	else
	{
		adresse = document.formAvis.email.value;
		var place = adresse.indexOf("@",1);
		var point = adresse.indexOf(".",place+1);
		num = adresse.substring(point,adresse.length);
		if ((place > -1)&&(adresse.length >2)&&(point > 1)&&(place+1 != point)&&(num.length >= 3))
		{ }
		else
		{
			document.getElementById("erreur_comparaison").innerHTML = "Vous devez entrer un email valide.<br><br>";
			return false;
		}
	}
    if (document.formAvis.Crypto.value==""){
      document.getElementById("erreur_comparaison").innerHTML = "Vous n'avez pas renseigné le champs de vérification.";
      return false;
    }
    return true;
  }
