//' Version :
//' ---------
//' 1.13 / 2006-08-19 / JA => Ajout de checkAmountField
//' 1.12 / 2003-04-11 / PL => Suppression des fonctions communes (check_form_XX)
//'														'checkPhoneXX' renommer en 'checkPhone'
//' 1.11 / 2003-01-21 / PL => Ajout de 'field2Number' et 'changeCli'
//' 1.10 / 2002-09-03 / CB => Ajout de 'checkUserPIN'
//' 1.09 / 2002-05-17 / FB => Modif de la fonction checkNumField et checkStrField
//' 1.08 / 2002-02-28 / JA => Modif F -> €
//' 1.07 / 2001-12-02 / CB => Modif 'checkPhoneFR'
//' 1.06 / 2001-11-27 / CB => Modif checkAutoParrain (pb valueOf)
//' 1.05 / 2001-11-24 / CB => Ajout refus EMail
//' 1.04 / 2001-10-24 / CB => Refus de ' dans EMail
//' 1.03 / 2001-08-07 / DB => Prise en compte du parrainage
//' 1.02 / 2001-08-07 / MB => Ajout de la l'adresse interdite club.elle.fr
//' 1.01 / 2001-08-01 / CB => Correction texte vLOC_check_form_2A et vLOC_check_form_2B
//' 1.00 / 2001-05-29 / CB => Création

var vLOC_check_form_1=		"Veuillez saisir ";
var vLOC_check_form_1A=		"Veuillez saisir au moins un numéro de téléphone...";
var vLOC_check_form_2A=		"Veuillez entrer un minimum de ";
var vLOC_check_form_2B=		"caractère(s) ";
var vLOC_check_form_2C=		"pour ";
var vLOC_check_form_5=		" doit être constitué uniquement de chiffres !";
var vLOC_check_form_6=		" doit commencer par '6' o '9' !";
var vLOC_check_form_6B=		" ne doit pas commencer par '9' !";
var vLOC_check_form_7=		" doit commencer par '0' !";
var vLOC_check_form_8=		" ne peut pas être vérifié !";
var vLOC_check_form_9=		"Pour des raisons de sécurité, nous ne pouvons actuellement livrer votre code " +
													"personnel que sur une boite à lettres de type '.fr' ou '.edu'\n" + 
													"Veuillez saisir une adresse Email associée à votre fournisseur d'accès " +
													"ou à votre entreprise.\n" +
													"Si votre boîte à lettres Web ne correspond pas à ces critères, " +
													"merci de nous téléphoner au 0 820 00 00 04 (0,12€/mn)";
var vLOC_check_form_10=		" n'est pas correctement constitué !";                  
var vLOC_check_form_11A=	"Pour des raisons de sécurité, nous ne pouvons livrer votre code personnel " +
													"sur une boite à lettres Web de type '";
var vLOC_check_form_11B=	"'.\n" +
													"Veuillez saisir une adresse Email associée à votre fournisseur d'accès " +
													"ou à votre entreprise.\n" +
													"Si votre boîte à lettres Web ne correspond pas à ces critères, " +
													"merci de nous téléphoner au 0 820 00 00 04 (0,12€/mn)";
//'pour le parrainage
var vLOC_check_form_12 =	"Vous ne pouvez pas vous parrainer vous-même.\nVeuillez choisir un autre parrain !";
var vLOC_check_form_13=		" doit commencer par '01', '02', '03', '04', '05' ou '06' ou '07' !";
var vLOC_check_form_14=		" doit correspondre au format d'un montant";

//' Vérifie que le champ 'pField' ne soit pas vide et comporte au moins pCount caractères. 
//' Si oui, affiche un message spécifiant que le champ 'pLibelle' est vide et retourne false.
//' Si non, return true.
function checkStrField(pField, pLibelle, pCount, pCheckEmpty) {
	if (pCheckEmpty+''=="undefined") pCheckEmpty=true; else pCheckEmpty=false;
	if (pCheckEmpty && pField.value == "") {
	  alert(vLOC_check_form_1 + pLibelle + " !");
	  pField.focus();
	  return false;
	}
	if (pField.value.length < pCount) {
	  var vString= vLOC_check_form_2A + ' ' + pCount + ' ' + vLOC_check_form_2B + ' ';
	  vString+= vLOC_check_form_2C + pLibelle + " !";
	  alert(vString);
	  pField.focus();
	  return false;
	}
	return true;
}

