var NUM = '0123456789';
var ALPHA = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var ALPHABIS = 'âäàåéêëèïîìôöòüûùÿÄÅÉæÆÖÜÇç';
var SP = ' ';
var OTHER1 = '-\'';
var OTHER2 = '_$&@"';
var OTHER3 = '~{([|`\^)]}=+*/,?;.:!§%µ¨£¤<>²_$&@"-\'';
var OTHER4 = '#';
var OTHER5 = '€';
//*******************************************************************************************
//
//  1.  Define the validation rules for each field in the HEAD section
// 2.  Insert the onLoad event handler into your BODY tag
// 3.  Add validate() to your submit button, as shown below -->
//<SCRIPT LANGUAGE="JavaScript">
//
//<!-- Begin
//function init() {
//define('field1', 'string', 'Apple');
//define('field2', 'string', 'Peach', 4);
//define('field3', 'string', 'Cherry', null, 8);
//define('field4', 'string', 'Melon', 4, 8);
//define('field5', 'num', 'Banana');
//define('field6', 'num', 'Grape', 3);
//define('field7', 'num', 'Carot', null, 6);
//define('field8', 'num', 'Sugar', 4, 6);
//define('field9', 'email', 'Fruit');
//}
//   End -->
//<BODY OnLoad="init()">
//<input type=submit name=submit onClick="validate();return returnVal;" value="Test fields">
//</script>
//*******************************************************************************************

//Begin
// Generic Form Validation
var checkObjects	= new Array();
var errors		= "";
var returnVal		= false;
var language		= new Array();
language["header"]	= "The following error(s) occured:"
language["start"]	= "->";
language["field"]	= " Res ";
language["require"]	= " is required";
language["min"]		= " and must consist of at least ";
language["max"]		= " and must not contain more than ";
language["minmax"]	= " and no more than ";
language["chars"]	= " characters";
language["num"]		= " and must contain a number";
language["email"]	= " must contain a valid e-mail address";
// -----------------------------------------------------------------------------
// define - Call this function in the beginning of the page. I.e. onLoad.
// n = name of the input field (Required)
// type= string, num, email (Required)
// min = the value must have at least [min] characters (Optional)
// max = the value must have maximum [max] characters (Optional)
// d = (Optional)
// -----------------------------------------------------------------------------
function define(n, type, HTMLname, min, max, d) {
var p;
var i;
var x;
if (!d) d = document;
if ((p=n.indexOf("?"))>0&&parent.frames.length) {
d = parent.frames[n.substring(p+1)].document;
n = n.substring(0,p);
}
if (!(x = d[n]) && d.all) x = d.all[n];
for (i = 0; !x && i < d.forms.length; i++) {
x = d.forms[i][n];
}
for (i = 0; !x && d.layers && i < d.layers.length; i++) {
x = define(n, type, HTMLname, min, max, d.layers[i].document);
return x;
}
eval("V_"+n+" = new formResult(x, type, HTMLname, min, max);");
checkObjects[eval(checkObjects.length)] = eval("V_"+n);
}
function formResult(form, type, HTMLname, min, max) {
this.form = form;
this.type = type;
this.HTMLname = HTMLname;
this.min  = min;
this.max  = max;
}
function validate() {
if (checkObjects.length > 0) {
errorObject = "";
for (i = 0; i < checkObjects.length; i++) {
validateObject = new Object();
validateObject.form = checkObjects[i].form;
validateObject.HTMLname = checkObjects[i].HTMLname;
validateObject.val = checkObjects[i].form.value;
validateObject.len = checkObjects[i].form.value.length;
validateObject.min = checkObjects[i].min;
validateObject.max = checkObjects[i].max;
validateObject.type = checkObjects[i].type;
if (validateObject.type == "num" || validateObject.type == "string") {
if ((validateObject.type == "num" && validateObject.len <= 0) || (validateObject.type == "num" && isNaN(validateObject.val))) { errors += language['start'] + language['field'] + validateObject.HTMLname + language['require'] + language['num'] + "\n";
} else if (validateObject.min && validateObject.max && (validateObject.len < validateObject.min || validateObject.len > validateObject.max)) { errors += language['start'] + language['field'] + validateObject.HTMLname + language['require'] + language['min'] + validateObject.min + language['minmax'] + validateObject.max+language['chars'] + "\n";
} else if (validateObject.min && !validateObject.max && (validateObject.len < validateObject.min)) { errors += language['start'] + language['field'] + validateObject.HTMLname + language['require'] + language['min'] + validateObject.min + language['chars'] + "\n";
} else if (validateObject.max && !validateObject.min &&(validateObject.len > validateObject.max)) { errors += language['start'] + language['field'] + validateObject.HTMLname + language['require'] + language['max'] + validateObject.max + language['chars'] + "\n";
} else if (!validateObject.min && !validateObject.max && validateObject.len <= 0) { errors += language['start'] + language['field'] + validateObject.HTMLname + language['require'] + "\n";
}
} else if(validateObject.type == "email") {
// Checking existense of "@" and ".".
// Length of must >= 5 and the "." must
// not directly precede or follow the "@"
if ((validateObject.val.indexOf("@") == -1) || (validateObject.val.charAt(0) == ".") || (validateObject.val.charAt(0) == "@") || (validateObject.len < 6) || (validateObject.val.indexOf(".") == -1) || (validateObject.val.charAt(validateObject.val.indexOf("@")+1) == ".") || (validateObject.val.charAt(validateObject.val.indexOf("@")-1) == ".")) { errors += language['start'] + language['field'] + validateObject.HTMLname + language['email'] + "\n"; }
	}
}
}
if (errors) {
alert(language["header"].concat("\n" + errors));
errors = "";
returnVal = false;
} else {
returnVal = true;
}
}
// End -->


//*******************************************************************************************
//
//		ONE STEP TO INSTALL PRINT PAGE:
//	Copy the coding into the BODY of your HTML document
//	STEP ONE: Paste this code into the BODY of your HTML document
//*******************************************************************************************

//Begin
//if (window.print) {
//document.write('<form>Do not forget to '
//+ '<input type=button name=print value="Print" '
//+ 'onClick="javascript:window.print()"> this page!</form>');
//}
// End -->

//*******************************************************************************************
//
//		Retour autom. lignes suivantes
//<input onKeyUp="return autoTab(this, 3, event);" size="4" maxlength="3">
//*******************************************************************************************

// Begin
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode;
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}
//  End -->

//*******************************************************************************************
//
//		Quelques fonction utiles
//
//*******************************************************************************************

function confirmation(){
	if (confirm('click on OK if you want to save'))
		return true;
	else
		return false;
}
//submit
function submiter(pForm){
		pForm.submit();
}
//  End -->

//Annuler
function Cancel(){
	//var doc = eval("document."+formulaire);
	if (confirm("Do you really want to cancel your creation / modification ?"))
		return true;
	else
		return false;
}
//  End -->

function ResetData(pForm){
	//var doc = eval("document."+formulaire);
	if (confirm("Do you really want to reset ?")){
		pForm.reset();
	}
}

//*******************************************************************************************
//
//		Gestion des codes postaux
// Utilisation :
// <form name=zip onSubmit="return validateZIP(this,this.value)">
//
//*******************************************************************************************

// Begin
function validateZIP(fieldName,field) {
var valid = "0123456789-";
var hyphencount = 0;

if (field.length!=5 && field.length!=10) {
	if(fieldName.value !=""){
		alert("Please enter your 5 digit or 5 digit+4 zip code.");
		fieldName.value = "";
		fieldName.focus();
		return false;
	}
}
for (var i=0; i < field.length; i++) {
temp = "" + field.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
	if(fieldName.value !="" && fieldName.value !=null ){ //ajout du test le 04/10/2001
		alert("Invalid characters in your zip code.  Please try again.");
		fieldName.value = "";
		fieldName.focus();
		return false;
	}
}
if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
	//ajout du test le 04/10/2001
	if(fieldName.value !="" && fieldName.value !=null ){
		alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
		fieldName.value = "";
		fieldName.focus();
		return false;
	}
}
}
return true;
}
//  End -->


