//<!--

function IdemAddress ( chk )
{
  //var fo = document.form;
  if (!chk.checked) return;

  document.form.misc6.selectedIndex = document.form.title.selectedIndex;
  document.form.misc14.selectedIndex = document.form.country.selectedIndex;

  document.form.misc7.value = document.form.last_name.value;
  document.form.misc8.value = document.form.first_name.value;
  document.form.misc9.value = document.form.address.value;
  document.form.misc10.value = document.form.address2.value;
  document.form.misc12.value = document.form.zip_code.value;
  document.form.misc13.value = document.form.city.value;
  document.form.misc15.value = document.form.phone.value;
  document.form.misc16.value = document.form.gsm.value;
}


function valide_mail ()
{
  var fo = document.contact_form;
  
  if (fo.last_name.value.length == 0)
  {
    alert ("You forgot to enter your surname");
    return false;
  }
  
  if (fo.first_name.value.length == 0)
  {
    alert ("You forgot to enter your first name");
    return false;
  }
  
  if (fo.address.value.length == 0)
  {
    alert ("You forgot to enter your address");
    return false;
  }
  
  if (fo.zip_code.value.length == 0) {
    alert ("You forgot to enter your postcode");
    return false;
  }
  
  if (fo.city.value.length == 0) {
    alert ("You forgot to enter your city");
    return false;
  }
  
  if (fo.phone.value.length == 0) {
    alert ("You forgot to enter your telephone number");
    return false;
  }
  
  if (!fo.email.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("You must enter a valid e-mail address (firstname.surname@myemail.com)");
    return false;
  }
  
  if (fo.email.value.match(/^www\./i))
  {
    alert ("You must enter a valid e-mail address (firstname.surname@myemail.com)");
    return false;
  }
  
  if (fo.SECURITY_CODE.value.length == 0) {
    alert ("You forgot to enter your security code");
    return false;
  }
  
  return true;
  
}


function valide_account (TYPE)
{
  var fo = document.form;
  
  if (fo.title.value.length == 0)
  {
    alert ("You must select the title (Mr, Mrs, Miss)");
    return false;
  }
  if (fo.last_name.value.length == 0)
  {
    alert ("You forgot to enter your surname");
    return false;
  }
  if (fo.first_name.value.length == 0)
  {
    alert ("You forgot to enter your first name");
    return false;
  }
  if (fo.address.value.length == 0)
  {
    alert ("You forgot to enter your address");
    return false;
  }
  if (fo.zip_code.value.length == 0)
  {
    alert ("You forgot to enter your postcode");
    return false;
  }  
  if (fo.city.value.length == 0)
  {
    alert ("You forgot to enter your city");
    return false;
  }
  // special pour les codes postaux des DOM-TOM
  if (fo.country.value.substring(0,2) == 'FR' &&
      parseInt (fo.zip_code.value.substring(0,2), 10) >= 97)
  {
    alert ("Error: invalid postcode for mainland France");
    return false;
  }
  if (!fo.email.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("You must enter a valid e-mail address (firstname.surname@myemail.com)");
    return false;
  }
  if (fo.email.value.match(/^www\./i))
  {
    alert ("You must enter a valid e-mail address (firstname.surname@myemail.com)");
    return false;
  }
  
  if(TYPE!="update")
  {
    if (fo.email.value != fo.email_confirm.value)
    {
      alert ("The two e-mail addresses are not identical");
      return false;
    }
  }
  
  if (fo.password.value.length == 0)
  {
    alert ("You forgot to enter your password");
    return false;
  }
  if (fo.password.value.length > 10)
  {
    alert ("Your password must have a maximum of 10 characters");
    return false;
  }
  
  if(TYPE=="update")
  {
    if (fo.new_password && fo.new_password.value.length != 0)
    {
      if (fo.new_password.value != fo.new_password_confirm.value)
      {
        alert ("The two new passwords are not identical");
        return false;      
      }
    }
  }
  else
  {
    if (fo.password.value != fo.password_confirm.value)
    {
      alert ("The two passwords are not identical");
      return false;
    }
  }
  
  if (fo.phone.value.length == 0)
  {
    alert ("You forgot to enter your telephone number");
    return false;
  }
  
  // Spécial PRO
  /*
  if (document.getElementById('fax') && fo.fax.value.length == 0)
  {
    alert ("Vous avez oublié de saisir le fax");
    return false;
  }
  */
  
  /* LIVRAISON */
 if (fo.misc6.value.length == 0)
  {
    alert ("You must select the title of the person to whom the delivery is being made (Mr, Mrs, Miss)");
    return false;
  }
  if (fo.misc7.value.length == 0)
  {
    alert ("You forgot to enter your delivery surname");
    return false;
  }
  if (fo.misc8.value.length == 0)
  {
    alert ("You forgot to enter your delivery first name");
    return false;
  }
  if (fo.misc9.value.length == 0)
  {
    alert ("You forgot to enter your delivery address");
    return false;
  }
  if (fo.misc12.value.length == 0)
  {
    alert ("You forgot to enter your delivery postcode");
    return false;
  }  
  if (fo.misc13.value.length == 0)
  {
    alert ("You forgot to enter your delivery city");
    return false;
  }
  // special pour les codes postaux des DOM-TOM
  if (fo.misc14.value.substring(0,2) == 'FR' &&
      parseInt (fo.misc12.value.substring(0,2), 10) >= 97)
  {
    alert ("Error: invalid postcode for mainland France");
    return false;
  }
  if (fo.misc15.value.length == 0)
  {
    alert ("You forgot to enter your delivery telephone number");
    return false;
  }
  
  
  if (fo.cgv && !fo.cgv.checked)
  {
    alert ("You must read the terms and conditions of service.");
    return false;
  }

  return true;
}


