/******************************************************************************************/
/******************************************************************************************/
/******************************************************************************************/
var mPrefix = "Les champs suivis d'une astérisque * sont obligatoires. Merci de les remplir pour poursuivre votre commande.";
var mSuffix = "";

var iCP = "Le code postal doit etre un entier de 5 caractéres. Veuillez le ressaisir svp.";
var iEmail = "Vous devez saisir une adresse e mail valide. (ex : foo@bar.com)";
var iDay = "Le jour de naissance doit etre un nombre entre 1 et 31. Veuillez le ressaisir svp.";
var iMonth = "Le mois de naissance doit etre un nombre entre 1 et 12. Veuillez le ressaisir svp.";
var iYear = "L'année de naissance doit etre une année valide de 2 ou 4 caractére. Veuillez le ressaisir svp.";
var iYearInRange = "Seules les personnes majeures (âgés de 18 ans et plus) peuvent souscrire à l'option net et mobile. Merci de vérifier votre année de naissance.";
var iMobilePhone = "Le numéro de mobile doit contenir 10 chiffres et commencer par 06 [exemple : 0601020304].  Veuillez le ressaisir svp.";
var iPhone = "Le numéro de telephone doit contenir 10 chiffres.  Veuillez le ressaisir svp.";
var iNotInteger = "Merci de vérifier le champ en rouge, il ne doit contenir que des lettres.";
var iCocherRestituer = "La location d'une nouvelle livebox est obligatoire pour bénéficier de l'option net et mobile. Merci de cocher la case correspondante.";
var iNumClient = "Merci de vérifier le numéro de client, il ne doit contenir que des chiffres.";

// FR phone numbers have 10 digits.
// They are formatted as 0125362514
var digitsInFRPhoneNumber = 10;

/******************************************************************************************/
/******************************************************************************************/
/******************************************************************************************/
// Personalisation pour le formulaire Formulaire_step1
function checkTelFixeOption (theForm){
	if (isWhitespace(theForm.elements["txtExNom"].value) && isWhitespace(theForm.elements["txtExNumFixe"].value)){
		checkString(theForm.elements["txtExNom"], "");
		return false;
	}else{
		if (!isWhitespace(theForm.elements["txtExNumFixe"].value)){
			if (isFRPhoneNumber(theForm.elements["txtExNumFixe"].value)){
				return true;
			}else{
				checkFRPhone(theForm.elements["txtExNumFixe"], "");
				return false;
			}
		}else{
			return true;
		}
	}
}


//idem warnempty mais sans le set focus qui fait erreur sous netscape
function warnEmptyCombo (theField, s){   
    alert(mPrefix + s + mSuffix);
    return false;
}

//Notify user that contents of field radio are invalid.
function warnInvalidRadio (radio, s){	
	radio[0].focus();
	alert(s);
	return false;
}

//Check if Field Value is Integer 
function checkIsInteger (theField, s, emptyOK){   
    if (checkIsInteger.arguments.length == 2) emptyOK = defaultEmptyOK;

    if ((emptyOK == true) && (isEmpty(theField.value))) return true;

    if (!isInteger(theField.value)) 
       return warnInvalid (theField, s);
    else return true;

}

// Check that string theField.value is a valid Year.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
function checkYearInRange (theField, emptyOK){   
    if (checkYearInRange.arguments.length == 1) emptyOK = defaultEmptyOK;
    
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;

    if (!isYear(theField.value, false)) {
       return warnInvalid (theField, iYear);
    }else{
	currentdate = new Date();
	currentYear = currentdate.getFullYear();
	maxYear = currentYear - 18;
	if (isIntegerInRange (theField.value, 1880, maxYear) == true){
		return true;
	}else{
		return warnInvalid (theField, iYearInRange);
	}
    }
}

// checkFRMobilePhone (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check tat string theField.value is a valid FR Mobile Phone.
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
function checkFRMobilePhone (theField, emptyOK){   
    if (checkFRMobilePhone.arguments.length == 1) emptyOK = defaultEmptyOK;

    if ((emptyOK == true) && (isEmpty(theField.value))) {
	return true;
    }else{
	var normalizedPhone = stripCharsInBag(theField.value, phoneNumberDelimiters)
	if (!isFRMobilePhoneNumber(normalizedPhone, emptyOK)) {
		return warnInvalid (theField, iMobilePhone);
	}else{  
		// if you don't want to reformat as (123) 456-789, comment next line out
		theField.value = normalizedPhone; //reformatFRPhone(normalizedPhone)
		return true;
       }
    }
}

//
function isFRMobilePhoneNumber (s){   
	if (isEmpty(s)) {
		if (isFRMobilePhoneNumber.arguments.length == 1) return defaultEmptyOK;
		else return (isFRMobilePhoneNumber.arguments[1] == true);
	}
	return (isInteger(s) && s.length == digitsInFRPhoneNumber && s.substr(0, 2) == "06")
}

// checkFRPhone (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check tat string theField.value is a valid FR Phone.
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
function checkFRPhone (theField, emptyOK){   
    if (checkFRPhone.arguments.length == 1) emptyOK = defaultEmptyOK;

    if ((emptyOK == true) && (isEmpty(theField.value))) {
	return true;
    }else{
	var normalizedPhone = stripCharsInBag(theField.value, phoneNumberDelimiters)
	if (!isFRPhoneNumber(normalizedPhone, emptyOK)) {
		return warnInvalid (theField, iPhone);
	}else{  
		// if you don't want to reformat as (123) 456-789, comment next line out
		theField.value = normalizedPhone; //reformatFRPhone(normalizedPhone)
		return true;
       }
    }
}

