//' Version :
//' ---------
//' 1.10 / 2003-04-11 / PL => Suppression des fonctions communes (check_form_XX)
//'														'checkPhoneXX' renommer en 'checkPhone'
//' 1.09 / 2003-01-21 / PL => Ajout de 'field2Number' et 'changeCli'
//' 1.08 / 2002-09-03 / CB => Ajout de 'checkUserPIN'
//' 1.07 / 2002-06-11 / CB => Ajout 'hotmail.com'
//' 1.06 / 2002-05-17 / FB => Modif de la fonction checkNumField et checkStrField
//' 1.05 / 2002-01-31 / CB => Modif 'changeTo...', bug taille tableaux
//' 1.04 / 2001-12-29 / CB => Modif 'changeTo...'
//' 1.03 / 2001-12-02 / CB => Modif 'checkPhoneFR'
//' 1.02 / 2001-11-27 / CB => Ajout checkAutoParrain
//' 1.01 / 2001-10-24 / CB => Refus de ' dans EMail
//' 1.00 / 2001-05-29 / CB => Création

var vLOC_check_form_1=		"Rellena";
var vLOC_check_form_2A=		"Teclea un minimo de";
var vLOC_check_form_2B=		"letra(s)";
var vLOC_check_form_2C=		"para";
var vLOC_check_form_5=		" debe estar constituido solamente de cifras !";
var vLOC_check_form_6=		" debe empezar por '6' o '9' !";
var vLOC_check_form_6B=		" no debe empezar por '9' !";
var vLOC_check_form_7=		" debe empezar por '0' !";
var vLOC_check_form_8=		" no puede estar verificada !";
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,78F/mn)";
var vLOC_check_form_10=		" no tiene una constitucion valida !";                  
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,78F/mn)";
var vLOC_check_form_13=		" debe empezar por '01', '02', '03', '04', '05' ou '06' !";
                  
  
//' 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;
	if (pField.value.charAt(0)!="6" && pField.value.charAt(0)!="8" && pField.value.charAt(0)!="9") {
		alert("'" + pLibelle + "'" + vLOC_check_form_6);
		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();

	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(vLOC_check_form_9);
		return false;
		}

	if (
vLowDomain=="altavista.fr" ||	
vLowDomain=="apexmail.fr" ||	
vLowDomain=="club.lemonde.fr" ||	
vLowDomain=="excite.fr" ||	
vLowDomain=="fairesuivre.fr" ||	
vLowDomain=="hotmail.com" ||
vLowDomain=="gmx.fr" ||	
vLowDomain=="lemel.fr" ||	
vLowDomain=="leparisien.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(vLOC_check_form_11A + vLowDomain + vLOC_check_form_11B);
		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 changeToTransfer() {
	var vSelected = document.form_buy.amount.selectedIndex;
	//if (vSelected>7) vSelected = 1;
	document.form_buy.amount.options.length=7;
	document.form_buy.amount.options[0]=new Option("10 €","10");
	document.form_buy.amount.options[1]=new Option("15 €","15");
	document.form_buy.amount.options[2]=new Option("20 €","20");
	document.form_buy.amount.options[3]=new Option("30 €","30");
	document.form_buy.amount.options[4]=new Option("50 €","50");
	document.form_buy.amount.options[5]=new Option("100 €","100");
	document.form_buy.amount.options[6]=new Option("150 €","150");
	//document.form_buy.amount.options[vSelected].selected=true;		
}

function changeToCB() {
	//var vSelected = document.form_buy.amount.selectedIndex;
	//if (vSelected>7) vSelected = 1;
	document.form_buy.amount.options.length=7;
	document.form_buy.amount.options[0]=new Option("10 €","10");
	document.form_buy.amount.options[1]=new Option("15 €","15");
	document.form_buy.amount.options[2]=new Option("20 €","20");
	document.form_buy.amount.options[3]=new Option("30 €","30");
	document.form_buy.amount.options[4]=new Option("50 €","50");
	document.form_buy.amount.options[5]=new Option("100 €","100");
	document.form_buy.amount.options[6]=new Option("150 €","150");
	//document.form_buy.amount.options[vSelected].selected=true;	
}
function changeToCheque() {
	//var vSelected = document.form_buy.amount.selectedIndex;
	//if (vSelected>7) vSelected = 1;
	document.form_buy.amount.options.length=9;
	document.form_buy.amount.options[0]=new Option("10 €","10");
	document.form_buy.amount.options[1]=new Option("15 €","15");
	document.form_buy.amount.options[2]=new Option("20 €","20");
	document.form_buy.amount.options[3]=new Option("30 €","30");
	document.form_buy.amount.options[4]=new Option("50 €","50");
	document.form_buy.amount.options[5]=new Option("100 €","100");
	document.form_buy.amount.options[6]=new Option("150 €","150");
	document.form_buy.amount.options[7]=new Option("300 €","300");
	document.form_buy.amount.options[8]=new Option("500 €","500");
	//document.form_buy.amount.options[vSelected].selected=true;		
}