/* ************************ */
/*	Script page COMMANDE	*/
/* ************************ */

/*  à réintégrer dès que je comprends pourquoi le maj() ne fonctionne pas déplacé dans le .js    */


/* ************************ */
/*	Script abonnementBox	*/
/* ************************ */

		if (document.images) { 
		  btnOff = new Image();
		  btnOff.src =		"/img/btn_devenirbilingue.gif";
		  btnOn = new Image();
		  btnOn.src =		"/img/btn_devenirbilingue_go.gif";
		  btnHover = new Image();
		  btnHover.src =	"/img/btn_devenirbilingue_go.gif"; 
        }

function verifEmail(champ) {
  with (champ) {
	posAt = value.indexOf("@")
	posPt = value.lastIndexOf(".")
	if (posAt<1 || posPt-posAt<2 || value.length-posPt<3 ) {
	  return false;
	}
	else {
	  return true;
	}
  }
}

function verifFormulaire(pourValider) {
  if (document.images) {
	if (verifEmail(document.abonnement.email)) {
	  document.abonnement.jeminscris.src = btnOn.src;
	  if (pourValider) {
		document.abonnement.submit();
		}
	}
	else {
	  document.abonnement.jeminscris.src = btnOff.src;
	  if (pourValider) {
		alert("Veuillez corriger votre adresse e-mail s'il vous plait");
		document.abonnement.email.focus();
	  }
	}
  }
}

// handles the neat button graphic update
// please note: we trigger this on keydown, would not trigger on keyup.
function verifPret() {
  if (document.images) {
	if (verifEmail(document.abonnement.email)) {
      document.abonnement.jeminscris.src = btnOn.src;
	} else {
      document.abonnement.jeminscris.src = btnOff.src;
    }
  }
}

function survoleBouton() {
  if (document.images) {
	if (verifEmail(document.abonnement.email)) {
	  document.abonnement.jeminscris.src = btnHover.src;
	}
  }
}

// hmm, does not seem to be used, dunno what is was here for. 
function verifFormulaire2(pourValider) {
  if (document.images) {
	if (verifEmail(document.abonnement2.email)) {
	  document.abonnement2.jeminscris2.src = btnOn.src;
	  if (pourValider) {
		document.abonnement2.submit();
		}
	}
	else {
	  document.abonnement2.jeminscris2.src = btnOff.src;
	  if (pourValider) {
		alert("Veuillez corriger votre adresse e-mail s'il vous plait");
		document.abonnement2.email.focus();
	  }
	}
  }
}

function survoleBouton2() {
  if (document.images) {
	if (verifEmail(document.abonnement2.email)) {
	  document.abonnement2.jeminscris2.src = btnHover.src;
	}
  }
}