//
function isFRPhoneNumber (s){   
	if (isEmpty(s)) {
		if (isFRPhoneNumber.arguments.length == 1) return defaultEmptyOK;
		else return (isFRPhoneNumber.arguments[1] == true);
	}
	return (isInteger(s) && s.length == digitsInFRPhoneNumber)
}

//Verify that CheckBox is Checked.
function isCheckedBox (Checkbox, isChecked, s){
	if(!isChecked)
		return warnInvalid(Checkbox, s)
	else return true;
}

//Check that Dropdownlist is Selected.
function checkSelected (theField, s, emptyOK){   
    // Next line is needed on NN3 to avoid "undefined is not a number" error
    // in equality comparison below.
	if (theField != null)
	{
    if (checkSelected.arguments.length == 2) emptyOK = defaultEmptyOK;
    
    if ((emptyOK == true) && (!isSelected(theField))) return true;
    
    if (!isSelected(theField)) 
       return warnEmptyCombo (theField, s);
    else return true;
	}
	else 
	{
		return false;
	}
}

//Verify that Dropdownlist is Selected.
function isSelected(theField){
	sValue1 = new String(); 
	if (theField!=null) {
		sValue = theField.options[theField.selectedIndex].value;
		if (sValue=="0" || isEmpty(sValue))  return false;
		else return true;
	}
	else{
		return false;
	}
}

// CheckIsTrue :  One of the checkbox must be checked.
function CheckIsTrue (checkbox, b, s) {
	if (!isTrue(b)) return warnInvalid(checkbox, s);
	return true;
}

function isTrue(b) {
	return b;
}

//Verify that radio is Checked Whithout Prompt alert if false.
function isRadioButtonChecked (radio, s){
	var rtn=false;
	
	for (var i = 0; i < radio.length; i++){  
		if (radio[i].checked) { rtn=true; }
	}
	
	if (!rtn) 
		return warnInvalidRadio (radio, s);
	else return true;
}

// Get checked value from radio button.
function getRadioButtonValueEx (radio){
	for (var i = 0; i < radio.length-1; i++){   
		if (radio[i].checked){ break }
	}
	
	if (!radio[i].checked) {return false;}
	
	return radio[i].value
}

// checked that value from Fields have not integer 
function checkIsNotInteger (theField, s, emptyOK) {
	// Next line is needed on NN3 to avoid "undefined is not a number" error
	// in equality comparison below.
	if (checkIsNotInteger.arguments.length == 2) emptyOK = defaultEmptyOK;

	if ((emptyOK == true) && (isEmpty(theField.value))) return true;

	//alert(isInteger(theField.value));
	if (hasInteger(theField.value)) {
		theField.style.backgroundColor="red";
		return warnInvalid (theField, iNotInteger);
	} else {
		if ((emptyOK == defaultEmptyOK) && (isEmpty(theField.value))) {
			theField.style.backgroundColor="";
			return warnEmpty (theField, s);
		}else{
			theField.style.backgroundColor="";
			return true;
		}
	}
}


function hasInteger (s) {   
	var i;
	if (isEmpty(s)) 
		if (hasInteger.arguments.length == 1) return defaultEmptyOK;
		else return (hasInteger.arguments[1] == true);

	// Search through string's characters one by one
	// until we find a non-numeric character.
	// When we do, return false; if we don't, return true.
	for (i = 0; i < s.length; i++){
		// Check that current character is number.
		var c = s.charAt(i);
		if (isDigit(c)) return true;
	}

	// All characters are numbers.
	return false;
}


/*
var mFRCivility = "Veuillez séléctionner une civilité.";
var iZIPCode = "Le champs Code Postal doit contenir 5 chiffres (Example 92600). Veuillez la ressaisir svp."
var iEmail = "L'adresse email doit etre du type foo@bar.com. Veuillez la ressaisir svp.";
var iWorldPhone = "Le numero de telephone doit etre valide. Veuillez la ressaisir svp.";
var iFRPhone = "Le numero de telephone doit etre valide. Veuillez la ressaisir svp.";
var iFRMobilePhone = "Le numero de telephone doit contenir 10 chiffre et commencer par 06 [exemple : 0601020304].  Veuillez le ressaisir svp.";
var iFRAge = "Veuiller saisir un age valide (entier entre 10 et 99).";
var iFRDate = "Date"
//var iDay = "Ce champs doit etre un nombre entre 1 et 31. Veuillez le ressaisir svp."
//var iMonth = "Ce champs doit etre un nombre entre 1 et 12. Veuillez le ressaisir svp."
//var iYear = "Ce champs doit etre une année valide de 2 ou 4 caractére. Veuillez le ressaisir svp."
var iDatePrefix = "Le jour, Mois, est année du champs "
var iDateSuffix = " ne forme pas une date valide.  Veuillez les ressaisir svp."

var sFRMayUseEmail = "Acceptez vous de recevoir de l'informations 1007 par e-mail "
var sFREmail = "Email"
var sFRName = "Nom";
var sFRFirstName = "Prénom";
var sFRAddrNumber = "N° de voie";
var sFRAddrWayType = "Type de voie";
var sFRAddrWayName = "Nom de voie";
var sFRAddr = "Adresse"
var sFRAddrComp = "Complément d'adresse";
var sFRCity = "Ville";
var sFRZip = "Code Postal";
var sFRCountry = "Pays";
var sFRQuestion = "Question";
var sFRLangue = "Langue";
var sFRBrand = "Marque";
var sFRModel = "Modele";
var sFRSMSNumber = "Téléphone Portable";

*/