function valide_password_forgotten ()
{
  var fo = document.password_forgotten;
  
  if (!fo.email.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("You must enter a valid e-mail address (firstname.surname@myemail.com)");
    return false;
  }
  
  if (fo.email.value.match(/^www\./i))
  {
    alert ("You must enter a valid e-mail address (firstname.surname@myemail.com)");
    return false;
  }
  
  return true;
}


function valide_send_friend ()
{
  var fo = document.send_friend;
  
  if (!fo.email_source.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("You must enter a valid e-mail address (firstname.surname@myemail.com)");
    return false;
  }
  
  if (fo.email_source.value.match(/^www\./i))
  {
    alert ("You must enter a valid e-mail address (firstname.surname@myemail.com)");
    return false;
  }
  
  if (!fo.email_dest.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("You must enter a valid e-mail address for the beneficiary (firstname.surname@myemail.com)");
    return false;
  }
  
  if (fo.email_dest.value.match(/^www\./i))
  {
    alert ("You must enter a valid e-mail address for the beneficiary (firstname.surname@myemail.com)");
    return false;
  }
  
  return true;
  
}

function valide_delivery_form ()
{
  var fo = document.goto_BDC_2;

  if (fo.title.value.length == 0)
  {
    alert ("You must select the title (Mr, Mrs, Miss)");
    return false;
  }

  if (fo.last_name.value.length == 0)
  {
    alert ("You forgot to enter the surname");
    return false;
  }
  if (fo.first_name.value.length == 0)
  {
    alert ("You forgot to enter the first name");
    return false;
  }
  if (fo.address.value.length == 0)
  {
    alert ("You forgot to enter the address");
    return false;
  }
  
  if (fo.zip_code.value.length == 0)
  {
    alert ("You forgot to enter the postcode");
    return false;
  }  
  if (fo.city.value.length == 0)
  {
    alert ("You forgot to enter the city");
    return false;
  }
  
  // special pour les codes postaux des DOM-TOM
  if (fo.country.value.substring(0,2) == 'FR' &&
      parseInt (fo.zip_code.value.substring(0,2), 10) >= 97)
  {
    alert ("Error: invalid postcode for mainland France");
    return false;
  }
  
  return true;
}


function valide_print_access ()
{
  var fo = document.print_access;
  
  if (!fo.LOGIN.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("You must enter a valid e-mail address (firstname.surname@myemail.com)");
    return false;
  }
  
  if (fo.LOGIN.value.match(/^www\./i))
  {
    alert ("You must enter a valid e-mail address (firstname.surname@myemail.com)");
    return false;
  }
  
  if (fo.PASSWORD.value.length == 0)
  {
    alert ("You forgot to enter your password");
    return false;
  }

  return true;
}

function valide_print_access_bdc ()
{
  var fo = document.print_access_bdc;
  
  if (!fo.LOGIN.value.match(/^[a-z0-9&\'\.\-_\+]*@[a-z0-9]+([\.\-][a-z0-9]+)*\.[a-z]{2,}$/i))
  {
    alert ("You must enter a valid e-mail address (firstname.surname@myemail.com)");
    return false;
  }
  
  if (fo.LOGIN.value.match(/^www\./i))
  {
    alert ("You must enter a valid e-mail address (firstname.surname@myemail.com)");
    return false;
  }
  
  if (fo.PASSWORD.value.length == 0)
  {
    alert ("You forgot to enter your password");
    return false;
  }

  return true;
}

//-->