//*******************************************************************************************
//
//		Gestion des formats des dates dans les champs d'un formulaire
// Utilisation :
// <input type="text" name="Email_Ann"  size="25"  onBlur="return emailCheck(this,this.value);">
//
//*******************************************************************************************

// This script and many more are available free online at

// Begin
function emailCheck (emailName,emailStr) {

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address.
These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a
username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)

if (matchArray==null) {
		//Ajout du test suivant le 05/10/2001
	/* Too many/few @'s or something; basically, this address doesn't
		even fit the general mould of a valid e-mail address. */
		alert("L'adresse email est invalide (doit contenir un @ et un point)")
		//Ajout de trois lignes suivantes le 05/10/2001
		emailName.value = "";
		//emailName.focus();
		return false;

}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid
if (user.match(userPat)==null) {
	// user is not valid
	alert("The username doesn't seem to be valid.")
	return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
	// this is an IP address
	for (var i=1;i<=4;i++) {
		if (IPArray[i]>255) {
			alert("Destination IP address is invalid!")
		return false
		}
	}
	return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.")
	return false
}

/* domain name seems valid, but now make sure that it ends in a
three-letter word (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding
the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 ||
	domArr[domArr.length-1].length>3) {
// the address must end in a two letter or three letter word.
alert("The address must end in a three-letter domain, or two letter country.")
return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
var errStr="This address is missing a hostname!"
alert(errStr)
return false
}

// If we've gotten this far, everything's valid!
return true;
}
//  End -->

//*******************************************************************************************
//
//		Gestion des formats des dates dans les champs d'un formulaire
// Utilisation :
// <input type="text" name="testDateFormat1" size='10' maxlength="10"
// onFocus="javascript:vDateType='1'" onKeyUp="DateFormat(this,this.value,event,false,'1')"
// onBlur="DateFormat(this,this.value,event,true,'1')">
//
//*******************************************************************************************

// Original:  Richard Gorremans (RichardG@spiritwolfx.com)

//Begin
// Check browser version
var isNav4 = false, isNav5 = false, isIE4 = false
var strSeperator = "/";
// If you are using any Java validation on the back side you will want to use the / because
// Java date validations do not recognize the dash as a valid date separator.
var vDateType = 3; // Global value for type of date format
//                1 = mm/dd/yyyy
//                2 = yyyy/dd/mm  (Unable to do date check at this time)
//                3 = dd/mm/yyyy
var vYearType = 4; //Set to 2 or 4 for number of digits in the year for Netscape
var vYearLength = 2; // Set to 4 if you want to force the user to enter 4 digits for the year before validating.
var err = 0; // Set the error code to a default of zero
if(navigator.appName == "Netscape") {
if (navigator.appVersion < "5") {
isNav4 = true;
isNav5 = false;
}
else
if (navigator.appVersion > "4") {
isNav4 = false;
isNav5 = true;
}
}
else {
isIE4 = true;
}
function DateFormat(vDateName, vDateValue, e, dateCheck, dateType) {
vDateType = dateType;
// vDateName = object name
// vDateValue = value in the field being checked
// e = event
// dateCheck
// True  = Verify that the vDateValue is a valid date
// False = Format values being entered into vDateValue only
// vDateType
// 1 = mm/dd/yyyy
// 2 = yyyy/mm/dd
// 3 = dd/mm/yyyy
//Enter a tilde sign for the first number and you can check the variable information.
if (vDateValue == "~") {
alert("AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE4+" \nYear Type = "+vYearType+" \nDate Type = "+vDateType+" \nSeparator = "+strSeperator);
vDateName.value = "";
vDateName.focus();
return true;
}
var whichCode = (window.Event) ? e.which : e.keyCode;
// Check to see if a seperator is already present.
// bypass the date if a seperator is present and the length greater than 8
if (vDateValue.length > 8 && isNav4) {
if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1))
return true;
}
//Eliminate all the ASCII codes that are not valid
var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";
if (alphaCheck.indexOf(vDateValue) >= 1) {
if (isNav4) {
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
else {
vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
return false;
}
}
if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no value
return false;
else {
//Create numeric string values for 0123456789/
//The codes provided include both keyboard and keypad values
var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
if (strCheck.indexOf(whichCode) != -1) {
if (isNav4) {
if (((vDateValue.length < 6 && dateCheck) || (vDateValue.length == 7 && dateCheck)) && (vDateValue.length >=1)) {
alert("La date est invalide\nVeuillez la ressaisir");
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
if (vDateValue.length == 6 && dateCheck) {
var mDay = vDateName.value.substr(2,2);
var mMonth = vDateName.value.substr(0,2);
var mYear = vDateName.value.substr(4,4)
//Turn a two digit year into a 4 digit year
if (mYear.length == 2 && vYearType == 4) {
var mToday = new Date();
//If the year is greater than 30 years from now use 19, otherwise use 20
var checkYear = mToday.getFullYear() + 30;
var mCheckYear = '20' + mYear;
if (mCheckYear >= checkYear)
mYear = '19' + mYear;
else
mYear = '20' + mYear;
}
var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
if (!dateValid(vDateValueCheck)) {
alert("La date est invalide\nVeuillez la ressaisir");
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
return true;
}
else {
// Reformat the date for validation and set date type to a 1
if (vDateValue.length >= 8  && dateCheck) {
if (vDateType == 1) // mmddyyyy
{
var mDay = vDateName.value.substr(2,2);
var mMonth = vDateName.value.substr(0,2);
var mYear = vDateName.value.substr(4,4)
vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
}
if (vDateType == 2) // yyyymmdd
{
var mYear = vDateName.value.substr(0,4)
var mMonth = vDateName.value.substr(4,2);
var mDay = vDateName.value.substr(6,2);
vDateName.value = mYear+strSeperator+mMonth+strSeperator+mDay;
}
if (vDateType == 3) // ddmmyyyy
{
var mMonth = vDateName.value.substr(2,2);
var mDay = vDateName.value.substr(0,2);
var mYear = vDateName.value.substr(4,4)
vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
}
//Create a temporary variable for storing the DateType and change
//the DateType to a 1 for validation.
var vDateTypeTemp = vDateType;
vDateType = 1;
var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
if (!dateValid(vDateValueCheck)) {
alert("La date est invalide\nVeuillez la ressaisir");
vDateType = vDateTypeTemp;
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
vDateType = vDateTypeTemp;
return true;
}
else {
if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
alert("La date est invalide\nVeuillez la ressaisir");
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
		}
	}
}
}
else {
// Non isNav Check
if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
alert("La date est invalide\nVeuillez la ressaisir");
vDateName.value = "";
vDateName.focus();
return true;
}
// Reformat date to format that can be validated. mm/dd/yyyy
if (vDateValue.length >= 8 && dateCheck) {
// Additional date formats can be entered here and parsed out to
// a valid date format that the validation routine will recognize.
if (vDateType == 1) // mm/dd/yyyy
{
var mMonth = vDateName.value.substr(0,2);
var mDay = vDateName.value.substr(3,2);
var mYear = vDateName.value.substr(6,4)
}
if (vDateType == 2) // yyyy/mm/dd
{
var mYear = vDateName.value.substr(0,4)
var mMonth = vDateName.value.substr(5,2);
var mDay = vDateName.value.substr(8,2);
}
if (vDateType == 3) // dd/mm/yyyy
{
var mDay = vDateName.value.substr(0,2);
var mMonth = vDateName.value.substr(3,2);
var mYear = vDateName.value.substr(6,4)
}
if (vYearLength == 4) {
if (mYear.length < 4) {
alert("La date est invalide\nVeuillez la ressaisir");
vDateName.value = "";
vDateName.focus();
return true;
}
}
// Create temp. variable for storing the current vDateType
var vDateTypeTemp = vDateType;
// Change vDateType to a 1 for standard date format for validation
// Type will be changed back when validation is completed.
vDateType = 1;
// Store reformatted date to new variable for validation.
var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
if (mYear.length == 2 && vYearType == 4 && dateCheck) {
//Turn a two digit year into a 4 digit year
var mToday = new Date();
//If the year is greater than 30 years from now use 19, otherwise use 20
var checkYear = mToday.getFullYear() + 30;
var mCheckYear = '20' + mYear;
if (mCheckYear >= checkYear)
mYear = '19' + mYear;
else
mYear = '20' + mYear;
vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
// Store the new value back to the field.  This function will
// not work with date type of 2 since the year is entered first.
if (vDateTypeTemp == 1) // mm/dd/yyyy
vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
if (vDateTypeTemp == 3) // dd/mm/yyyy
vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
}
if (!dateValid(vDateValueCheck)) {
alert("La date est invalide\nVeuillez la ressaisir");
vDateType = vDateTypeTemp;
vDateName.value = "";
vDateName.focus();
return true;
}
vDateType = vDateTypeTemp;
return true;
}
else {
if (vDateType == 1) {
if (vDateValue.length == 2) {
vDateName.value = vDateValue+strSeperator;
}
if (vDateValue.length == 5) {
vDateName.value = vDateValue+strSeperator;
}
}
if (vDateType == 2) {
if (vDateValue.length == 4) {
vDateName.value = vDateValue+strSeperator;
}
if (vDateValue.length == 7) {
vDateName.value = vDateValue+strSeperator;
}
}
if (vDateType == 3) {
if (vDateValue.length == 2) {
vDateName.value = vDateValue+strSeperator;
}
if (vDateValue.length == 5) {
vDateName.value = vDateValue+strSeperator;
}
}
return true;
}
}
if (vDateValue.length == 10 && dateCheck) {
if (!dateValid(vDateName)) {
// Un-comment the next line of code for debugging the dateValid() function error messages
//alert(err);
alert("La date est invalide\nVeuillez la ressaisir");
vDateName.focus();
vDateName.select();
}
}
return false;
}
else {
// If the value is not in the string return the string minus the last
// key entered.
if (isNav4) {
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
else
{
vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
return false;
		}
	}
}
}
function dateValid(objName) {
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
// var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
//strDate = datefield.value;
strDate = objName;
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
err = 1;
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound = true;
}
}
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
}
}
//Adjustment for short years entered
if (strYear.length == 2) {
strYear = '20' + strYear;
}
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
}
}
if (isNaN(intMonth)) {
err = 3;
return false;
}
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday < 1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
err = 9;
return false;
}
}
else {
if (intday > 28) {
err = 10;
return false;
	}
}
}
return true;
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}
//  End -->



/****************************************************************************************************
function isFieldNumberValid(pField, pFieldName, pFieldLengthMin, pFieldLengthMax, isFieldMandatory)
Cette fonction permet de vérifier que la chaine de caractères correspondant à la valeur du champ pField est correctement
formaté selon son type pFieldType
En entrée : pField = le nom d'un composant HTML de type <INPUT> (ex: 'document.monForm.monChamp')
		pFieldName = Le libellé du composant HTML défini par pField
		pFieldLengthMin = un entier définissant la taille minimale de la valeur du champ
		pFieldLengthMax = un entier définissant la taille maximale de la valeur du champ
		isFieldMandatory = un booléen qui définit le caractère obligatoire ou non de la valeur du champ.
		S'il est à "true", le champ doit obligatoirement avoir une valeur et non si à "false"
En sortie : "true" si la valeur du champ est correctement formatée et "false" sinon

Version    Date        Auteur     Navigateurs          Description des modifications
---------   ----------------  -----------   --------------------------  --------------------------------------------------
1.0      03/10/2000    OLD       IE4+ et Netscape3+    Code original
*/
function isFieldNumberValid(pField, pFieldName, pFieldLengthMin, pFieldLengthMax, isFieldMandatory) {
var vFieldLength = pField.value.length;
var vFieldValue = pField.value;
var vIsValid = true;

var vMessage = trimNumber(vFieldValue);
if (vMessage.length > 0) vIsValid = false;

if (!vIsValid) {
alert('The field '+pFieldName+' is not valid. ' + vMessage);
}
else {
if (vFieldLength > 0) {
if (pFieldLengthMin > 0) {
	if (vFieldLength < pFieldLengthMin) {
	alert('The minimum size of the field ' + pFieldName + ' is of ' + pFieldLengthMin + ' characters.');
	vIsValid = false;
	}
}
if (vFieldLength > pFieldLengthMax) {
	alert('The maximum size of the field ' + pFieldName + ' is of ' + pFieldLengthMax + ' characters.');
	vIsValid = false;
}
}
else { // if (vFieldLength > 0)
if (isFieldMandatory) {
	alert('The field ' + pFieldName + ' is compulsory.');
	vIsValid = false;
}
}
}

if (!vIsValid) pField.focus();

return vIsValid;
}