//' Appelle checkStrField. 
//' Vérifie que le champ 'pField' soit composé uniquement de chiffres.
//' Si non, affiche un message.
//' Si oui, return true.
function checkNumField(pField, pLibelle, pCount, pCheckEmpty) {
        if (checkStrField(pField, pLibelle, pCount, pCheckEmpty) == false)
                return false;
        var vC;
        var vLen = pField.value.length;
        for (var x = 0; x < vLen; x++) {
                vC = pField.value.charAt(x);
                if (vC < '0' || vC > '9') {
                        alert(pLibelle + ' ' + vLOC_check_form_5);
                        pField.focus();
                        return false;
                }
        }
    return true;
}

function checkUserPIN(pField, pLibelle, pCount) {
	if (checkNumField(pField, pLibelle, pCount)==false)
		return false;
	if (pField.value.charAt(0)=="9") {
		alert(pLibelle + vLOC_check_form_6B);
		return false;
	}
	return true;
}

function checkPhone(pField, pLibelle, pCount) {
	if (checkNumField(pField, pLibelle, pCount)==false)
		return false;
	var vDigit1= pField.value.charAt(0);
	if (vDigit1!="0") {
		alert(pLibelle + vLOC_check_form_7);
		return false;
	}

	//' Regarde s'il s'agit d'un numéro de test interne
	var vTestNumber= pField.value.substring(0,6);
	if (vTestNumber=='099999')
		return true;
	
	var vDigit2= pField.value.charAt(1);
	if (!(vDigit2=="1" || vDigit2=="2" || vDigit2=="3" || vDigit2=="4" || 
				vDigit2=="5" || vDigit2=="6" || vDigit2=="7")) {
		alert(pLibelle + vLOC_check_form_13);
		return false;
	}
	return true;
}

function checkCheckField(pField, pFieldCheck, pLibelle) {
	if (pField.value!=pFieldCheck.value) {
		alert(pLibelle + vLOC_check_form_8);
		return false;
	}
	return true;
}

function checkAutoParrain (pMailF,pMailP) {
	if (pMailF.value==pMailP.value) {
		return true;
	}	else{
		return false;
	}		
}

