//' Version :
//' ---------

//' 1.00 / 2003-06-25 / DB => 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 '0' !";
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_10=		" n'est pas correctement constitué !";                  
var vLOC_check_form_11=		" doit contenir '9' chiffres !"; 
var vLOC_check_form_13=		" doit contenir '10' chiffres !";


//' 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, pOffer) {
	var vDigit1= pField.value.charAt(0);
	var vDigit2= pField.value.charAt(1);
	var vDigit3= pField.value.charAt(2);
	var vLength= pField.value.length;
	var vStr = new String(pField);
	//'alert(ekjfb);
	if (vDigit1!="0") {
		alert(pLibelle + vLOC_check_form_7);
		return false;
	} else {
		if ((vDigit2=="4") && ((vDigit3=="7") || (vDigit3=="8") || (vDigit3=="9"))) {
		//'alert('num mobile');
			if (vLength!=10) {
				alert(pLibelle + vLOC_check_form_13);
				return false;
			}
			else return true;
		}

		else {
			//'alert ('num fixe')
			if (vLength!="9") {
				alert (pLibelle + vLOC_check_form_11);
				return false;
			}
			else 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;
}