/****************************************************************************************************
function isFieldAlphaValid(pField, pFieldName, pFieldLengthMin, pFieldLengthMax, isFieldMandatory)
Cette fonction permet de vérifier que la chaine de caractères correspondant à la valeur du champ pField est correctement
formatée et ne contient que des caractères alphabétiques
En entrée : pField = le nom d'un composant HTML de type <INPUT> (ex: 'document.monForm.monChamp')
		pFieldName = Le libellé du composant HTML défini par pField
		pFieldLengthMin = un entier définissant la taille minimale de la valeur du champ
		pFieldLengthMax = un entier définissant la taille maximale de la valeur du champ
		isFieldMandatory = un booléen qui définit le caractère obligatoire ou non de la valeur du champ.
		S'il est à "true", le champ doit obligatoirement avoir une valeur et non si à "false"
En sortie : "true" si la valeur du champ est correctement formatée et "false" sinon

Version    Date        Auteur     Navigateurs          Description des modifications
---------   ----------------  -----------   --------------------------  --------------------------------------------------
1.0      03/10/2000    OLD       IE4+ et Netscape3+    Code original
*/
function isFieldAlphaValid(pField, pFieldName, pFieldLengthMin, pFieldLengthMax, isFieldMandatory) {
var vFieldLength = pField.value.length;
var vFieldValue = pField.value;
var vIsValid = true;

if (vFieldValue.length > 0) {
var vIndex = -1;
for (i = 0; i < vFieldValue.length; i++) {
/* Ne passe pas en Netscape 3
vCodeAscii = vFieldValue.charCodeAt(i);
if ( ((vCodeAscii < 65) || (vCodeAscii > 122)) || (( vCodeAscii > 90) && (vCodeAscii < 97)) ) {
   */
vCodeAscii = vFieldValue.charAt(i);
if ( ((vCodeAscii < 'A') || (vCodeAscii > 'z')) || (( vCodeAscii > 'Z') && (vCodeAscii < 'a')) ) {
	vIndex = i;
	break;
}
}
if (vIndex > -1) {
pField.focus();
alert('Le champ ' + pFieldName +' doit contenir des caractères alphanumériques.');
vIsValid = false;
}
}

if (vIsValid) {
if (vFieldLength > 0) {
if (pFieldLengthMin > 0) {
	if (vFieldLength < pFieldLengthMin) {
		alert('La taille minimum du champ ' + pFieldName + ' est ' + pFieldLengthMin + ' caractères.');
	vIsValid = false;
	}
}
if (vFieldLength > pFieldLengthMax) {
		alert('La taille maximum du champ ' + pFieldName + ' est ' + pFieldLengthMax + ' caractères.');
	vIsValid = false;
}
}
else { // if (vFieldLength > 0)
if (isFieldMandatory) {
	alert('Le champ ' + pFieldName + ' est obligatoire.');
	vIsValid = false;
}
}
}

if (!vIsValid) pField.focus();

return vIsValid;
}


