
// Kick out of frameset.
if (window.self != window.top) window.top.location = window.self.location;

// CHECK EMAIL ADDR
  function ChkEmail(email) {
  var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
  if (!reg1.test(email) && reg2.test(email))
  	{ // if syntax is valid
    return true;
  	}
  return false;
  }

// VALIDATE FORMS

// LOGIN FORM
function ChkLogin(theForm)
{
  if (theForm.login.value == "")
  {
    alert("Veuillez indiquer votre identifiant.");
    theForm.login.focus();
    return (false);
  }
  if (theForm.password.value == "")
  {
    alert("Veuillez indiquer votre mot de passe.");
    theForm.password.focus();
    return (false);
  }
  return true;
}

// LOGIN REMINDER FORM
function ChkLoginReminder(theForm)
{
	if(!ChkEmail(theForm.Email.value))
	{
		alert("Adresse email non valide !");
		theForm.Email.value="";
		theForm.Email.focus();
		return (false);
	}
  return true;
}

function ChkModel(theForm)
{
  if (theForm.model.selectedIndex == 0)
  {
    alert("Merci de choisir un modèle.");
    theForm.model.focus();
    return (false);
  }
  return true;
}

function ChkGenre(theForm)
{
  if (theForm.genre.selectedIndex == 0)
  {
    alert("Merci de choisir un genre de véhicule.");
    theForm.genre.focus();
    return (false);
  }
  return true;
}

function ChkConst(theForm)
{
  if (theForm.construct.selectedIndex == 0)
  {
    alert("Merci de choisir un constructeur.");
    theForm.construct.focus();
    return false;
  }
  return true;
}

// CONTACT FORM
function ChkContact(theForm)
{
  if (theForm.name.value == "")
  {
    alert("Veuillez indiquer vos nom et prénom.");
    theForm.name.focus();
    return (false);
  }
	if(!ChkEmail(theForm.email.value))
	{
		alert("Adresse email non valide !");
		theForm.email.value="";
		theForm.email.focus();
		return false
	}
  if (theForm.subject.value == "")
  {
    alert("Veuillez indiquer l'objet de votre prise de contact.");
    theForm.subject.focus();
    return (false);
  }
  if (theForm.body.value == "")
  {
    alert("Veuillez taper votre message.");
    theForm.body.focus();
    return (false);
  }
  return true;
}

// ADD PARTNER FORM
function ChkPartnerAdd(theForm)
{
	if (theForm.login.value.length<6)
	{
		alert("Choisissez un identifiant de 6 caractères minimum !");
		theForm.login.focus();
		return (false);
	}
  if (theForm.FName.value == "")
  {
    alert("Veuillez indiquer votre prénom.");
    theForm.FName.focus();
    return (false);
  }
  if (theForm.LName.value == "")
  {
    alert("Veuillez indiquer votre nom.");
    theForm.LName.focus();
    return (false);
  }
	if(!ChkEmail(theForm.Email.value))
	{
		alert("Adresse email non valide !");
		theForm.Email.value="";
		theForm.Email.focus();
		return (false);
	}
  if (theForm.Company.value == "")
  {
    alert("Veuillez indiquer le nom de votre société.");
    theForm.Company.focus();
    return (false);
  }
  if (theForm.Siret.value == "")
  {
    alert("Veuillez indiquer le SIRET de votre société.");
    theForm.Siret.focus();
    return (false);
  }
  if (theForm.Addr1.value == "")
  {
    alert("Veuillez indiquer votre adresse.");
    theForm.Addr1.focus();
    return (false);
  }
  if (theForm.Zip.value.length>5||theForm.Zip.value.length<5)
  {
    alert("Veuillez indiquer le code postal.");
    theForm.Zip.focus();
    return (false);
  }
  if (theForm.City.value == "")
  {
    alert("Veuillez indiquer votre localité.");
    theForm.City.focus();
    return (false);
  }
  if (theForm.Phone1.value == "")
  {
    alert("Veuillez indiquer un numéro de téléphone.");
    theForm.Phone1.focus();
    return (false);
  }
  return true;
}