//' Appelle checkStrField. 
//' Vérifie que le champ 'pField' soit un EMail (dans sa composition)
//' Si non, affiche un message.
//' Si oui, return true.
function chechEMailRestriction(pField, pLibelle) {
	var vDotPlace=	pField.value.lastIndexOf(".", pField.value.length);
	var vCountry=	pField.value.substring(vDotPlace+1, pField.value.length);
	var vLowCountry=	vCountry.toLowerCase();

	var vAtPlace=	pField.value.indexOf("@",1);
	var vDomain=	pField.value.substring(vAtPlace+1, pField.value.length);
	var vLowDomain=	vDomain.toLowerCase();

//' Vérifie les noms spéciaux
	if (
	(pField.value.indexOf("jkbd",0)==0)  //' Voleur signalé par Marc le 2001-11-24
	)
		{
		alert("Pour des raisons de sécurité, nous ne pouvons livrer votre code personnel sur cette boite à lettres Web.\n" + 
		      "Veuillez saisir une adresse Email associée à votre fournisseur d'accès ou à votre entreprise.\n" +
                  "Si votre boîte à lettres Web ne correspond pas à ces critères, merci de nous téléphoner au 0 820 00 00 04 (0,12€/mn)");
		return false;
		}

	if (
//' Les fournisseurs d'accès sont autorisés, même si c'est pas béton...
vLowDomain=="6sens.com" ||
vLowDomain=="aol.com" ||
vLowDomain=="everyday.com" ||
vLowDomain=="infonie.com" ||
vLowDomain=="itineris.net" ||
vLowDomain=="mageos.com" ||
vLowDomain=="net-up.com" ||
vLowDomain=="oreka.com" ||
vLowDomain=="sfr.net" ||
vLowDomain=="voonoo.net" ||
vLowDomain=="waika9.com" ||
//' Les entreprises suivantes sont autorisés, mais c'est plus béton du tout...
vLowDomain=="globalone.net" ||
vLowDomain=="budgetelecom.com"
				)	
		{
		return true;
		}

	if ((vLowCountry=="fr" || vLowCountry=="edu")==false)
		{
		alert("Pour des raisons de sécurité, nous ne pouvons actuellement livrer votre code personnel que sur une boite à lettres de type '.fr' ou '.edu'\n" + 
		      "Veuillez saisir une adresse Email associée à votre fournisseur d'accès ou à votre entreprise.\n" +
                  "Si votre boîte à lettres Web ne correspond pas à ces critères, merci de nous téléphoner au 0 820 00 00 04 (0,12€/mn)");
		return false;
		}

	if (
vLowDomain=="altavista.fr" ||
vLowDomain=="apexmail.fr" ||
vLowDomain=="bonjour.fr" ||
vLowDomain=="club.elle.fr" ||
vLowDomain=="club.lemonde.fr" ||
vLowDomain=="excite.fr" ||
vLowDomain=="fairesuivre.fr" ||
//' vLowDomain=="freesurf.fr" ||
vLowDomain=="genie.fr" ||	//' ajout 2001-10-15
vLowDomain=="gmx.fr" ||
vLowDomain=="lemel.fr" ||
vLowDomain=="leparisien.fr" ||
vLowDomain=="libertysurf.fr" ||
vLowDomain=="lycos.fr" ||
vLowDomain=="mail.dotcom.fr" ||
vLowDomain=="netpme.fr" ||
vLowDomain=="nomade.fr" ||
vLowDomain=="pagefrance.fr" ||
vLowDomain=="respublica.fr" ||
vLowDomain=="skymail.fr" ||
vLowDomain=="spray.fr" ||
vLowDomain=="voila.fr" ||
vLowDomain=="yahoo.fr" ||
vLowDomain=="youpy.fr"	
				)
		{
		alert("Pour des raisons de sécurité, nous ne pouvons livrer votre code personnel sur une boite à lettres Web de type '" + vLowDomain + "'.\n" + 
		      "Veuillez saisir une adresse Email associée à votre fournisseur d'accès ou à votre entreprise.\n" +
                  "Si votre boîte à lettres Web ne correspond pas à ces critères, merci de nous téléphoner au 0 820 00 00 04 (0,12€/mn)");
		return false;
		}
	return true;
}

function checkEMailField(pField, pLibelle, pCount) {
	if (checkStrField(pField, pLibelle, pCount)==false)
		return false;
	var vAtPlace=		pField.value.indexOf("@",1);
	var vDotPlace=		pField.value.indexOf(".",vAtPlace+1);
	var vQuotePlace=	pField.value.indexOf("'",0);
	if (pField.value.indexOf(" ",0)!= -1){
		alert("'" + pLibelle + "'" + vLOC_check_form_10);
		pField.focus();
		return false;
	} 
	if (vAtPlace>1 && vDotPlace>vAtPlace && vQuotePlace==-1 && (vDotPlace<pField.value.length-1))
		return true;
	alert("'" + pLibelle + "'" + vLOC_check_form_10);
	pField.focus();
	return false;
}

function checkAmountField(pField, pLibelle, pCount, pCheckEmpty) {
	if (checkStrField(pField, pLibelle, pCount, pCheckEmpty) == false)
		return false;
	var vC;
	var vLen = pField.value.length;
	for (var x = 0; x < vLen; x++) {
		vC = pField.value.charAt(x);
		if ((vC < '0' || vC > '9') && (vC != ",") && (vC != ".")){
			alert(pLibelle + ' ' + vLOC_check_form_14);
			pField.focus();
			return false;
		}
	}
	return true;
}