/****************************************************************************************************
function isCorrectEmailString(pString)
Cette fonction permet de vérifier que la chaine de caractères pString correspond à une adresse eMail
En entrée : pString = une chaine de caractères qui doit être de la forme *@*.* uniquement (* étant un caractère générique) !
En sortie : "true" si pString correspond à une adresse eMail et "false" sinon

Version    Date        Auteur     Navigateurs          Description des modifications
---------   ----------------  -----------   --------------------------  --------------------------------------------------
1.0      29/09/2000    OLD       IE4+ et Netscape3+    Code original
*/
function isCorrectEmailString(pString) {
var vEmailOk = true;

if ((typeof(pString) == 'string') && (pString.length > 0)) {
var vPosPoint = pString.indexOf('.');
var vPosAt = pString.indexOf('@');
var vPosLastPoint = pString.lastIndexOf('.');
var vPosTwoPoints = pString.indexOf('..');
var vPosSpace = pString.indexOf(' ');
if ( (pString.length < 6) || // vérifie que l'adresse email comporte au moins 6 caractères (*@*.**)
	(vPosPoint < 1) || // vérifie que l'adresse email comporte un point et qu'il n'est pas au début
	(vPosAt < 1) || // vérifie que l'adresse email comporte le @ et qu'il n'est pas au début
	(vPosLastPoint <= vPosAt + 1) || // vérifie que le dernier point de l'adresse email ne se trouve pas avant le @ et pas non plus juste après le @
	(vPosLastPoint == pString.length - 1) || // vérifie que le point n'est pas le dernier caractère de l'adresse email
	(vPosTwoPoints > -1) || // vérifie qu'il n'y a pas deux points qui se suivent dans l'adresse email
	(vPosSpace > -1)) // vérifie qu'il n'y a pas d'espace dans l'adresse email
vEmailOk = false;

vPos = 0;
while ((vEmailOk) && (vPos < pString.length)) {
vEmailOk = ((pString.charAt(vPos) > ' ') && (pString.charAt(vPos) < '~'));
vPos++;
}
}
else
vEmailOk = false;

return vEmailOk;
}

function verif_champ(leChamp,nomChamp,longueurMiniChamp,longueurMaxiChamp,champObligatoire) {
	var longueurChamp = leChamp.value.length;
	var vToReturn;
	vToReturn=true;
	if (longueurChamp > 0) {
	if (longueurMiniChamp > 0) {
		if (longueurChamp < longueurMiniChamp) {
			alert('La taille minimum du champ ' + nomChamp + ' est de ' + longueurMiniChamp + ' caractères.');
		vToReturn=false;
		}
	}
	if (longueurChamp > longueurMaxiChamp) {
			alert('La taille maximum du champ ' + nomChamp + ' est de ' + longueurMaxiChamp + ' caractères.');
		vToReturn=false;
	}
	}
	else {
	if (champObligatoire) {
			alert('Le champ ' + nomChamp + ' est obligatoire.');
		vToReturn=false;
	}
	}
	if(!vToReturn)leChamp.focus();
	else{	//Gestion passage en majuscule !
		//gerer_Majuscules(leChamp);
	}
	return vToReturn;
}
function isFieldValid(pField, pFieldLabel, pSetCharAllowed, pFieldLengthMin, pFieldLengthMax, isFieldMandatory) {
	var vResult = true;
	var vMessage = '';
	var vFieldValue = pField;
	var vFieldLength = pField.length;
	vMessage="ATTENTION !\n";
	vMessage+="______________________________________________________________________\n\n";
	if (vFieldLength > 0) {
		// Verification des caracteres
		var vCpt = 0;
		while ((vResult) && (vCpt < vFieldLength)) {
			vResult = (pSetCharAllowed.indexOf(vFieldValue.charAt(vCpt)) > -1);
			vCpt++;
		}
		if (!vResult) {
			vMessage += "La valeur saisie du champ '" + pFieldLabel + "' n'est pas correcte.\n";
			vMessage += "Les valeurs autorisées sont : numériques et alphanumériques.\n\n";
			vMessage += "Les valeurs non autorisées sont :\n";
			vMessage += " 1- â ä à å é ê ë è ï î ì ô ö ò ü û ù ÿ Ä Å É æ Æ Ö Ü Ç ç\n";
			vMessage += " 2- ~ { ( [ | ` \ ^ ) ] } = + * / , ? ; . : ! § % µ ¨ £ ¤ < > ² _ $ & @ \" - \ '\n";
			vMessage += " 3- L'espace n'est pas autorisé.\n";
		}
		else {
			if (pFieldLengthMin > 0) { // Verification de nombre de caracteres minimum
				if (vFieldLength < pFieldLengthMin) {
					vMessage +="La taille minimum du champ '" + pFieldLabel + "' est de " + pFieldLengthMin + " caractères.\n";
					//vMessage += pFieldLabel + " doit avoir une taille minimum de " + pFieldLengthMin + " caractèrs.\n";
					vResult = false;
				}
			}
			if (vFieldLength > pFieldLengthMax) { // Verification de nombre de caracteres maximum
				vMessage +="La taille maximum du champ '" + pFieldLabel + "' est de " + pFieldLengthMax + " caractères.\n";
				//vMessage += pFieldLabel + " doit avoir une taille maximum de " + pFieldLengthMax + " caractèrs.\n";
				vResult = false;
			}
		}
	}
	else { // if (vFieldValue == 0)
		if (isFieldMandatory) { // Verification de la saisie obligatoire
			vMessage+= "Les champs marqués avec une * sont obligatoires.\n";
			vResult = false;
		}
	}

	if (!vResult) {
		vMessage+="______________________________________________________________________\n\n";
		alert(vMessage);
	}
	return vResult;
}
function isAncreValid(pStr) {
		var NUM = '0123456789';
		var ALPHA = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
		var ALPHABIS = 'âäàåéêëèïîìôöòüûùÿÄÅÉæÆÖÜÇç';
		var SP = ' ';
		var OTHER1 = '-\'';
		var OTHER2 = '_$&@"';
		var OTHER3 = '~{([|`\^)]}=+*/,?;.:!§%µ¨£¤<>²_$&@"-\'';
		var OTHER4 = '#';
		var ALL = NUM + ALPHA + OTHER4;
		var vCharsFor = ALL;
		if (!isFieldValid(pStr, 'Nom de l\'ancre', vCharsFor, 1, 20, true)) {
			return false;
		}else{
			return true;
		}
}
function replaceStrInStr(pInitialString, pSearchString, pReplaceString) {
	var vNewStr = null;
	if ((typeof(pInitialString) == 'string') && (typeof(pSearchString) == 'string') && (typeof(pReplaceString) == 'string')) {
		vNewStr = pInitialString;
		if ((pSearchString.length > 0) && (pSearchString.length < pInitialString.length)) {
			vNewStr = pInitialString.replace(new RegExp('\\' + pSearchString, 'g'), pReplaceString);
		}
	}
	return vNewStr;
}
function replaceIndent(pReplaceString) {
	pReplaceString = pReplaceString.replace("<BLOCKQUOTE dir=ltr style=\"MARGIN-RIGHT: 0px\">","<BLOCKQUOTE>");
	pReplaceString = pReplaceString.replace("<P dir=ltr style=\"MARGIN-RIGHT: 0px\">","<P>");
	return pReplaceString;
}
function replaceAnchor(pReplaceString) {
	//-------On transforme l'URL qui contient l'ancre.--------------
	var vPort="";
	var vHostName = location.hostname;
	if(location.port != ''){
		vPort = ":" + location.port;
	}
	//----------On vérifie s'il y a un ancre dans le texte riche----------
	if((vHostName != '') && (pReplaceString.indexOf("/x_anchor/###") > 0)){
		var vURL1 = "http://" + vHostName + vPort;
		var vURL = "http://" + vHostName + vPort + "/x_anchor/###";
		pReplaceString=replaceStrInStr(pReplaceString,vURL1+"/x_anchor/###", "#");
		pReplaceString=replaceStrInStr(pReplaceString, "/x_anchor/###", "#");
	}
	if((vHostName != '') && (pReplaceString.indexOf("/editor/") > 0)){
		var vURL1 = "http://" + vHostName + vPort;
		var vURL = "http://" + vHostName + vPort + "/editor/";
		pReplaceString=replaceStrInStr(pReplaceString,vURL1+"/admin/editor/fr/richedit.html", "");
		pReplaceString=replaceStrInStr(pReplaceString, "/admin/editor/fr/richedit.html", "");
	}
	return pReplaceString;
}

