var NUM = '0123456789';
var ALPHA = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var ALPHABIS = 'âäàåéêëèïîìôöòüûùÿÄÅÉæÆÖÜÇç';
var SP = ' ';
var OTHER1 = '-\'';
var OTHER2 = '_$&@"';
var OTHER3 = '~{([|`\^)]}=+*/,?;.:!§%µ¨£¤<>²_$&@"-\'';
var OTHER4 = '#';
var OTHER5 = '€';
var PONCTUATION = '€_-&=#@';
var PASSWORD = '\w';
var MAIL = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{4}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/

// *******************************************************************************************
//
// 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 (pFieldLengthMax > 0) { // Verification de nombre de caracteres
        // maximum
        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;
}

function verif_pass(value) {
  if (!(/\S{6,12}/.test(value))) {
    return false;
  }

  return true;
}

function verif_email(value) {
  var regex = /^[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]+(\.[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]+)*@(([a-z0-9]([-a-z0-9]*[a-z0-9]+)?){1,63}\.)+([a-z0-9]([-a-z0-9]*[a-z0-9]+)?){2,63}$/i;

  if (value == "") {
    return false;
  }

  if (!(regex.test(value))) {
    return false
  }
  return true;
}

/* 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;
}

function onOffAuto(id) {
  var element = document.getElementById(id);
  if (element) {
    if (element.style.display == 'none') {
      element.style.display = 'block';
    } else {
      element.style.display = 'none';
    }
  }
}

function setMsg(pStrChantierField, pForm) {

  var w_annee = getSelectedItemValue(pForm.annee);
  var w_pays = getSelectedItemValue(pForm.pays);
  var w_activite = getSelectedItemValue(pForm.activite);

  if (w_annee.length == 0 && w_pays.length == 0 && w_activite.length == 0) {
    alert(pStrChantierField);
    return (false);
  }
  return (true);
}

function setMsgPag(pStrActiviteField, pForm) {

  var w_activite = getSelectedItemValue(pForm.combo_page);

  if (w_activite.length == 0) {
    alert(pStrActiviteField);
    return (false);
  }
  return (true);
}

function setValue(pVal, pUrl, pForm) {

  for ( var i = 0; i < pForm.activite.options.length; i++) {
    if (pForm.activite.options[i].selected == true) {
      pForm.activite.options[i].selected = false;
    }
  }

  for ( var i = 0; i < pForm.pays.options.length; i++) {
    if (pForm.pays.options[i].selected == true) {
      pForm.pays.options[i].selected = false;
    }
  }

  for ( var i = 0; i < pForm.annee.options.length; i++) {
    if (pForm.annee.options[i].selected == true) {
      pForm.annee.options[i].selected = false;
    }
  }

  document.chantier.action = pUrl;
  document.chantier.type_search.value = "All";
  document.chantier.submit();
}

function setValuePag(pVal, pUrl, pForm) {

  for ( var i = 0; i < pForm.combo_page.options.length; i++) {
    if (pForm.combo_page.options[i].selected == true) {
      pForm.combo_page.options[i].selected = false;
    }
  }

  document.recherche.action = pUrl;
  document.recherche.type_search.value = "All";
  document.recherche.submit();
}

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

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

function see_projet_1() {

  document.getElementById("onglets").innerHTML = "<img onclick='see_projet_1()' alt='' src='/images/webrazel/activites_on.gif' border='0' /><img onclick='see_video_1()' alt='' src='/images/webrazel/images_off.gif' border='0' />";
  document.getElementById("video1").style.display = "none";
  document.getElementById("projet").style.display = "block";
}

function see_video_1() {
  document.getElementById("onglets").innerHTML = "<img onclick='see_projet_1()' alt='' src='/images/webrazel/activites_off.gif' border='0' /><img onclick='see_video_1()' alt='' src='/images/webrazel/images_on.gif' border='0' />";
  document.getElementById("projet").style.display = "none";
  document.getElementById("video1").style.display = "block";
}

function see_projet() {

  document.getElementById("onglets").innerHTML = "<img onclick='see_projet()' alt='' src='/images/webrazel/projet_on.gif' border='0' /><img onclick='see_video()' alt='' src='/images/webrazel/images_off.gif' border='0' />";
  document.getElementById("video1").style.display = "none";
  document.getElementById("projet").style.display = "block";
}
function see_video() {
  $("#onglets").empty();
  $("#onglets")
      .append(
          "<img onclick='see_projet()' alt='' src='/images/webrazel/projet_off.gif' border='0' /><img onclick='see_video()' alt='' src='/images/webrazel/images_on.gif' border='0' />");
  $("#projet").css( {
    display :"none"
  });
  $("#video1").css( {
    display :"block"
  });
}
function see_video_old() {
  document.getElementById("onglets").innerHTML = "<img onclick='see_projet()' alt='' src='/images/webrazel/projet_off.git' border='0' /><img onclick='see_video()' alt='' src='/images/webrazel/images_on.gif' border='0' />";
  document.getElementById("projet").style.display = "none";
  document.getElementById("video1").style.display = "block";
}

function viewVideo(vid) { // v2.0
  window
      .open(
          '/showvideo.php?video=' + vid,
          'Viewer',
          'resizable=no, location=no, width=430, height=500, top=70,left=350, menubar=no, status=no, scrollbars=no, menubar=no');
}

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

/* 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;
}