function isChampValid(pField, pFieldLabel, pSetCharAllowed, pFieldLengthMin, pFieldLengthMax, isFieldMandatory) {

	var vResult = true;
	var vMessage = '';
	var vFieldValue = pField.value;
	var vFieldLength = pField.value.length;
	if (vFieldLength > 0) {
		// Verification des caracteres
		var vCpt = 0;
		while ((vResult) && (vCpt < vFieldLength)) {

			vResult = (pSetCharAllowed.indexOf(vFieldValue.charAt(vCpt)) > -1);

			// Gestion des caractères spéciaux
			if ((!vResult) && (escape(vFieldValue.charAt(vCpt)).indexOf('%') == 0)) {
				// Autorisation des retours chariots (nécessaire pour les TEXTAREA)
				if ((vFieldValue.charCodeAt(vCpt) == 10) || (vFieldValue.charCodeAt(vCpt) == 13)) {
					vResult = true;
				}
			}
			vCpt++;
		}

		if (!vResult) {
			vMessage += "La valeur saisie du champ '" + pFieldLabel + "' n'est pas correcte.\n";
		}
		else {
			if (pFieldLengthMin > 0) { // Verification de nombre de caracteres minimum
				if (vFieldLength < pFieldLengthMin) {
					vMessage +="La taille minimum du champ '" + pFieldLabel + "' est de " + pFieldLengthMin + " caractères.\n";
					vResult = false;
				}
			}
			if (vFieldLength > pFieldLengthMax) { // Verification de nombre de caracteres maximum
				vMessage +="La taille maximum du champ '" + pFieldLabel + "' est de " + pFieldLengthMax + " caractères.\n";
				vResult = false;
			}
		}
	}
	else { // if (vFieldValue == 0)
		if (isFieldMandatory) { // Verification de la saisie obligatoire
			vMessage += "Le champ '" + pFieldLabel + "' est obligatoire.\n";
			vResult = false;
		}
	}

	if (!vResult) {
		alert(vMessage);
		pField.focus();
	}

	return vResult;
}

/* Contrôle chiffres-clés */
function isChiffreValid(pForm) {
		var ALL = NUM + ALPHA + ALPHABIS + SP + OTHER1 + OTHER2 + OTHER3 + OTHER4;
		var vCharsFor = ALL;
		if (!isChampValid(pForm.resume,'Résumé du document',vCharsFor,4,300,false)) return false;
		if (!isChampValid(pForm.titre,'Titre du document',vCharsFor,4,70,true)) return false;
		return true;
}
/* Contrôle des articles */
function isArticleValid(pForm) {
		var ALL = NUM + ALPHA + ALPHABIS + SP + OTHER1 + OTHER2 + OTHER3 + OTHER4;
		var vCharsFor = ALL;
		if (!isChampValid(pForm.titre,'Titre de l\'article',vCharsFor,4,70,true)) return false;
		if (!isChampValid(pForm.resume,'Résumé de l\'article',vCharsFor,4,300,false)) return false;
		return true;
}
/* Contrôle de l'agenda */
function isAgendaValid(pForm) {
		var ALL = NUM + ALPHA + ALPHABIS + SP + OTHER1 + OTHER2 + OTHER3 + OTHER4;
		var vCharsFor = ALL;
		if (!isChampValid(pForm.titre,'Titre de la manifestation',vCharsFor,4,70,true)) return false;
		if (!isChampValid(pForm.resume,'Résumé de la manifestation',vCharsFor,4,300,false)) return false;
		return true;
}

/* Contrôle de l'agenda */
function isNewsletterValid(pForm) {
		var ALL = NUM + ALPHA + ALPHABIS + SP + OTHER1 + OTHER2 + OTHER3 + OTHER4;
		var vCharsFor = ALL;
		if (!isChampValid(pForm.titre,'Titre de la newsletter ',vCharsFor,4,100,true)) return false;
		if (!isChampValid(pForm.texte,'Texte de la newsletter',vCharsFor,4,200000000,true)) return false;
		if (!isChampValid(pForm.email,'e-Mail de l\'expéditeur ',vCharsFor,6,60,true)) return false;
		return true;
}
/* Contrôle du secteur */
function isSecteurValid(pForm) {
		var ALL = NUM + ALPHA + ALPHABIS + SP + OTHER1 + OTHER2 + OTHER3 + OTHER4;
		var vCharsFor = ALL;
		if (!isChampValid(pForm.nom,'Nom du secteur ',vCharsFor,4,80,true)) return false;
		return true;
}

/* Contrôle du service */
function isServiceValid(pForm,pId) {
		var ALL = NUM + ALPHA + ALPHABIS + SP + OTHER1 + OTHER2 + OTHER3 + OTHER4;
		var vCharsFor = ALL;
		if(pId != "" ){
				ALPHA = ALL;
		}
		if (!isChampValid(pForm.code,'Code du service ',ALPHA,4,50,true)) return false;

		if (!isChampValid(pForm.description,'Description du service ',vCharsFor,4,255,true)) return false;
		return true;
}

/* Contrôle du secteur */
function isDomaineValid(pForm) {
		var ALL = NUM + ALPHA + ALPHABIS + SP + OTHER1 + OTHER2 + OTHER3 + OTHER4;
		var vCharsFor = ALL;
		if (!isChampValid(pForm.nom,'Nom du domaine ',vCharsFor,4,80,true)) return false;
		return true;
}
/* Contrôle du secteur */
function isCategorieValid(pForm) {
		var ALL = NUM + ALPHA + ALPHABIS + SP + OTHER1 + OTHER2 + OTHER3 + OTHER4;
		var vCharsFor = ALL;
		if (!isChampValid(pForm.nom,'Titre de la catégorie ',vCharsFor,4,80,true)) return false;
		if (!isChampValid(pForm.nom,'Couleur de la catégorie de la manifestation ',vCharsFor,0,7,false)) return false;
		return true;
}
/* Contrôle thème */
function isGalerieValid(pForm) {
		var ALL = NUM + ALPHA + ALPHABIS + SP + OTHER1 + OTHER2 + OTHER3 + OTHER4 + OTHER5;
		var vCharsFor = ALL;
		if (!isChampValid(pForm.titre,'Titre de l\'image  ',vCharsFor,0,70,true)) return false;
		return true;
}

/* Contrôle de la zone de contenu back-offcie */
function isZoneContenuValid(pForm) {
	var ALL = NUM + ALPHA + ALPHABIS + SP + OTHER1 + OTHER2 + OTHER3 + OTHER4;
	var vCharsFor = ALL;

	//La langue
	var lng = getSelectedItemValue(pForm.liste_langue);
	if (lng.length == 0) {
		alert('Vous devez obligatoirement sélectionner une valeur dans la liste déroulante \'Langue\'');
		pForm.liste_langue.focus();
		return false;
	}
	//Modèle template
	var modele = getSelectedItemValue(pForm.modele);
	if ((modele.length == 0) || isNaN(modele)) {
		alert('Vous devez obligatoirement sélectionner une valeur dans la liste déroulante \'Modèle\'');
		pForm.modele.focus();
		return false;
	}
	//Titre
	if (!isChampValid(pForm.titre,'Titre de la zone de contenu',vCharsFor,1,255,true)) return false;

	if(pForm.modele.value == 161)
	{
		//Description
		if (!isChampValid(pForm.carte_decription_1,'Description du pavé 1',vCharsFor,1,1000000000,true)) return false;

		//Description
		if (!isChampValid(pForm.carte_decription_2,'Description du pavé 2',vCharsFor,1,1000000000,true)) return false;

		//Titre
		if (!isChampValid(pForm.carte_titre_1,'Description du pavé 3',vCharsFor,1,255,true)) return false;

		//Titre
		if (!isChampValid(pForm.carte_titre_2,'Description du pavé 4',vCharsFor,1,255,true)) return false;

		/*var doc = getSelectedItemValue(pForm.doc1_id);
		if (doc.length == 0 || isNaN(doc)) {
			alert('Vous devez obligatoirement sélectionner une valeur dans la liste déroulante \'Documents\'');
			pForm.doc1_id.focus();
			return false;
		}*/
	}
	return true;
}

//permet de faire apparaitre et disparaitre des div
//bool a true = visible, bool a rien = invisible
function onOff(id,bool)
{
	var element = document.getElementById(id);
	if(element)
	{
		if(bool)
		{
			element.style.display = '';
		}
		else
		{
			element.style.display = 'none';
		}
	}
}

function val(pUrl,mode){
	if(mode != null){
		document.pagination.from_pager.value=mode;
	}
	document.pagination.action=pUrl;
	document.pagination.submit();
}

function tri(pUrl,pColTri,pPreColTri,pOrder,form,target){

	if(form == null){
		document.formu.target="_parent";
		document.formu.coltri.value =pColTri;
		document.formu.precoltri.value = pPreColTri;
		document.formu.ordre.value = pOrder;
		document.formu.action=pUrl;
		document.formu.submit();
	} else {
		if(target == null){
			target = "_parent"
		}

		form.target= target;
		form.coltri.value =pColTri;
		form.precoltri.value = pPreColTri;
		form.ordre.value = pOrder;
		form.action=pUrl;
		form.submit();
	}
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

/**********************************************************************************************
	Gestion de l'envoi des formulaires
***********************************************************************************************/
function submitForm(pForm, pVerifOK) {
	if (pVerifOK)
		pForm.submit();
}

function subForm(pVerifOK) {

	if (pVerifOK)
		document.formu.submit();
}

function setModAct(pForm,plang,pacc,pid,pfile,pcombo) {
	var selectedRow = eval('document.forms[pForm].'+pcombo+'.options.selectedIndex');
	var value = eval('document.forms[pForm].'+pcombo+'.options[selectedRow].value');
	document.forms[pForm].action= "/" + pfile + "/" + plang+ "/" + pacc + "_" + pid + "_" + value +".htm";
	document.forms[pForm].submit();
}

function search_by_reference(pType,pUrl)
{

	switch(pType){
		case 1:
			document.formu.target="_parent";
			document.formu.new_s.value=1;
			document.formu.type_search.value="reference_seul";
			break;
		case 2:
			if(document.formu.reference){
				document.formu.reference.value="";
			}
			document.formu.type_search.value="attributs_seuls";
			break;
	}

	if(pUrl!=""){
		document.formu.action= pUrl;
		document.formu.submit();
	}
}

function setMsg(
			pStrCatalogueMillesime
			,pStrCatalogueJsGammeDePrix
			,pStrCatalogueJsPrixMin
			,pStrCatalogueJsGammeDePrix
			,pStrCatalogueJsPrixMax
			,pStrCatalogueJsMillesime
			,pStrCatalogueJsPrixMinMax
			,p_id,pphpLang,paccueil_id,pvar,pMillesime,pPrixmin,pPrixmax,pForm
			){
	if(pMillesime == null){
		var w_millesime = document.formu.w_millesime;
		var w_prix_debut = document.formu.w_prix_debut;
		var w_prix_fin = document.formu.w_prix_fin;
		var form = document.formu;
		document.formu.new_s.value=1;
		document.formu.target="_parent";

	} else {
		var w_millesime = pMillesime;
		var w_prix_debut = pPrixmin;
		var w_prix_fin = pPrixmax;
		var w_prix_fin = pPrixmax;
		var form = pForm;
	}
	switch(pvar)
	{
		case 0:
			//form.action="/index.php?ter_id="+p_id+"&amp;phpLang="+pphpLang+"&amp;accueil_id="+paccueil_id;
			form.action="/index.php/"+pphpLang+"/"+paccueil_id+"_"+p_id+".htm";
			break;
		case 1:
			form.action="/rubrique.php?rub_id="+p_id+"&amp;phpLang="+pphpLang+"&amp;accueil_id="+paccueil_id;
			break;
		case 2:
			form.action= "/page.php/" +pphpLang+ "/" +paccueil_id+ "_" +p_id+ ".htm#tableau";
			break;
		case 3:
			form.action= "/page.php/" +pphpLang+ "/" +paccueil_id+ "_" +p_id+ ".htm#tableau";
			break;
	}

	if((w_millesime.value < 1000
	|| w_millesime.value > 9999)
	&& w_millesime.value != "")
	{
		alert(pStrCatalogueJsMillesime);
		return(false);
	}

	if (!isFieldNumberValid(w_millesime, pStrCatalogueMillesime, 4, 4, false)) return false;
	if (!isChampValid(w_prix_debut,pStrCatalogueJsGammeDePrix, NUM, 1, 4, false)) return false;

	if((w_prix_debut.value!= "" && w_prix_fin.value == "")
		|| (w_prix_debut.value== "" && w_prix_fin.value != "")
	)
	{
			alert(pStrCatalogueJsPrixMinMax);
			return(false);
	}

	if((w_prix_debut.value < 1
	|| w_prix_debut.value > 9999)
	&& w_prix_debut.value!="")
	{
			alert(pStrCatalogueJsPrixMin);
			return(false);
	}
	else
	{
		if (!isChampValid(w_prix_fin,pStrCatalogueJsGammeDePrix, NUM, 1, 4, false))
		{
			return false;
		}
		else
		{
			if((w_prix_fin.value < 1
			&& w_prix_fin.value > 9999)
			&& w_prix_fin.value)
			{
				alert(pStrCatalogueJsPrixMax);
				return(false);
			}
		}
	}
	return(true);
}


function setVal(p_id,pphpLang,paccueil_id,pvar){
	document.formu.new_s.value=1;
	document.formu.target="_parent";
	var target = '';
	switch(pvar)
	{
		case 0:
			document.formu.action="/index.php/"+pphpLang+"/"+paccueil_id+"_"+p_id+".htm#tableau";
			break;
		case 1:
			document.formu.action="/rubrique.php?rub_id="+p_id+"&amp;phpLang="+pphpLang+"&amp;accueil_id="+paccueil_id;
			break;
		case 2:
			document.formu.action= "/page.php/" +pphpLang+ "/" +paccueil_id+ "_" +p_id+ ".htm#tableau";
			break;
		case 3:
			//Produit sélectionné
			var pro_id = getSelectedItemValue(document.formu.W_LISTE_PR_EVE);
			document.formu.action= "/index.php/" +pphpLang+ "/" + paccueil_id + "_" + p_id + "_" + pro_id + ".htm";
			break;
		case 4:
			//Produit sélectionné
			var pro_id = getSelectedItemValue(document.formu.W_LISTE_COFFRET);
			document.formu.action= "/index.php/" +pphpLang+ "/" + paccueil_id + "_" + p_id + "_" + pro_id + ".htm";
			break;
		case 5:
			document.formu.new_s.value=0;
			//Produit sélectionné
			var pro_id = getSelectedItemValue(document.formu.W_LISTE_COFFRET);
			document.formu.action= "/page.php/" +pphpLang+ "/" + paccueil_id + "_" + p_id + "_" + pro_id + ".htm";
			document.formu.submit()
			break;
		case 6:
			//Liste des coffrets
			document.formu.W_LISTE_COFFRET.value=1;
			document.formu.action="/index.php/"+pphpLang+"/"+paccueil_id+"_"+p_id+".htm";
			break;
		case 7:
			document.formu.new_s.value=0;
			//Produit sélectionné
			document.formu.W_LISTE_COFFRET.value=1;
			document.formu.action= "/page.php/" +pphpLang+ "/" + paccueil_id + "_" + p_id + ".htm";
			document.formu.submit();
			break;
		case 8:
		case 10:
			//Coffret sélectionné dans la combobox : pour afficher le détail du produit
			var pro_id = getSelectedItemValue(document.formu.W_LISTE_COFFRET_1);
			if(pvar==8){
				//On vient des écrans des HP
				target = "/index.php/";
			}else{
				//On vient des écrans accessibles à partir des zones de contenu et HP rubriques
				target = "/page.php/";
			}
			document.formu.action= target + pphpLang+ "/" + paccueil_id + "_" + p_id + "_" + pro_id + ".htm";
			document.formu.submit();
			break;
		case 9:
			//On vient de la navigation gauche avec selection des zones de contenu spéciaux
			document.formu.new_s.value=0;
			document.formu.action= "/page.php/" +pphpLang+ "/" + paccueil_id + "_" + p_id + ".htm";
			document.formu.submit();
			break;
	}
	return(true);
}

function dateJourPlus(nb){
	var d= new Date();
	d.setDate(d.getDate()+nb);
	var strDay = (d.getDate()<10?"0":"")+d.getDate();
	var month = d.getMonth()+1;
	var strMonth = (month<10?"0":"")+month;
	dateJourPlusUnMois = new Date(d.getFullYear(),strMonth,strDay);
	dateJourPlusUnMoisTime = dateJourPlusUnMois.getTime();
	return dateJourPlusUnMoisTime;
}
function setValListe(p_id, pphpLang, paccueil_id, pmsg, palerte, alerte){
	document.formu.new_s.value=1;
	document.formu.target="_parent";
	var id_theme = getSelectedItemValue(document.formu.W_THEME_CADEAUX);
	if (id_theme.length == 0 || isNaN(id_theme)) {
			alert(pmsg);
			document.formu.id_theme.focus();
			return false;
	}
	// Vérifier la date de clôture par rapport à la date du jour
	var date_cloture = document.formu.date_cloture.value;
	var tableau = date_cloture.split('/');
	dateSaisie = new Date(tableau[2],tableau[1],tableau[0]);
	dateSaisieTime = dateSaisie.getTime();

	//Date du jour + 30 jours
	dateJourPlusUnMoisTime=dateJourPlus(30);

	if(dateSaisieTime>dateJourPlusUnMoisTime){
		alert(palerte);
		return false;
	}

	var date=dateJourPlus(0);
	if(dateSaisieTime<=date){
		alert(alerte);
		return false;
	}
	return(true);
}


function verifDateNaissance(date){
	// Vérifier la date de clôture par rapport à la date du jour
	var tableau = date.split('/');

	//Date du jour
	var d= new Date();
	d.setDate(d.getDate());

	var strDay = (d.getDate()<10?"0":"")+d.getDate();
	var month = d.getMonth()+1;
	var strMonth = (month<10?"0":"")+month;
	dateJour = new Date(d.getFullYear(),strMonth,strDay);
	dateJourTime = dateJour.getYear();

	if((d.getFullYear()-tableau[2]) < 18)
	{
		return false;
	}
	return(true);
}


function compPrix(pX1,pX2){
	if(eval(pX2) < eval(pX1))
	{
		alert(pStrCatalogueJsPrixMinPrixMax);
		return(false);
	}
	else
	{
		return(true);
	}
}

function setValCoffret(pId,pType){
	//W_EVE_TYPE  0
	//W_PROD_TYPE 1
	document.formu.voir.value=1;
	switch(pType){
		case 0:
			for(var i=0; i < document.formu.W_EVE_TYPE.options.length;i++)
			{
				vValue = document.formu.W_EVE_TYPE.options[i].value;
				if(pId == vValue){
					document.formu.W_EVE_TYPE.options[i].selected = true;
					break;
				}
			}
			//C'est un événement qui est sélectionné à afficher
			break;
		case 1:
			for(var i=0; i < document.formu.W_PROD_TYPE.options.length;i++)
			{
				vValue = document.formu.W_PROD_TYPE.options[i].value;
				if(pId == vValue){
					document.formu.W_PROD_TYPE.options[i].selected = true;
					break;
				}
			}
			//C'est un produit qui est sélectionné à afficher
			break;
	}
}

function maj_item(mod)
{
	if(mod == 141 || mod == 143 || mod == 136 || mod == 145 || mod == 140 || mod == 133)
	{
		//Catalogue
		if (document.getElementById('ty_blo_co_1')) {
			document.getElementById('ty_blo_co_1').style.display = 'none';
		}
		if (document.getElementById('ty_blo_ca_1')) {
			document.getElementById('ty_blo_ca_1').style.display = '';
		}
		if (document.getElementById('ty_blo_co_2')) {
			document.getElementById('ty_blo_co_2').style.display = 'none';
		}
		if (document.getElementById('ty_blo_ca_2')) {
			document.getElementById('ty_blo_ca_2').style.display = '';
		}
		if (document.getElementById('ty_blo_co_3')) {
			document.getElementById('ty_blo_co_3').style.display = 'none';
		}
		if (document.getElementById('ty_blo_ca_3')) {
			document.getElementById('ty_blo_ca_3').style.display = '';
		}

	}
	else if(mod == 150 || mod == 149 || mod == 138 || mod == 152 || mod == 151)
	{
		//Coffrets
		if (document.getElementById('ty_blo_co_1')) {
			document.getElementById('ty_blo_co_1').style.display = '';
		}
		if (document.getElementById('ty_blo_ca_1')) {
			document.getElementById('ty_blo_ca_1').style.display = 'none';
		}
		if (document.getElementById('ty_blo_co_2')) {
			document.getElementById('ty_blo_co_2').style.display = '';
		}
		if (document.getElementById('ty_blo_ca_2')) {
			document.getElementById('ty_blo_ca_2').style.display = 'none';
		}
		if (document.getElementById('ty_blo_co_3')) {
			document.getElementById('ty_blo_co_3').style.display = '';
		}
		if (document.getElementById('ty_blo_ca_3')) {
			document.getElementById('ty_blo_ca_3').style.display = 'none';
		}

	}
}

function maj_div(mod)
{
	if(mod == 141 || mod == 143 || mod == 136 || mod == 145 || mod == 140 || mod == 133)
	{

		//Display promo et catalogue
		if (document.getElementById('catalogue_1')) {
			document.getElementById('catalogue_1').style.display = 'none';
		}
		if (document.getElementById('catalogue_2')) {
			document.getElementById('catalogue_2').style.display = 'none';
		}
		if (document.getElementById('catalogue_3')) {
			document.getElementById('catalogue_3').style.display = 'none';
		}
		if (document.getElementById('promo_1')) {
			document.getElementById('promo_1').style.display = 'none';
		}
		if (document.getElementById('promo_2')) {
			document.getElementById('promo_2').style.display = 'none';
		}
		if (document.getElementById('promo_3')) {
			document.getElementById('promo_3').style.display = 'none';
		}
		//layers Coffrets
		if (document.getElementById('coffret_1')) {
			document.getElementById('coffret_1').style.display = 'none';
		}
		if (document.getElementById('coffret_2')) {
			document.getElementById('coffret_2').style.display = 'none';
		}
		if (document.getElementById('coffret_3')) {
			document.getElementById('coffret_3').style.display = 'none';
		}
	}
	else if(mod == 150 || mod == 149 || mod == 138 || mod == 152 || mod == 151)
	{

		//Not display catalogue et promo
		if (document.getElementById('promo_1')) {
			document.getElementById('promo_1').style.display = 'none';
		}

		if (document.getElementById('promo_2')) {
			document.getElementById('promo_2').style.display = 'none';
		}
		if (document.getElementById('promo_3')) {
			document.getElementById('promo_3').style.display = 'none';
		}
		if (document.getElementById('catalogue_1')) {
			document.getElementById('catalogue_1').style.display = 'none';
		}
		if (document.getElementById('catalogue_2')) {
			document.getElementById('catalogue_2').style.display = 'none';
		}
		if (document.getElementById('catalogue_3')) {
			document.getElementById('catalogue_3').style.display = 'none';
		}
		//Display coffret
		if (document.getElementById('coffret_1')) {
			document.getElementById('coffret_1').style.display = '';
		}
		if (document.getElementById('coffret_2')) {
			document.getElementById('coffret_2').style.display = '';
		}
		if (document.getElementById('coffret_3')) {
			document.getElementById('coffret_3').style.display = '';
		}
	}
}

function strstr( haystack, needle, bool ) {
	var pos = 0;
	pos = haystack.indexOf( needle );
	if( pos == -1 ){
		return false;
	} else{
		if( bool ){
			return haystack.substr( 0, pos );
		} else{
			return haystack.slice( pos );
		}
	}
}

function isDisplayCombo(id) {

	if(document.getElementById(id).style.display == ''){
		return true;
	}
	return false;
}

function pos_flag(valeur)
{
	document.getElementById('display').value=valeur;
	if(valeur==2){
		//Désélectionner la combo des adresses livraison
		ref=document.getElementById("id_select_adr");
		ref.selectedIndex=-1;
	}
	document.form_coord.submit();
}

function modif_champ_verif(valeur)
{
	document.getElementById('test_verifier_repartition').value = valeur;
}

function deselectionner(id,c)
{
	ref=document.getElementById(id);
	ref.selectedIndex=-1;

	switch(c){
		case 1:
			if(id=="id_select_adr_exp"){
				// Il s'agit des adresses expéditeur
				document.form_coord.c_societe.value="";
			}else{
				document.form_coord.s_societe.value="";
			}
			break;
		case 2:
			if(id=="id_select_adr_exp"){
				// Il s'agit des adresses expéditeur
				document.form_coord.c_nom.value="";
			}else{
				document.form_coord.s_nom.value="";
			}
			break;
	}
	document.form_coord.submit();
}

function verifField(id){
	if(document.getElementById(id).style.display=='none')
	{
		return false;
	}else{
		return true;
	}
}

function verifCodePromo(pForm){

	var ALL = NUM + ALPHA + ALPHABIS + SP + OTHER1 + OTHER2 + OTHER3 + OTHER4 + OTHER5;
	if (!isChampValid(pForm.cop_code_promotion,'Code promotion',ALPHA+NUM,7,15,true)) return false;
	else if (!isChampValid(pForm.cop_date_debut,'début',ALL,10,10,true)) return false;
	if (!valideDate(pForm.cop_date_debut.value, 'début')) {
		pForm.cop_date_debut.focus();
		return false;
	}

	if (!isChampValid(pForm.cop_date_fin,'fin',ALL,10,10,true)) return false;
	if (!valideDate(pForm.cop_date_fin.value, 'fin')) {
		pForm.cop_date_fin.focus();
		return false;
	}

	var type = getSelectedItemValue(pForm.cop_type_promotion);
	if (type == "")
	{
			alert("Vous devez sélectionner une valeur dans la liste déroulante \"Type de promotion\".");
			return false;
	}
	//Montant minimum
	if(verifField("id_montant_mini")){
		if (!isChampValid(pForm.cop_montant_minimum,'Montant minimum de la commande',NUM+'.',0,7,true)) return false;
	}

	//Montant remise
	if(verifField("id_montant_remise")){
		pForm.cop_montant_remise_p.value="";
		if (!isChampValid(pForm.cop_montant_remise,'Montant à déduire',NUM+'.',0,7,true)) return false;
	}

	//Pourcentage
	if(verifField("id_pourcentage")){
		pForm.cop_montant_remise.value="";
		if (!isChampValid(pForm.cop_montant_remise_p,'Pourcentage de réduction',NUM+'.',0,3,true)) return false;
	}
	//Pays
	/*if(verifField("id_pays")){
		var pays = getSelectedItemValue(pForm.pays);
		if (pays == "")
		{
			alert("Vous devez sélectionner une valeur dans la liste déroulante \"Pays\".");
			return false;
		}
	}*/

	if (!isChampValid(pForm.cop_commentaire_fr,'Commentaire en Français',ALL,0,2000,true)) return false;
	else if (!isChampValid(pForm.cop_commentaire_en,'Commentaire en Anglais',ALL,0,2000,true)) return false;

	//Produits à acheter
	if(verifField("id_produits_acheter")){
		if (!isChampValid(pForm.cop_qte_a_acheter,'Quantité à acheter',NUM,1,4,true)) return false;
		else if(pForm.cop_qte_a_acheter.value==0){
			alert("Vous devez saisir la quantité à achetere.");
				return false;
		}
		else if(pForm.pro_ach.value=="" || pForm.pro_ach.value==0){
			alert("Vous devez sélectionner le produit à acheter");
			return false;
		}
	}

	//Produits à offrir
	if(verifField("id_produits_offrir")){
		if (!isChampValid(pForm.cop_qte_a_offrir,'Quantité à offrir',NUM,1,4,true)) return false;
		else if(pForm.cop_qte_a_offrir.value==0){
			alert("Vous devez saisir la quantité à offrir.");
				return false;
		}
		if(pForm.pro_off.value=="" || pForm.pro_off.value==0){
			alert("Vous devez sélectionner le produit à offrir");
			return false;
		}

	}

	if(!isOneRadioButtonChecked(pForm.online)){
		alert("Vous devez indiquer si le code est publié ou non!");
		return false;
	}
	return true;
}

function verifCp(pForm){

	var ALL = NUM + ALPHA;
	if (!isChampValid(pForm.code_promo,'Code promotion',ALPHA+NUM,7,15,false)) return false;

	return true;
}
/* Affichage d'une animation flash avec focus direct (IE, Opera, Firefox) */
function InsertFlash(data, width, height, transparent, base) {
var swf = '<object' + ' type="application/x-shockwave-flash" data="' + data
	+ '" width="' + width + '" height="' + height + '">\n';
swf += '<param name="movie" value="' + data + '" />\n';
if (transparent == true) {
	swf += '<param name="wmode" value="transparent" />\n';
	swf += '<param value="transparent" name="embed"  />\n';
	if (base != '') {
	swf += '<param name="base" value="' + base + '"  />\n';
	}
}
swf += '<embed src="' + data
	+ '" pluginspage="http://www.macromedia.com/go/getflashplayer'
	+ '" width="' + width + '" height="' + height + '"';

if (base != '') {
	swf += ' base="' + base + '"';
}
swf += ' type="application/x-shockwave-flash">' + '</embed>\n';
swf += '</object>\n';
document.write(swf);
return;
}

function getserverresponse(strURL,type,num,bloc,typedata)
{

	// Mozilla/Safari
	if (window.XMLHttpRequest) {
	self.eval('xmlHttpReq'+type+'= new XMLHttpRequest()');
	}

	// IE
	else if (window.ActiveXObject) {
		self.eval('xmlHttpReq'+type+'= new ActiveXObject("Microsoft.XMLHTTP")') ;
	}

	self.eval('xmlHttpReq'+type).open('POST', strURL, true);
	//alert(strURL);
	self.eval('xmlHttpReq'+type).setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

	self.eval('xmlHttpReq'+type).onreadystatechange = function() {
	if (self.eval('xmlHttpReq'+type).readyState == 4) {
		res = self.eval('xmlHttpReq'+type).responseText;
		if(typedata==1)
		{
		  $('#modele4_albums_image_b'+bloc+'_combo2').html(res);
			 
		}else{
	   	$('modele4_albums_flash_b'+bloc+'_combo2').html(res);
		}
 
	}
}
self.eval('xmlHttpReq'+type).send(strURL);
}

function getImg(id,num,bloc,option,typedata)
{
	if (option[0].checked || option[1].checked)
	{
		url="getImg.php?value="+id+"&num="+num+"&bloc="+bloc;
		getserverresponse(url,1,num,bloc,typedata);
	}else{
		alert("Veuillez sélectionner le type d'album.");
		return false;

	}
}

function verifMotCle(pForm){

	//On détermine le nombre de champ formulaire VAL_
	var nb_field = 0;
	var nb_field_f = 0;
	for(var i=0; i<pForm.length; i++) {
		var e = pForm.elements[i];
		if(e.type == "text" && !e.name.indexOf("VAL_")){
			nb_field++;
		}
	}

	var empty_fields="";
	var cpt = 0;
	for(var i=0; i<pForm.length; i++){
		var e = pForm.elements[i];
		if(e.type == "text" && !e.name.indexOf("VAL_"))
		{
			cpt++;

			if(e.value == "" && pForm.id_deleted.value.indexOf(e.value))
			{
				empty_fields="Le champ 'Libellé' est obligatoire !";
				if(cpt==nb_field && cpt!=1){
					empty_fields="";
				}
				i=pForm.length+1;
			}
		}
	}

	if(empty_fields){
		alert(empty_fields);
		return false;
	}
	return true;
}
