
window.debug=(function(){var i=this,b=Array.prototype.slice,d=i.console,h={},f,g,m=9,c=["error","warn","info","debug","log"],l="assert clear count dir dirxml exception group groupCollapsed groupEnd profile profileEnd table time timeEnd trace".split(" "),j=l.length,a=[];while(--j>=0){(function(n){h[n]=function(){m!==0&&d&&d[n]&&d[n].apply(d,arguments)}})(l[j])}j=c.length;while(--j>=0){(function(n,o){h[o]=function(){var q=b.call(arguments),p=[o].concat(q);a.push(p);e(p);if(!d||!k(n)){return}d.firebug?d[o].apply(i,q):d[o]?d[o](q):d.log(q)}})(j,c[j])}function e(n){if(f&&(g||!d||!d.log)){f.apply(i,n)}}h.setLevel=function(n){m=typeof n==="number"?n:9};function k(n){return m>0?m>n:c.length+m<=n}h.setCallback=function(){var o=b.call(arguments),n=a.length,p=n;f=o.shift()||null;g=typeof o[0]==="boolean"?o.shift():false;p-=typeof o[0]==="number"?o.shift():n;while(p<n){e(a[p++])}};return h})();
function AntiSpam(liste){
  var courriel = "";
  var texte  = "";
  var subject = "";
  var onClick = "";
  var tableau = liste.split('|');
   
  
  var tableauCourriel = tableau[0].split(',');
  for (i=0;i<tableauCourriel.length;i++)
   courriel+=String.fromCharCode(tableauCourriel[i]);
   
   
  if ((tableau.length>=2) && (tableau[1].length > 0)){
  var tableauTexte = tableau[1].split(',');
}

  if ((typeof(tableauTexte) != 'undefined') && (tableauTexte.length > 0)){
  for (i=0;i<tableauTexte.length;i++)
   texte+=String.fromCharCode(tableauTexte[i]);
 }
  else
   texte = courriel;

  
   
  if ((tableau.length>=3) && (tableau[2].length > 0))
  subject = tableau[2];
 else{
 var domaine = "http://" + window.location.toString().split("//")[1].split("/")[0] + "/";
 subject = "Demande via le site Internet " + domaine;
 } 

   
  if ((tableau.length>=4) && (tableau[3].length > 0)){
  onClick = tableau[3] + ';';
 }

  tableauTexte = texte.split("@");
  
  if (tableauTexte.length == 2){
   texte = tableauTexte[0] + '<span style="display:none;">[REMOVE-THIS-FOR-SPAM]</span>&#64;' + tableauTexte[1];
 }
   
  return('<a href="mailto:a" onclick="' + onClick + 'this.href = AntiSpamClic(Array(' + tableauCourriel + '),\'' + subject + '\');">' + texte + '</a>');
}

function AntiSpamClic(tableauCourriel, subject){
  var courriel = "";
  for (i=0;i<tableauCourriel.length;i++)
   courriel+=String.fromCharCode(tableauCourriel[i]);
  if (subject.length > 0)
   courriel+= '?subject=' + subject;
  return 'mai' + 'lto:' + courriel;
}
 
String.prototype.Ltrim = function() {
 return this.replace(/^\s+/,"");
}
String.prototype.Rtrim = function() {
 return this.replace(/\s+$/,"");
}

String.prototype.CorrigerSerialize = function() {
 return this.replace(/%E2%80%99/g,"'").replace(/%E2%80%93/g,"-");
}


function print_r(x, max, sep, l) {

 l = l || 0;
 max = max || 10;
 sep = sep || ' ';

 if (l > max) {
 return "[WARNING: Too much recursion]\n";
}

 var
 i,
 r = '',
 t = typeof x,
 tab = '';

 if (x === null) {
 r += "(null)\n";
} else if (t == 'object') {

 l++;

 for (i = 0;i < l;i++) {
  tab += sep;
}

 if (x && x.length) {
  t = 'array';
}

 r += '(' + t + ") :\n";

 for (i in x) {
  try {
  r += tab + '[' + i + '] : ' + print_r(x[i], max, sep, (l + 1));
 } catch(e) {
  return "[ERROR: " + e + "]\n";
 }
}

} else {

 if (t == 'string') {
  if (x == '') {
  x = '(empty)';
 }
}

 r += '(' + t + ') ' + x + "\n";

}

 return r;

};



var JSON = JSON || {};

// implement JSON.stringify serialization
JSON.stringify = JSON.stringify || function (obj) {

 var t = typeof (obj);
 if (t != "object" || obj === null) {

 // simple data type
 if (t == "string") obj = '"'+obj+'"';
 return String(obj);

}
 else {

 // recurse array or object
 var n, v, json = [], arr = (obj && obj.constructor == Array);

 for (n in obj) {
  v = obj[n];t = typeof(v);

  if (t == "string") v = '"'+v+'"';
  else if (t == "object" && v !== null) v = JSON.stringify(v);

  json.push((arr ? "" : '"' + n + '":') + String(v));
}

 return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
}
};


// implement JSON.parse de-serialization
JSON.parse = JSON.parse || function (str) {
 if (str === "") str = '""';
 eval("var p=" + str + ";");
 return p;
};
 
function CompterCliques(nomFichier){
 
 var donnees = 'nomFichier=' + nomFichier;
 $.ajax({
 url: "/utilitaires/compterCliques.php",
 type: "POST",
 cache: false,
 data: donnees,
  "error": function (XMLHttpRequest, textStatus, errorThrown) {
   alert( "Erreur");
   if (DevMode()){
 alert(XMLHttpRequest.status + XMLHttpRequest.responseText + ' ' + textStatus + ' ' + errorThrown);
  }   
 },
  success: function(resultat){
   if (DevMode())
   alert(print_r(resultat));
 }  
   
});
 return false;
}

//Fonctions pour traiter des dates
var re_date = /^\d{1,2}\-\d{1,2}\-\d{4}$/;
var tempo = new Array();
var max_mois = new Array();
for (n=1;n<100;n++)
  {
  if (n==4 || n==6 || n==9 || n==11)
   max_mois[n] = 30;
  else
   max_mois[n] = 31;
 }

function valideDate(dateSaisie)
  {
  t_date = re_date.test(dateSaisie);

  if (t_date)
   t_date = t_date && analyse(dateSaisie,1,2,3);

  return t_date;
 }

function analyse(quoi,p_jour,p_mois,p_an)
  {
  tempo = quoi.split('-');
  jour = eval(tempo[(p_jour-1)]);
  mois = eval(tempo[(p_mois-1)]);
  an = eval(tempo[(p_an-1)]);

  if (bisx(an))
   max_mois[2] = 29;
  else
   max_mois[2] = 28;

  t_tempo = (jour<=max_mois[mois] && mois<=12 && mois>=1 && jour>=1);

  return t_tempo;
 }

function bisx(quoi)
  {
  if ((quoi % 100 == 0) && (quoi % 400 == 0))
   return true;
  else if ((quoi % 4) == 0)
   return true;

  return false;
 }

function DateAdd(startDate, numDays, numMonths, numYears)
  {
  var returnDate = new Date(startDate.getTime());
  var yearsToAdd = numYears;
  var month = returnDate.getMonth() + numMonths;
  if (month > 11)
   {
   yearsToAdd = Math.floor((month+1)/12);
   month -= 12*yearsToAdd;
   yearsToAdd += numYears;
  }
  returnDate.setMonth(month);
  returnDate.setFullYear(returnDate.getFullYear() + yearsToAdd);
  returnDate.setTime(returnDate.getTime()+60000*60*24*numDays);
  return returnDate;
 }

function YearAdd(startDate, numYears)
  {
  return DateAdd(startDate,0,0,numYears);
 }

function MonthAdd(startDate, numMonths)
  {
  return DateAdd(startDate,0,numMonths,0);
 }

function DayAdd(startDate, numDays)
  {
  return DateAdd(startDate,numDays,0,0);
 }

function DateDiff(date1, date2)
  {
  diff = new Date();

  diff.setTime(date1.getTime() - date2.getTime());
  timediff = diff.getTime();
  days = Math.floor(timediff / (1000 * 60 * 60 * 24));
  timediff -= days * (1000 * 60 * 60 * 24);
  return days;
 }

function Langue(valeur, position){
  if (typeof(position) == 'undefined')
 return langue[valeur];
 else
 return langue[valeur][position];
}  
  




$.extend({
 getUrlVars: function(){
  var vars = [], hash;
  var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
  for(var i = 0;i < hashes.length;i++)
  {
   hash = hashes[i].split('=');
   vars.push(hash[0]);
   vars[hash[0]] = hash[1];
 }
  return vars;
},
 getUrlVar: function(name){
  return $.getUrlVars()[name];
} 
});


var devMode = false;

$(function() {
  if ($.getUrlVar("devMode") == 1) 
 devMode = true;
});

function DevMode(){
 return devMode;
}
var decalageH2eNiveau=20;
var decalageH3eNiveau=15;
var decalageV3eNiveau=-10;

var delaiAffichage=250;

function activerMenus(idMenuAActiver,vitesseTransitionMenu)
 {
 $('ul#'+idMenuAActiver+' li ul>li:first-child').not('ul#'+idMenuAActiver+' div ul li').addClass('premier');
 $('ul#'+idMenuAActiver+' li ul>li:last-child').not('ul#'+idMenuAActiver+' div ul li').addClass('dernier');
 $('ul#'+idMenuAActiver+' li ul').not('ul#'+idMenuAActiver+' div ul').css('display','block').css('visibility','hidden').each(function(){
 $(this).css('height',$(this).height()+'px')
});
 
 
//$('ul#'+idMenuAActiver+'>li>a').wrapInner('<span class="centre"></span>')
//$('ul#'+idMenuAActiver+'>li>a').prepend('<span class="gauche"></span>')
//$('ul#'+idMenuAActiver+'>li>a').append('<span class="droite"></span>')
 
 $('ul#'+idMenuAActiver+' li.premier').prepend('<span class="fond">&nbsp;</span>')
 $('ul#'+idMenuAActiver+' li.dernier').prepend('<span class="fond">&nbsp;</span>')
 $('ul#'+idMenuAActiver+' li.dernier').each(function(){
 $(this).css('background-position','-364px -'+(124-$(this).outerHeight()+30)+'px')
})
 
 
 
 $('ul#'+idMenuAActiver+' li a').not('ul#'+idMenuAActiver+' li ul li a').prepend('<span class="fixPlein"></span>');
 $('ul#'+idMenuAActiver+' li span.fixPlein').each(function(){
 var paddingHaut=parseInt($(this).parent().css('padding-top').substr(0,$(this).parent().css('padding-top').length-2));
 var hauteurLien=$(this).parent().height();
 var hauteurFix=0
 if(jQuery.browser.msie){
  var hauteurFix=(paddingHaut*2)
}else{
  var hauteurFix=(paddingHaut*2)+hauteurLien
}
 
 $(this).css('height',hauteurFix+'px');
 $(this).css('width',$(this).parent().outerWidth()+'px');
})
 $('ul#'+idMenuAActiver+' li ul').not('ul#'+idMenuAActiver+' li div ul').css('display','none').css('visibility','visible');
 
 $('ul#'+idMenuAActiver+' li ul').not('ul#'+idMenuAActiver+' div ul').parent().find('>a').addClass('avecSousMenus')
 
 $('ul#'+idMenuAActiver+' li ul').parent().each(function(){
 $(this).find('>a').css('z-index','50');
 $(this).children().not('a,span').css('z-index','99');
 if($(this).parent().attr('id')==idMenuAActiver){
  //2e niveau
  if($(this).offset().left-decalageH2eNiveau+$(this).children().not('a,span').outerWidth() < $(window).width()){
  $(this).children().not('a,span').css('left',(decalageH2eNiveau*-1)+'px');
 }
  else
  {
  var differenceMenus=($(this).outerWidth()-$(this).children().not('a,span').outerWidth());
  $(this).children().not('a,span').css('left',(differenceMenus+decalageH2eNiveau)+'px');
 }
 }
  else
  {
  //3e,4e,5e... niveau
  if($(this).offset().left-decalageH2eNiveau+$(this).children().not('a,span').outerWidth()+$(this).outerWidth() < $(window).width()){
  $(this).children().not('a,span').css('left',($(this).outerWidth()-decalageH3eNiveau+1)+'px');
  $(this).children().not('a,span').css('top',decalageV3eNiveau+'px');
 }
  else{
  $(this).children().not('a,span').css('left',(1+decalageH3eNiveau-$(this).children().not('a,span').outerWidth())+'px');
  $(this).children().not('a,span').css('top',decalageV3eNiveau+'px');
 }
 }
})
 
 
 
 
 //detection sousMenusOuvert
 $('ul#'+idMenuAActiver+' li ul,ul#'+idMenuAActiver+' li div').not('ul#'+idMenuAActiver+' li div ul').parent().mouseover(function(){
 $(this).stop(true,true);
 $(this).children().not('a,span').stop(true,true);
 if($(this).children().not('a,span').css('display')!='block'){
  $(this).delay(delaiAffichage).queue(function(){
  $(this).find('>a').addClass('actif');
  $(this).children().not('a,span').stop(true,true).attr('style','display:none;visibility:visible;');
  $(this).children().not('a,span').css('overflow','hidden');
  $(this).children().not('a,span').clearQueue().slideDown(vitesseTransitionMenu,function(){$(this).css('overflow','visible')});
  
  $(this).siblings('li').each(function(){
  $(this).clearQueue();
   $(this).clearQueue();
   if($(this).children().not('a,span').length > 0){
   $(this).children().not('a,span').stop(true,true);
   if($(this).children().not('a,span').css('display') != 'none'){
 $(this).children().not('a,span').delay(delaiAffichage/2).queue(function(){
 $(this).parent().css('z-index','50');
 $(this).parent().find('>a').removeClass('actif');
 $(this).dequeue();
})
 .fadeOut(vitesseTransitionMenu,function(){$(this).attr('style','display:none;visibility:visible;');$(this).clearQueue()});
  }
  }
 })
  
  $(this).css('z-index','99');
  //position d'affichage par rapport au niveau
  if($(this).parent().attr('id')==idMenuAActiver){
  //2e niveau
  if($(this).offset().left-decalageH2eNiveau+$(this).children().not('a,span').outerWidth() < $(window).width()){
   $(this).children().not('a,span').css('left',(decalageH2eNiveau*-1)+'px');
  }
   else
   {
   var differenceMenus=($(this).outerWidth()-$(this).children().not('a,span').outerWidth());
   $(this).children().not('a,span').css('left',(differenceMenus+decalageH2eNiveau)+'px');
  }
 }else{
  //3e,4e,5e... niveau
  if($(this).offset().left-decalageH2eNiveau+$(this).children().not('a,span').outerWidth()+$(this).outerWidth() < $(window).width()){
   $(this).children().not('a,span').css('left',($(this).outerWidth()-decalageH3eNiveau+1)+'px');
   $(this).children().not('a,span').css('top',decalageV3eNiveau+'px');
  }else{
   $(this).children().not('a,span').css('left',(1+decalageH3eNiveau-$(this).children().not('a,span').outerWidth())+'px');
   $(this).children().not('a,span').css('top',decalageV3eNiveau+'px');
 }
 }
  $(this).dequeue();
 })
}
})
 
 $('ul#'+idMenuAActiver+' li ul,ul#'+idMenuAActiver+' li div').not('ul#'+idMenuAActiver+' li div *').parent().mouseout(function(){
  $(this).stop(true,true);
  $(this).children().not('a,span').stop(true,true);
  if($(this).children().not('a,span').css('display') != 'none'){
  $(this).children().not('a,span').delay(delaiAffichage/2).queue(function(){
   $(this).parent().css('z-index','50');
   $(this).parent().find('>a').removeClass('actif');
   $(this).dequeue();
 })
  .fadeOut(vitesseTransitionMenu,function(){$(this).attr('style','display:none;visibility:visible;');$(this).clearQueue()});
 }
})
}


(function($) {

$.extend($.fn, {
 // http://docs.jquery.com/Plugins/Validation/validate
 validate: function( options ) {
 // if nothing is selected, return nothing;can't chain anyway
 if (!this.length) {
  options && options.debug && window.console && console.warn( "nothing selected, can't validate, returning nothing" );
  return;
}

 // check if a validator for this form was already created
 var validator = $.data(this[0], 'validator');
 if ( validator ) {
  return validator;
}
 
 validator = new $.validator( options, this[0] );
 $.data(this[0], 'validator', validator);
 
 if ( validator.settings.onsubmit ) {
 
  // allow suppresing validation by adding a cancel class to the submit button
  this.find("input, button").filter(".cancel").click(function() {
  validator.cancelSubmit = true;
 });
  
  // when a submitHandler is used, capture the submitting button
  if (validator.settings.submitHandler) {
  this.find("input, button").filter(":submit").click(function() {
   validator.submitButton = this;
 });
 }
 
  // validate the form on submit
  this.submit( function( event ) {
  if ( validator.settings.debug )
   // prevent form submit to be able to see console output
   event.preventDefault();
   
  function handle() {
   if ( validator.settings.submitHandler ) {
   if (validator.submitButton) {
 // insert a hidden input as a replacement for the missing submit button
 var hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);
  }
   validator.settings.submitHandler.call( validator, validator.currentForm );
   if (validator.submitButton) {
 // and clean up afterwards;thanks to no-block-scope, hidden can be referenced
 hidden.remove();
  }
   return false;
  }
   return true;
 }
   
  // prevent submit for invalid forms or custom submit handlers
  if ( validator.cancelSubmit ) {
   validator.cancelSubmit = false;
   return handle();
 }
  if ( validator.form() ) {
   if ( validator.pendingRequest ) {
   validator.formSubmitted = true;
   return false;
  }
   return handle();
 } else {
   validator.focusInvalid();
   return false;
 }
 });
}
 
 return validator;
},
 // http://docs.jquery.com/Plugins/Validation/valid
 valid: function() {
 if ( $(this[0]).is('form')) {
   return this.validate().form();
} else {
   var valid = true;
   var validator = $(this[0].form).validate();
   this.each(function() {
  valid &= validator.element(this);
  });
   return valid;
}
 },
 // attributes: space seperated list of attributes to retrieve and remove
 removeAttrs: function(attributes) {
 var result = {},
  $element = this;
 $.each(attributes.split(/\s/), function(index, value) {
  result[value] = $element.attr(value);
  $element.removeAttr(value);
});
 return result;
},
 // http://docs.jquery.com/Plugins/Validation/rules
 rules: function(command, argument) {
 var element = this[0];
 
 if (command) {
  var settings = $.data(element.form, 'validator').settings;
  var staticRules = settings.rules;
  var existingRules = $.validator.staticRules(element);
  switch(command) {
  case "add":
  $.extend(existingRules, $.validator.normalizeRule(argument));
  staticRules[element.name] = existingRules;
  if (argument.messages)
   settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
  break;
  case "remove":
  if (!argument) {
   delete staticRules[element.name];
   return existingRules;
 }
  var filtered = {};
  $.each(argument.split(/\s/), function(index, method) {
   filtered[method] = existingRules[method];
   delete existingRules[method];
 });
  return filtered;
 }
}
 
 var data = $.validator.normalizeRules(
 $.extend(
  {},
  $.validator.metadataRules(element),
  $.validator.classRules(element),
  $.validator.attributeRules(element),
  $.validator.staticRules(element)
 ), element);
 
 // make sure required is at front
 if (data.required) {
  var param = data.required;
  delete data.required;
  data = $.extend({required: param}, data);
}
 
 return data;
}
});

// Custom selectors
$.extend($.expr[":"], {
 // http://docs.jquery.com/Plugins/Validation/blank
 blank: function(a) {return !$.trim("" + a.value);},
 // http://docs.jquery.com/Plugins/Validation/filled
 filled: function(a) {return !!$.trim("" + a.value);},
 // http://docs.jquery.com/Plugins/Validation/unchecked
 unchecked: function(a) {return !a.checked;}
});

// constructor for validator
$.validator = function( options, form ) {
 this.settings = $.extend( true, {}, $.validator.defaults, options );
 this.currentForm = form;
 this.init();
};

$.validator.format = function(source, params) {
 if ( arguments.length == 1 ) 
 return function() {
  var args = $.makeArray(arguments);
  args.unshift(source);
  return $.validator.format.apply( this, args );
};
 if ( arguments.length > 2 && params.constructor != Array ) {
 params = $.makeArray(arguments).slice(1);
}
 if ( params.constructor != Array ) {
 params = [ params ];
}
 $.each(params, function(i, n) {
 source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n);
});
 return source;
};

$.extend($.validator, {
 
 defaults: {
 messages: {},
 groups: {},
 rules: {},
 errorClass: "error",
 validClass: "valid",
 errorElement: "label",
 focusInvalid: true,
 errorContainer: $( [] ),
 errorLabelContainer: $( [] ),
 onsubmit: true,
 ignore: [],
 ignoreTitle: false,
 onfocusin: function(element) {
  this.lastActive = element;
  
  // hide error label and remove error class on focus if enabled
  if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
  this.settings.unhighlight && this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
  this.errorsFor(element).hide();
 }
},
 onfocusout: function(element) {
  if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
  this.element(element);
 }
},
 onkeyup: function(element) {
  if ( element.name in this.submitted || element == this.lastElement ) {
  this.element(element);
 }
},
 onclick: function(element) {
  // click on selects, radiobuttons and checkboxes
  if ( element.name in this.submitted )
  this.element(element);
  // or option elements, check parent select in that case
  else if (element.parentNode.name in this.submitted)
  this.element(element.parentNode);
},
 highlight: function( element, errorClass, validClass ) {
  $(element).addClass(errorClass).removeClass(validClass);
},
 unhighlight: function( element, errorClass, validClass ) {
  $(element).removeClass(errorClass).addClass(validClass);
}
},

 // http://docs.jquery.com/Plugins/Validation/Validator/setDefaults
 setDefaults: function(settings) {
 $.extend( $.validator.defaults, settings );
},

 messages: {
 required: "This field is required.",
 remote: "Please fix this field.",
 email: "Please enter a valid email address.",
 url: "Please enter a valid URL.",
 date: "Please enter a valid date.",
 dateISO: "Please enter a valid date (ISO).",
 number: "Please enter a valid number.",
 digits: "Please enter only digits.",
 creditcard: "Please enter a valid credit card number.",
 equalTo: "Please enter the same value again.",
 accept: "Please enter a value with a valid extension.",
 maxlength: $.validator.format("Please enter no more than {0} characters."),
 minlength: $.validator.format("Please enter at least {0} characters."),
 rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
 range: $.validator.format("Please enter a value between {0} and {1}."),
 max: $.validator.format("Please enter a value less than or equal to {0}."),
 min: $.validator.format("Please enter a value greater than or equal to {0}.")
},
 
 autoCreateRanges: false,
 
 prototype: {
 
 init: function() {
  this.labelContainer = $(this.settings.errorLabelContainer);
  this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
  this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer );
  this.submitted = {};
  this.valueCache = {};
  this.pendingRequest = 0;
  this.pending = {};
  this.invalid = {};
  this.reset();
  
  var groups = (this.groups = {});
  $.each(this.settings.groups, function(key, value) {
  $.each(value.split(/\s/), function(index, name) {
   groups[name] = key;
 });
 });
  var rules = this.settings.rules;
  $.each(rules, function(key, value) {
  rules[key] = $.validator.normalizeRule(value);
 });
  
  function delegate(event) {
  var validator = $.data(this[0].form, "validator"),
   eventType = "on" + event.type.replace(/^validate/, "");
  validator.settings[eventType] && validator.settings[eventType].call(validator, this[0] );
 }
  $(this.currentForm)
  .validateDelegate(":text, :password, :file, select, textarea", "focusin focusout keyup", delegate)
  .validateDelegate(":radio, :checkbox, select, option", "click", delegate);

  if (this.settings.invalidHandler)
  $(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
},

 // http://docs.jquery.com/Plugins/Validation/Validator/form
 form: function() {
  this.checkForm();
  $.extend(this.submitted, this.errorMap);
  this.invalid = $.extend({}, this.errorMap);
  if (!this.valid())
  $(this.currentForm).triggerHandler("invalid-form", [this]);
  this.showErrors();
  return this.valid();
},
 
 checkForm: function() {
  this.prepareForm();
  for ( var i = 0, elements = (this.currentElements = this.elements());elements[i];i++ ) {
  this.check( elements[i] );
 }
  return this.valid();
},
 
 // http://docs.jquery.com/Plugins/Validation/Validator/element
 element: function( element ) {
  element = this.clean( element );
  this.lastElement = element;
  this.prepareElement( element );
  this.currentElements = $(element);
  var result = this.check( element );
  if ( result ) {
  delete this.invalid[element.name];
 } else {
  this.invalid[element.name] = true;
 }
  if ( !this.numberOfInvalids() ) {
  // Hide error containers on last error
  this.toHide = this.toHide.add( this.containers );
 }
  this.showErrors();
  return result;
},

 // http://docs.jquery.com/Plugins/Validation/Validator/showErrors
 showErrors: function(errors) {
  if(errors) {
  // add items to error list and map
  $.extend( this.errorMap, errors );
  this.errorList = [];
  for ( var name in errors ) {
   this.errorList.push({
   message: errors[name],
   element: this.findByName(name)[0]
  });
 }
  // remove items from success list
  this.successList = $.grep( this.successList, function(element) {
   return !(element.name in errors);
 });
 }
  this.settings.showErrors
  ? this.settings.showErrors.call( this, this.errorMap, this.errorList )
  : this.defaultShowErrors();
},
 
 // http://docs.jquery.com/Plugins/Validation/Validator/resetForm
 resetForm: function() {
  if ( $.fn.resetForm )
  $( this.currentForm ).resetForm();
  this.submitted = {};
  this.prepareForm();
  this.hideErrors();
  this.elements().removeClass( this.settings.errorClass );
},
 
 numberOfInvalids: function() {
  return this.objectLength(this.invalid);
},
 
 objectLength: function( obj ) {
  var count = 0;
  for ( var i in obj )
  count++;
  return count;
},
 
 hideErrors: function() {
  this.addWrapper( this.toHide ).hide();
},
 
 valid: function() {
  return this.size() == 0;
},
 
 size: function() {
  return this.errorList.length;
},
 
 focusInvalid: function() {
  if( this.settings.focusInvalid ) {
  try {
   $(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])
   .filter(":visible")
   .focus()
   // manually trigger focusin event;without it, focusin handler isn't called, findLastActive won't have anything to find
   .trigger("focusin");
 } catch(e) {
   // ignore IE throwing errors when focusing hidden elements
 }
 }
},
 
 findLastActive: function() {
  var lastActive = this.lastActive;
  return lastActive && $.grep(this.errorList, function(n) {
  return n.element.name == lastActive.name;
 }).length == 1 && lastActive;
},
 
 elements: function() {
  var validator = this,
  rulesCache = {};
  
  // select all valid inputs inside the form (no submit or reset buttons)
  // workaround $Query([]).add until http://dev.jquery.com/ticket/2114 is solved
  return $([]).add(this.currentForm.elements)
  .filter(":input")
  .not(":submit, :reset, :image, [disabled]")
  .not( this.settings.ignore )
  .filter(function() {
  !this.name && validator.settings.debug && window.console && console.error( "%o has no name assigned", this);
  
  // select only the first element for each name, and only those with rules specified
  if ( this.name in rulesCache || !validator.objectLength($(this).rules()) )
   return false;
  
  rulesCache[this.name] = true;
  return true;
 });
},
 
 clean: function( selector ) {
  return $( selector )[0];
},
 
 errors: function() {
  return $( this.settings.errorElement + "." + this.settings.errorClass, this.errorContext );
},
 
 reset: function() {
  this.successList = [];
  this.errorList = [];
  this.errorMap = {};
  this.toShow = $([]);
  this.toHide = $([]);
  this.currentElements = $([]);
},
 
 prepareForm: function() {
  this.reset();
  this.toHide = this.errors().add( this.containers );
},
 
 prepareElement: function( element ) {
  this.reset();
  this.toHide = this.errorsFor(element);
},
 
 check: function( element ) {
  element = this.clean( element );
  
  // if radio/checkbox, validate first element in group instead
  if (this.checkable(element)) {
  element = this.findByName( element.name )[0];
 }
  
  var rules = $(element).rules();
  var dependencyMismatch = false;
  for( method in rules ) {
  var rule = {method: method, parameters: rules[method]};
  try {
   var result = $.validator.methods[method].call( this, element.value.replace(/\r/g, ""), element, rule.parameters );
   
   // if a method indicates that the field is optional and therefore valid,
   // don't mark it as valid when there are no other rules
   if ( result == "dependency-mismatch" ) {
   dependencyMismatch = true;
   continue;
  }
   dependencyMismatch = false;
   
   if ( result == "pending" ) {
   this.toHide = this.toHide.not( this.errorsFor(element) );
   return;
  }
   
   if( !result ) {
   this.formatAndAdd( element, rule );
   return false;
  }
 } catch(e) {
   this.settings.debug && window.console && console.log("exception occured when checking element " + element.id
 + ", check the '" + rule.method + "' method", e);
   throw e;
 }
 }
  if (dependencyMismatch)
  return;
  if ( this.objectLength(rules) )
  this.successList.push(element);
  return true;
},
 
 // return the custom message for the given element and validation method
 // specified in the element's "messages" metadata
 customMetaMessage: function(element, method) {
  if (!$.metadata)
  return;
  
  var meta = this.settings.meta
  ? $(element).metadata()[this.settings.meta]
  : $(element).metadata();
  
  return meta && meta.messages && meta.messages[method];
},
 
 // return the custom message for the given element name and validation method
 customMessage: function( name, method ) {
  var m = this.settings.messages[name];
  return m && (m.constructor == String
  ? m
  : m[method]);
},
 
 // return the first defined argument, allowing empty strings
 findDefined: function() {
  for(var i = 0;i < arguments.length;i++) {
  if (arguments[i] !== undefined)
   return arguments[i];
 }
  return undefined;
},
 
 defaultMessage: function( element, method) {
  return this.findDefined(
  this.customMessage( element.name, method ),
  this.customMetaMessage( element, method ),
  // title is never undefined, so handle empty string as undefined
  !this.settings.ignoreTitle && element.title || undefined,
  $.validator.messages[method],
  "<strong>Warning: No message defined for " + element.name + "</strong>"
  );
},
 
 formatAndAdd: function( element, rule ) {
  var message = this.defaultMessage( element, rule.method ),
  theregex = /\$?\{(\d+)\}/g;
  if ( typeof message == "function" ) {
  message = message.call(this, rule.parameters, element);
 } else if (theregex.test(message)) {
  message = jQuery.format(message.replace(theregex, '{$1}'), rule.parameters);
 }  
  this.errorList.push({
  message: message,
  element: element
 });
  
  this.errorMap[element.name] = message;
  this.submitted[element.name] = message;
},
 
 addWrapper: function(toToggle) {
  if ( this.settings.wrapper )
  toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) );
  return toToggle;
},
 
 defaultShowErrors: function() {
  for ( var i = 0;this.errorList[i];i++ ) {
  var error = this.errorList[i];
  this.settings.highlight && this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass );
  this.showLabel( error.element, error.message );
 }
  if( this.errorList.length ) {
  this.toShow = this.toShow.add( this.containers );
 }
  if (this.settings.success) {
  for ( var i = 0;this.successList[i];i++ ) {
   this.showLabel( this.successList[i] );
 }
 }
  if (this.settings.unhighlight) {
  for ( var i = 0, elements = this.validElements();elements[i];i++ ) {
   this.settings.unhighlight.call( this, elements[i], this.settings.errorClass, this.settings.validClass );
 }
 }
  this.toHide = this.toHide.not( this.toShow );
  this.hideErrors();
  this.addWrapper( this.toShow ).show();
},
 
 validElements: function() {
  return this.currentElements.not(this.invalidElements());
},
 
 invalidElements: function() {
  return $(this.errorList).map(function() {
  return this.element;
 });
},
 
 showLabel: function(element, message) {
  var label = this.errorsFor( element );
  if ( label.length ) {
  // refresh error/success class
  label.removeClass().addClass( this.settings.errorClass );
  
  // check if we have a generated label, replace the message then
  label.attr("generated") && label.html(message);
 } else {
  // create label
  label = $("<" + this.settings.errorElement + "/>")
   .attr({"for": this.idOrName(element), generated: true})
   .addClass(this.settings.errorClass)
   .html(message || "");
  if ( this.settings.wrapper ) {
   // make sure the element is visible, even in IE
   // actually showing the wrapped element is handled elsewhere
   label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
 }
  if ( !this.labelContainer.append(label).length )
   this.settings.errorPlacement
   ? this.settings.errorPlacement(label, $(element) )
   : label.insertAfter(element);
 }
  if ( !message && this.settings.success ) {
  label.text("");
  typeof this.settings.success == "string"
   ? label.addClass( this.settings.success )
   : this.settings.success( label );
 }
  this.toShow = this.toShow.add(label);
},
 
 errorsFor: function(element) {
  var name = this.idOrName(element);
   return this.errors().filter(function() {
  return $(this).attr('for') == name;
 });
},
 
 idOrName: function(element) {
  return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);
},

 checkable: function( element ) {
  return /radio|checkbox/i.test(element.type);
},
 
 findByName: function( name ) {
  // select by name and filter by form for performance over form.find("[name=...]")
  var form = this.currentForm;
  return $(document.getElementsByName(name)).map(function(index, element) {
  return element.form == form && element.name == name && element || null;
 });
},
 
 getLength: function(value, element) {
  switch( element.nodeName.toLowerCase() ) {
  case 'select':
  return $("option:selected", element).length;
  case 'input':
  if( this.checkable( element) )
   return this.findByName(element.name).filter(':checked').length;
 }
  return value.length;
},
 
 depend: function(param, element) {
  return this.dependTypes[typeof param]
  ? this.dependTypes[typeof param](param, element)
  : true;
},
 
 dependTypes: {
  "boolean": function(param, element) {
  return param;
 },
  "string": function(param, element) {
  return !!$(param, element.form).length;
 },
  "function": function(param, element) {
  return param(element);
 }
},
 
 optional: function(element) {
  return !$.validator.methods.required.call(this, $.trim(element.value), element) && "dependency-mismatch";
},
 
 startRequest: function(element) {
  if (!this.pending[element.name]) {
  this.pendingRequest++;
  this.pending[element.name] = true;
 }
},
 
 stopRequest: function(element, valid) {
  this.pendingRequest--;
  // sometimes synchronization fails, make sure pendingRequest is never < 0
  if (this.pendingRequest < 0)
  this.pendingRequest = 0;
  delete this.pending[element.name];
  if ( valid && this.pendingRequest == 0 && this.formSubmitted && this.form() ) {
  $(this.currentForm).submit();
  this.formSubmitted = false;
 } else if (!valid && this.pendingRequest == 0 && this.formSubmitted) {
  $(this.currentForm).triggerHandler("invalid-form", [this]);
  this.formSubmitted = false;
 }
},
 
 previousValue: function(element) {
  return $.data(element, "previousValue") || $.data(element, "previousValue", {
  old: null,
  valid: true,
  message: this.defaultMessage( element, "remote" )
 });
}
 
},
 
 classRuleSettings: {
 required: {required: true},
 email: {email: true},
 url: {url: true},
 date: {date: true},
 dateISO: {dateISO: true},
 dateDE: {dateDE: true},
 number: {number: true},
 numberDE: {numberDE: true},
 digits: {digits: true},
 creditcard: {creditcard: true}
},
 
 addClassRules: function(className, rules) {
 className.constructor == String ?
  this.classRuleSettings[className] = rules :
  $.extend(this.classRuleSettings, className);
},
 
 classRules: function(element) {
 var rules = {};
 var classes = $(element).attr('class');
 classes && $.each(classes.split(' '), function() {
  if (this in $.validator.classRuleSettings) {
  $.extend(rules, $.validator.classRuleSettings[this]);
 }
});
 return rules;
},
 
 attributeRules: function(element) {
 var rules = {};
 var $element = $(element);
 
 for (method in $.validator.methods) {
  var value = $element.attr(method);
  if (value) {
  rules[method] = value;
 }
}
 
 // maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs
 if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) {
  delete rules.maxlength;
}
 
 return rules;
},
 
 metadataRules: function(element) {
 if (!$.metadata) return {};
 
 var meta = $.data(element.form, 'validator').settings.meta;
 return meta ?
  $(element).metadata()[meta] :
  $(element).metadata();
},
 
 staticRules: function(element) {
 var rules = {};
 var validator = $.data(element.form, 'validator');
 if (validator.settings.rules) {
  rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {};
}
 return rules;
},
 
 normalizeRules: function(rules, element) {
 // handle dependency check
 $.each(rules, function(prop, val) {
  // ignore rule when param is explicitly false, eg. required:false
  if (val === false) {
  delete rules[prop];
  return;
 }
  if (val.param || val.depends) {
  var keepRule = true;
  switch (typeof val.depends) {
   case "string":
   keepRule = !!$(val.depends, element.form).length;
   break;
   case "function":
   keepRule = val.depends.call(element, element);
   break;
 }
  if (keepRule) {
   rules[prop] = val.param !== undefined ? val.param : true;
 } else {
   delete rules[prop];
 }
 }
});
 
 // evaluate parameters
 $.each(rules, function(rule, parameter) {
  rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
});
 
 // clean number parameters
 $.each(['minlength', 'maxlength', 'min', 'max'], function() {
  if (rules[this]) {
  rules[this] = Number(rules[this]);
 }
});
 $.each(['rangelength', 'range'], function() {
  if (rules[this]) {
  rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
 }
});
 
 if ($.validator.autoCreateRanges) {
  // auto-create ranges
  if (rules.min && rules.max) {
  rules.range = [rules.min, rules.max];
  delete rules.min;
  delete rules.max;
 }
  if (rules.minlength && rules.maxlength) {
  rules.rangelength = [rules.minlength, rules.maxlength];
  delete rules.minlength;
  delete rules.maxlength;
 }
}
 
 // To support custom messages in metadata ignore rule methods titled "messages"
 if (rules.messages) {
  delete rules.messages;
}
 
 return rules;
},
 
 // Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
 normalizeRule: function(data) {
 if( typeof data == "string" ) {
  var transformed = {};
  $.each(data.split(/\s/), function() {
  transformed[this] = true;
 });
  data = transformed;
}
 return data;
},
 
 // http://docs.jquery.com/Plugins/Validation/Validator/addMethod
 addMethod: function(name, method, message) {
 $.validator.methods[name] = method;
 $.validator.messages[name] = message != undefined ? message : $.validator.messages[name];
 if (method.length < 3) {
  $.validator.addClassRules(name, $.validator.normalizeRule(name));
}
},

 methods: {

 // http://docs.jquery.com/Plugins/Validation/Methods/required
 required: function(value, element, param) {
  // check if dependency is met
  if ( !this.depend(param, element) )
  return "dependency-mismatch";
  switch( element.nodeName.toLowerCase() ) {
  case 'select':
  // could be an array for select-multiple or a string, both are fine this way
  var val = $(element).val();
  return val && val.length > 0;
  case 'input':
  if ( this.checkable(element) )
   return this.getLength(value, element) > 0;
  default:
  return $.trim(value).length > 0;
 }
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/remote
 remote: function(value, element, param) {
  if ( this.optional(element) )
  return "dependency-mismatch";
  
  var previous = this.previousValue(element);
  if (!this.settings.messages[element.name] )
  this.settings.messages[element.name] = {};
  previous.originalMessage = this.settings.messages[element.name].remote;
  this.settings.messages[element.name].remote = previous.message;
  
  param = typeof param == "string" && {url:param} || param;
  
  if ( previous.old !== value ) {
  previous.old = value;
  var validator = this;
  this.startRequest(element);
  var data = {};
  data[element.name] = value;
  $.ajax($.extend(true, {
   url: param,
   mode: "abort",
   port: "validate" + element.name,
   dataType: "json",
   data: data,
   success: function(response) {
   validator.settings.messages[element.name].remote = previous.originalMessage;
   var valid = response === true;
   if ( valid ) {
 var submitted = validator.formSubmitted;
 validator.prepareElement(element);
 validator.formSubmitted = submitted;
 validator.successList.push(element);
 validator.showErrors();
  } else {
 var errors = {};
 var message = (previous.message = response || validator.defaultMessage( element, "remote" ));
 errors[element.name] = $.isFunction(message) ? message(value) : message;
 validator.showErrors(errors);
  }
   previous.valid = valid;
   validator.stopRequest(element, valid);
  }
 }, param));
  return "pending";
 } else if( this.pending[element.name] ) {
  return "pending";
 }
  return previous.valid;
},

 // http://docs.jquery.com/Plugins/Validation/Methods/minlength
 minlength: function(value, element, param) {
  return this.optional(element) || this.getLength($.trim(value), element) >= param;
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/maxlength
 maxlength: function(value, element, param) {
  return this.optional(element) || this.getLength($.trim(value), element) <= param;
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/rangelength
 rangelength: function(value, element, param) {
  var length = this.getLength($.trim(value), element);
  return this.optional(element) || ( length >= param[0] && length <= param[1] );
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/min
 min: function( value, element, param ) {
  return this.optional(element) || value >= param;
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/max
 max: function( value, element, param ) {
  return this.optional(element) || value <= param;
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/range
 range: function( value, element, param ) {
  return this.optional(element) || ( value >= param[0] && value <= param[1] );
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/email
 email: function(value, element) {
  // contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
  return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/url
 url: function(value, element) {
  // contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
  return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/date
 date: function(value, element) {
  return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/dateISO
 dateISO: function(value, element) {
  return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/number
 number: function(value, element) {
  return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/digits
 digits: function(value, element) {
  return this.optional(element) || /^\d+$/.test(value);
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/creditcard
 // based on http://en.wikipedia.org/wiki/Luhn
 creditcard: function(value, element) {
  if ( this.optional(element) )
  return "dependency-mismatch";
  // accept only digits and dashes
  if (/[^0-9-]+/.test(value))
  return false;
  var nCheck = 0,
  nDigit = 0,
  bEven = false;

  value = value.replace(/\D/g, "");

  for (var n = value.length - 1;n >= 0;n--) {
  var cDigit = value.charAt(n);
  var nDigit = parseInt(cDigit, 10);
  if (bEven) {
   if ((nDigit *= 2) > 9)
   nDigit -= 9;
 }
  nCheck += nDigit;
  bEven = !bEven;
 }

  return (nCheck % 10) == 0;
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/accept
 accept: function(value, element, param) {
  param = typeof param == "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
  return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
},
 
 // http://docs.jquery.com/Plugins/Validation/Methods/equalTo
 equalTo: function(value, element, param) {
  // bind to the blur event of the target in order to revalidate whenever the target field is updated
  // TODO find a way to bind the event just once, avoiding the unbind-rebind overhead
  var target = $(param).unbind(".validate-equalTo").bind("blur.validate-equalTo", function() {
  $(element).valid();
 });
  return value == target.val();
}
 
}
 
});

// deprecated, use $.validator.format instead
$.format = $.validator.format;

})(jQuery);

// ajax mode: abort
// usage: $.ajax({mode: "abort"[, port: "uniqueport"]});
// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort() 
;(function($) {
 var ajax = $.ajax;
 var pendingRequests = {};
 $.ajax = function(settings) {
 // create settings for compatibility with ajaxSetup
 settings = $.extend(settings, $.extend({}, $.ajaxSettings, settings));
 var port = settings.port;
 if (settings.mode == "abort") {
  if ( pendingRequests[port] ) {
  pendingRequests[port].abort();
 }
  return (pendingRequests[port] = ajax.apply(this, arguments));
}
 return ajax.apply(this, arguments);
};
})(jQuery);

// provides cross-browser focusin and focusout events
// IE has native support, in other browsers, use event caputuring (neither bubbles)

// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target 
;(function($) {
 // only implement if not provided by jQuery core (since 1.4)
 // TODO verify if jQuery 1.4's implementation is compatible with older jQuery special-event APIs
 if (!jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener) {
 $.each({
  focus: 'focusin',
  blur: 'focusout' 
}, function( original, fix ){
  $.event.special[fix] = {
  setup:function() {
   this.addEventListener( original, handler, true );
 },
  teardown:function() {
   this.removeEventListener( original, handler, true );
 },
  handler: function(e) {
   arguments[0] = $.event.fix(e);
   arguments[0].type = fix;
   return $.event.handle.apply(this, arguments);
 }
 };
  function handler(e) {
  e = $.event.fix(e);
  e.type = fix;
  return $.event.handle.call(this, e);
 }
});
};
 $.extend($.fn, {
 validateDelegate: function(delegate, type, handler) {
  return this.bind(type, function(event) {
  var target = $(event.target);
  if (target.is(delegate)) {
   return handler.apply(target, arguments);
 }
 });
}
});
})(jQuery);


 switch (cfg["langueAbr"])
 {
 case 'fr':
 jQuery.extend(jQuery.validator.messages, {
   required: "Ce champ est obligatoire.",
   remote: "Corrigez ce champ.",
   email: "Courriel invalide",
   url: "Lien invalide.",
  complete_url: "Lien invalide.",
   date: "Date invalide.",
   dateISO: "Date invalide.",
   number: "Chiffre invalide.",
   digits: "Nombre seulement.",
   creditcard: "Numéro de carte de crédit invalide",
   equalTo: "Entrez la même valeur.",
   accept: "Extension invalide.",
   maxlength: $.validator.format("Entrez une valeur avec {0} caractère(s) maximum."),
   minlength: $.validator.format("Entrez une valeur avec {0} caractère(s) minimum."),
   rangelength: $.validator.format("Entrez une valeur entre{0} et {1} caractère(s) de long."),
   range: $.validator.format("Entrez une valeur entre {0} et {1}."),
   max: $.validator.format("Entrez une valeur plus petite ou égale à {0}."),
   min: $.validator.format("Entrez une valeur plus grande ou égale à {0}."),
  telephone : "Téléphone invalide"
});
  break;
 case 'en':
 jQuery.extend(jQuery.validator.messages, {
  complete_url: "Please enter a valid URL,"  
});
 break; 
 case 'es':
 jQuery.extend(jQuery.validator.messages, {
   required: "ESCe champ est obligatoire.",
   remote: "ESCorrigez ce champ.",
   email: "ESCourriel invalide",
   url: "ESLien invalide.",
  complete_url: "ESLien invalide.",  
   date: "ESDate invalide.",
   dateISO: "ESDate invalide.",
   number: "ESChiffre invalide.",
   digits: "ESNombre seulement.",
   creditcard: "ESNuméro de carte de crédit invalide",
   equalTo: "ESEntrez la même valeur.",
   accept: "ESExtension invalide.",
   maxlength: $.validator.format("ESEntrez une valeur avec {0} caractère(s) maximum."),
   minlength: $.validator.format("ESEntrez une valeur avec {0} caractère(s) minimum."),
   rangelength: $.validator.format("ESEntrez une valeur entre{0} et {1} caractère(s) de long."),
   range: $.validator.format("ESEntrez une valeur entre {0} et {1}."),
   max: $.validator.format("ESEntrez une valeur plus petite ou égale à {0}."),
   min: $.validator.format("ESEntrez une valeur plus grande ou égale à {0}."),
  telephone : "ENTéléphone invalide"
});
  break;
} 


(function($){$.fn.bxSlider=function(options){var defaults={mode:'horizontal',infiniteLoop:true,hideControlOnEnd:false,controls:true,speed:500,easing:'swing',pager:false,pagerSelector:null,pagerType:'full',pagerLocation:'bottom',pagerShortSeparator:'/',pagerActiveClass:'pager-active',nextText:'next',nextImage:'',nextSelector:null,prevText:'prev',prevImage:'',prevSelector:null,captions:false,captionsSelector:null,auto:false,autoDirection:'next',autoControls:false,autoControlsSelector:null,autoStart:true,autoHover:false,autoDelay:0,pause:3000,startText:'start',startImage:'',stopText:'stop',stopImage:'',ticker:false,tickerSpeed:5000,tickerDirection:'next',tickerHover:false,wrapperClass:'bx-wrapper',startingSlide:0,displaySlideQty:1,moveSlideQty:1,randomStart:false,onBeforeSlide:function(){},onAfterSlide:function(){},onLastSlide:function(){},onFirstSlide:function(){},onNextSlide:function(){},onPrevSlide:function(){},buildPager:null}
var options=$.extend(defaults,options);var base=this;var $parent='';var $origElement='';var $children='';var $outerWrapper='';var $firstChild='';var childrenWidth='';var childrenOuterWidth='';var wrapperWidth='';var wrapperHeight='';var $pager='';var interval='';var $autoControls='';var $stopHtml='';var $startContent='';var $stopContent='';var autoPlaying=true;var loaded=false;var childrenMaxWidth=0;var childrenMaxHeight=0;var currentSlide=0;var origLeft=0;var origTop=0;var origShowWidth=0;var origShowHeight=0;var tickerLeft=0;var tickerTop=0;var isWorking=false;var firstSlide=0;var lastSlide=$children.length-1;this.goToSlide=function(number,stopAuto){if(!isWorking){isWorking=true;currentSlide=number;options.onBeforeSlide(currentSlide,$children.length,$children.eq(currentSlide));if(typeof(stopAuto)=='undefined'){var stopAuto=true;}
if(stopAuto){if(options.auto){base.stopShow(true);}}
slide=number;if(slide==firstSlide){options.onFirstSlide(currentSlide,$children.length,$children.eq(currentSlide));}
if(slide==lastSlide){options.onLastSlide(currentSlide,$children.length,$children.eq(currentSlide));}
if(options.mode=='horizontal'){$parent.animate({'left':'-'+getSlidePosition(slide,'left')+'px'},options.speed,options.easing,function(){isWorking=false;options.onAfterSlide(currentSlide,$children.length,$children.eq(currentSlide));});}else if(options.mode=='vertical'){$parent.animate({'top':'-'+getSlidePosition(slide,'top')+'px'},options.speed,options.easing,function(){isWorking=false;options.onAfterSlide(currentSlide,$children.length,$children.eq(currentSlide));});}else if(options.mode=='fade'){setChildrenFade();}
checkEndControls();if(options.moveSlideQty>1){number=Math.floor(number/options.moveSlideQty);}
makeSlideActive(number);showCaptions();}}
this.goToNextSlide=function(stopAuto){if(typeof(stopAuto)=='undefined'){var stopAuto=true;}
if(stopAuto){if(options.auto){base.stopShow(true);}}
if(!options.infiniteLoop){if(!isWorking){var slideLoop=false;currentSlide=(currentSlide+(options.moveSlideQty));if(currentSlide<=lastSlide){checkEndControls();options.onNextSlide(currentSlide,$children.length,$children.eq(currentSlide));base.goToSlide(currentSlide);}else{currentSlide-=options.moveSlideQty;}}}else{if(!isWorking){isWorking=true;var slideLoop=false;currentSlide=(currentSlide+options.moveSlideQty);if(currentSlide>lastSlide){currentSlide=currentSlide%$children.length;slideLoop=true;}
options.onNextSlide(currentSlide,$children.length,$children.eq(currentSlide));options.onBeforeSlide(currentSlide,$children.length,$children.eq(currentSlide));if(options.mode=='horizontal'){var parentLeft=(options.moveSlideQty*childrenOuterWidth);$parent.animate({'left':'-='+parentLeft+'px'},options.speed,options.easing,function(){isWorking=false;if(slideLoop){$parent.css('left','-'+getSlidePosition(currentSlide,'left')+'px');}
options.onAfterSlide(currentSlide,$children.length,$children.eq(currentSlide));});}else if(options.mode=='vertical'){var parentTop=(options.moveSlideQty*childrenMaxHeight);$parent.animate({'top':'-='+parentTop+'px'},options.speed,options.easing,function(){isWorking=false;if(slideLoop){$parent.css('top','-'+getSlidePosition(currentSlide,'top')+'px');}
options.onAfterSlide(currentSlide,$children.length,$children.eq(currentSlide));});}else if(options.mode=='fade'){setChildrenFade();}
if(options.moveSlideQty>1){makeSlideActive(Math.ceil(currentSlide/options.moveSlideQty));}else{makeSlideActive(currentSlide);}
showCaptions();}}}
this.goToPreviousSlide=function(stopAuto){if(typeof(stopAuto)=='undefined'){var stopAuto=true;}
if(stopAuto){if(options.auto){base.stopShow(true);}}
if(!options.infiniteLoop){if(!isWorking){var slideLoop=false;currentSlide=currentSlide-options.moveSlideQty;if(currentSlide<0){currentSlide=0;if(options.hideControlOnEnd){$('.bx-prev',$outerWrapper).hide();}}
checkEndControls();options.onPrevSlide(currentSlide,$children.length,$children.eq(currentSlide));base.goToSlide(currentSlide);}}else{if(!isWorking){isWorking=true;var slideLoop=false;currentSlide=(currentSlide-(options.moveSlideQty));if(currentSlide<0){negativeOffset=(currentSlide%$children.length);if(negativeOffset==0){currentSlide=0;}else{currentSlide=($children.length)+negativeOffset;}
slideLoop=true;}
options.onPrevSlide(currentSlide,$children.length,$children.eq(currentSlide));options.onBeforeSlide(currentSlide,$children.length,$children.eq(currentSlide));if(options.mode=='horizontal'){var parentLeft=(options.moveSlideQty*childrenOuterWidth);$parent.animate({'left':'+='+parentLeft+'px'},options.speed,options.easing,function(){isWorking=false;if(slideLoop){$parent.css('left','-'+getSlidePosition(currentSlide,'left')+'px');}
options.onAfterSlide(currentSlide,$children.length,$children.eq(currentSlide));});}else if(options.mode=='vertical'){var parentTop=(options.moveSlideQty*childrenMaxHeight);$parent.animate({'top':'+='+parentTop+'px'},options.speed,options.easing,function(){isWorking=false;if(slideLoop){$parent.css('top','-'+getSlidePosition(currentSlide,'top')+'px');}
options.onAfterSlide(currentSlide,$children.length,$children.eq(currentSlide));});}else if(options.mode=='fade'){setChildrenFade();}
if(options.moveSlideQty>1){makeSlideActive(Math.ceil(currentSlide/options.moveSlideQty));}else{makeSlideActive(currentSlide);}
showCaptions();}}}
this.goToFirstSlide=function(stopAuto){if(typeof(stopAuto)=='undefined'){var stopAuto=true;}
base.goToSlide(firstSlide,stopAuto);}
this.goToLastSlide=function(){if(typeof(stopAuto)=='undefined'){var stopAuto=true;}
base.goToSlide(lastSlide,stopAuto);}
this.getCurrentSlide=function(){return currentSlide;}
this.getSlideCount=function(){return $children.length;}
this.stopShow=function(changeText){clearInterval(interval);if(typeof(changeText)=='undefined'){var changeText=true;}
if(changeText&&options.autoControls){$autoControls.html($startContent).removeClass('stop').addClass('start');autoPlaying=false;}}
this.startShow=function(changeText){if(typeof(changeText)=='undefined'){var changeText=true;}
setAutoInterval();if(changeText&&options.autoControls){$autoControls.html($stopContent).removeClass('start').addClass('stop');autoPlaying=true;}}
this.stopTicker=function(changeText){$parent.stop();if(typeof(changeText)=='undefined'){var changeText=true;}
if(changeText&&options.ticker){$autoControls.html($startContent).removeClass('stop').addClass('start');autoPlaying=false;}}
this.startTicker=function(changeText){if(options.mode=='horizontal'){if(options.tickerDirection=='next'){var stoppedLeft=parseInt($parent.css('left'));var remainingDistance=(origShowWidth+stoppedLeft)+$children.eq(0).width();}else if(options.tickerDirection=='prev'){var stoppedLeft=-parseInt($parent.css('left'));var remainingDistance=(stoppedLeft)-$children.eq(0).width();}
var finishingSpeed=(remainingDistance*options.tickerSpeed)/origShowWidth;moveTheShow(tickerLeft,remainingDistance,finishingSpeed);}else if(options.mode=='vertical'){if(options.tickerDirection=='next'){var stoppedTop=parseInt($parent.css('top'));var remainingDistance=(origShowHeight+stoppedTop)+$children.eq(0).height();}else if(options.tickerDirection=='prev'){var stoppedTop=-parseInt($parent.css('top'));var remainingDistance=(stoppedTop)-$children.eq(0).height();}
var finishingSpeed=(remainingDistance*options.tickerSpeed)/origShowHeight;moveTheShow(tickerTop,remainingDistance,finishingSpeed);if(typeof(changeText)=='undefined'){var changeText=true;}
if(changeText&&options.ticker){$autoControls.html($stopContent).removeClass('start').addClass('stop');autoPlaying=true;}}}
this.initShow=function(){$parent=$(this);$origElement=$parent.clone();$children=$parent.children();$outerWrapper='';$firstChild=$parent.children(':first');childrenWidth=$firstChild.width();childrenMaxWidth=0;childrenOuterWidth=$firstChild.outerWidth();childrenMaxHeight=0;wrapperWidth=getWrapperWidth();wrapperHeight=getWrapperHeight();isWorking=false;$pager='';currentSlide=0;origLeft=0;origTop=0;interval='';$autoControls='';$stopHtml='';$startContent='';$stopContent='';autoPlaying=true;loaded=false;origShowWidth=0;origShowHeight=0;tickerLeft=0;tickerTop=0;firstSlide=0;lastSlide=$children.length-1;$children.each(function(index){if($(this).outerHeight()>childrenMaxHeight){childrenMaxHeight=$(this).outerHeight();}
if($(this).outerWidth()>childrenMaxWidth){childrenMaxWidth=$(this).outerWidth();}});if(options.randomStart){var randomNumber=Math.floor(Math.random()*$children.length);currentSlide=randomNumber;origLeft=childrenOuterWidth*(options.moveSlideQty+randomNumber);origTop=childrenMaxHeight*(options.moveSlideQty+randomNumber);}else{currentSlide=options.startingSlide;origLeft=childrenOuterWidth*(options.moveSlideQty+options.startingSlide);origTop=childrenMaxHeight*(options.moveSlideQty+options.startingSlide);}
initCss();if(options.pager&&!options.ticker){if(options.pagerType=='full'){showPager('full');}else if(options.pagerType=='short'){showPager('short');}}
if(options.controls&&!options.ticker){setControlsVars();}
if(options.auto||options.ticker){if(options.autoControls){setAutoControlsVars();}
if(options.autoStart){setTimeout(function(){base.startShow(true);},options.autoDelay);}else{base.stopShow(true);}
if(options.autoHover&&!options.ticker){setAutoHover();}}
if(options.moveSlideQty>1){makeSlideActive(Math.ceil(currentSlide/options.moveSlideQty));}else{makeSlideActive(currentSlide);}
checkEndControls();if(options.captions){showCaptions();}
options.onAfterSlide(currentSlide,$children.length,$children.eq(currentSlide));}
this.destroyShow=function(){clearInterval(interval);$('.bx-next, .bx-prev, .bx-pager, .bx-auto',$outerWrapper).remove();$parent.unwrap().unwrap().removeAttr('style');$parent.children().removeAttr('style').not('.pager').remove();$children.removeClass('pager');}
this.reloadShow=function(){base.destroyShow();base.initShow();}
function initCss(){setChildrenLayout(options.startingSlide);if(options.mode=='horizontal'){$parent.wrap('<div class="'+options.wrapperClass+'" style="width:'+wrapperWidth+'px;position:relative;"></div>').wrap('<div class="bx-window" style="position:relative;overflow:hidden;width:'+wrapperWidth+'px;"></div>').css({width:'999999px',position:'relative',left:'-'+(origLeft)+'px'});$parent.children().css({width:childrenWidth,'float':'left',listStyle:'none'});$outerWrapper=$parent.parent().parent();$children.addClass('pager');}else if(options.mode=='vertical'){$parent.wrap('<div class="'+options.wrapperClass+'" style="width:'+childrenMaxWidth+'px;position:relative;"></div>').wrap('<div class="bx-window" style="width:'+childrenMaxWidth+'px;height:'+wrapperHeight+'px;position:relative;overflow:hidden;"></div>').css({height:'999999px',position:'relative',top:'-'+(origTop)+'px'});$parent.children().css({listStyle:'none',height:childrenMaxHeight});$outerWrapper=$parent.parent().parent();$children.addClass('pager');}else if(options.mode=='fade'){$parent.wrap('<div class="'+options.wrapperClass+'" style="width:'+childrenMaxWidth+'px;position:relative;"></div>').wrap('<div class="bx-window" style="height:'+childrenMaxHeight+'px;width:'+childrenMaxWidth+'px;position:relative;overflow:hidden;"></div>');$parent.children().css({listStyle:'none',position:'absolute',top:0,left:0,zIndex:98});$outerWrapper=$parent.parent().parent();$children.not(':eq('+currentSlide+')').fadeTo(0,0);$children.eq(currentSlide).css('zIndex',99);}
if(options.captions&&options.captionsSelector==null){$outerWrapper.append('<div class="bx-captions"></div>');}}
function setChildrenLayout(){if(options.mode=='horizontal'||options.mode=='vertical'){var $prependedChildren=getArraySample($children,0,options.moveSlideQty,'backward');$.each($prependedChildren,function(index){$parent.prepend($(this));});var totalNumberAfterWindow=($children.length+options.moveSlideQty)-1;var pagerExcess=$children.length-options.displaySlideQty;var numberToAppend=totalNumberAfterWindow-pagerExcess;var $appendedChildren=getArraySample($children,0,numberToAppend,'forward');if(options.infiniteLoop){$.each($appendedChildren,function(index){$parent.append($(this));});}}}
function setControlsVars(){if(options.nextImage!=''){nextContent=options.nextImage;nextType='image';}else{nextContent=options.nextText;nextType='text';}
if(options.prevImage!=''){prevContent=options.prevImage;prevType='image';}else{prevContent=options.prevText;prevType='text';}
showControls(nextType,nextContent,prevType,prevContent);}
function setAutoInterval(){if(options.auto){if(!options.infiniteLoop){if(options.autoDirection=='next'){interval=setInterval(function(){currentSlide+=options.moveSlideQty;if(currentSlide>lastSlide){currentSlide=currentSlide%$children.length;}
base.goToSlide(currentSlide,false);},options.pause);}else if(options.autoDirection=='prev'){interval=setInterval(function(){currentSlide-=options.moveSlideQty;if(currentSlide<0){negativeOffset=(currentSlide%$children.length);if(negativeOffset==0){currentSlide=0;}else{currentSlide=($children.length)+negativeOffset;}}
base.goToSlide(currentSlide,false);},options.pause);}}else{if(options.autoDirection=='next'){interval=setInterval(function(){base.goToNextSlide(false);},options.pause);}else if(options.autoDirection=='prev'){interval=setInterval(function(){base.goToPreviousSlide(false);},options.pause);}}}else if(options.ticker){options.tickerSpeed*=10;$('.pager',$outerWrapper).each(function(index){origShowWidth+=$(this).width();origShowHeight+=$(this).height();});if(options.tickerDirection=='prev'&&options.mode=='horizontal'){$parent.css('left','-'+(origShowWidth+origLeft)+'px');}else if(options.tickerDirection=='prev'&&options.mode=='vertical'){$parent.css('top','-'+(origShowHeight+origTop)+'px');}
if(options.mode=='horizontal'){tickerLeft=parseInt($parent.css('left'));moveTheShow(tickerLeft,origShowWidth,options.tickerSpeed);}else if(options.mode=='vertical'){tickerTop=parseInt($parent.css('top'));moveTheShow(tickerTop,origShowHeight,options.tickerSpeed);}
if(options.tickerHover){setTickerHover();}}}
function moveTheShow(leftCss,distance,speed){if(options.mode=='horizontal'){if(options.tickerDirection=='next'){$parent.animate({'left':'-='+distance+'px'},speed,'linear',function(){$parent.css('left',leftCss);moveTheShow(leftCss,origShowWidth,options.tickerSpeed);});}else if(options.tickerDirection=='prev'){$parent.animate({'left':'+='+distance+'px'},speed,'linear',function(){$parent.css('left',leftCss);moveTheShow(leftCss,origShowWidth,options.tickerSpeed);});}}else if(options.mode=='vertical'){if(options.tickerDirection=='next'){$parent.animate({'top':'-='+distance+'px'},speed,'linear',function(){$parent.css('top',leftCss);moveTheShow(leftCss,origShowHeight,options.tickerSpeed);});}else if(options.tickerDirection=='prev'){$parent.animate({'top':'+='+distance+'px'},speed,'linear',function(){$parent.css('top',leftCss);moveTheShow(leftCss,origShowHeight,options.tickerSpeed);});}}}
function setAutoControlsVars(){if(options.startImage!=''){startContent=options.startImage;startType='image';}else{startContent=options.startText;startType='text';}
if(options.stopImage!=''){stopContent=options.stopImage;stopType='image';}else{stopContent=options.stopText;stopType='text';}
showAutoControls(startType,startContent,stopType,stopContent);}
function setAutoHover(){$outerWrapper.find('.bx-window').hover(function(){if(autoPlaying){base.stopShow(false);}},function(){if(autoPlaying){base.startShow(false);}});}
function setTickerHover(){$parent.hover(function(){if(autoPlaying){base.stopTicker(false);}},function(){if(autoPlaying){base.startTicker(false);}});}
function setChildrenFade(){$children.not(':eq('+currentSlide+')').fadeTo(options.speed,0).css('zIndex',98);$children.eq(currentSlide).css('zIndex',99).fadeTo(options.speed,1,function(){isWorking=false;if(jQuery.browser.msie){$children.eq(currentSlide).get(0).style.removeAttribute('filter');}
options.onAfterSlide(currentSlide,$children.length,$children.eq(currentSlide));});};function makeSlideActive(number){if(options.pagerType=='full'&&options.pager){$('a',$pager).removeClass(options.pagerActiveClass);$('a',$pager).eq(number).addClass(options.pagerActiveClass);}else if(options.pagerType=='short'&&options.pager){$('.bx-pager-current',$pager).html(currentSlide+1);}}
function showControls(nextType,nextContent,prevType,prevContent){var $nextHtml=$('<a href="" class="bx-next"></a>');var $prevHtml=$('<a href="" class="bx-prev"></a>');if(nextType=='text'){$nextHtml.html(nextContent);}else{$nextHtml.html('<img src="'+nextContent+'" />');}
if(prevType=='text'){$prevHtml.html(prevContent);}else{$prevHtml.html('<img src="'+prevContent+'" />');}
if(options.prevSelector){$(options.prevSelector).append($prevHtml);}else{$outerWrapper.append($prevHtml);}
if(options.nextSelector){$(options.nextSelector).append($nextHtml);}else{$outerWrapper.append($nextHtml);}
$nextHtml.click(function(){base.goToNextSlide();return false;});$prevHtml.click(function(){base.goToPreviousSlide();return false;});}
function showPager(type){var pagerQty=$children.length;if(options.moveSlideQty>1){if($children.length%options.moveSlideQty!=0){pagerQty=Math.ceil($children.length/options.moveSlideQty);}else{pagerQty=$children.length/options.moveSlideQty;}}
var pagerString='';if(options.buildPager){for(var i=0;i<pagerQty;i++){pagerString+=options.buildPager(i,$children.eq(i*options.moveSlideQty));}}else if(type=='full'){for(var i=1;i<=pagerQty;i++){pagerString+='<a href="" class="pager-link pager-'+i+'">'+i+'</a>';}}else if(type=='short'){pagerString='<span class="bx-pager-current">'+(options.startingSlide+1)+'</span> '+options.pagerShortSeparator+' <span class="bx-pager-total">'+$children.length+'<span>';}
if(options.pagerSelector){$(options.pagerSelector).append(pagerString);$pager=$(options.pagerSelector);}else{var $pagerContainer=$('<div class="bx-pager"></div>');$pagerContainer.append(pagerString);if(options.pagerLocation=='top'){$outerWrapper.prepend($pagerContainer);}else if(options.pagerLocation=='bottom'){$outerWrapper.append($pagerContainer);}
$pager=$('.bx-pager',$outerWrapper);}
$pager.children().click(function(){if(options.pagerType=='full'){var slideIndex=$pager.children().index(this);if(options.moveSlideQty>1){slideIndex*=options.moveSlideQty;}
base.goToSlide(slideIndex);}
return false;});}
function showCaptions(){var caption=$('img',$children.eq(currentSlide)).attr('title');if(caption!=''){if(options.captionsSelector){$(options.captionsSelector).html(caption);}else{$('.bx-captions',$outerWrapper).html(caption);}}else{if(options.captionsSelector){$(options.captionsSelector).html(' ');}else{$('.bx-captions',$outerWrapper).html(' ');}}}
function showAutoControls(startType,startContent,stopType,stopContent){$autoControls=$('<a href="" class="bx-start"></a>');if(startType=='text'){$startContent=startContent;}else{$startContent='<img src="'+startContent+'" />';}
if(stopType=='text'){$stopContent=stopContent;}else{$stopContent='<img src="'+stopContent+'" />';}
if(options.autoControlsSelector){$(options.autoControlsSelector).append($autoControls);}else{$outerWrapper.append('<div class="bx-auto"></div>');$('.bx-auto',$outerWrapper).html($autoControls);}
$autoControls.click(function(){if(options.ticker){if($(this).hasClass('stop')){base.stopTicker();}else if($(this).hasClass('start')){base.startTicker();}}else{if($(this).hasClass('stop')){base.stopShow(true);}else if($(this).hasClass('start')){base.startShow(true);}}
return false;});}
function checkEndControls(){if(!options.infiniteLoop&&options.hideControlOnEnd){if(currentSlide==firstSlide){$('.bx-prev',$outerWrapper).hide();}else{$('.bx-prev',$outerWrapper).show();}
if(currentSlide==lastSlide){$('.bx-next',$outerWrapper).hide();}else{$('.bx-next',$outerWrapper).show();}}}
function getSlidePosition(number,side){if(side=='left'){var position=$('.pager',$outerWrapper).eq(number).position().left;}else if(side=='top'){var position=$('.pager',$outerWrapper).eq(number).position().top;}
return position;}
function getWrapperWidth(){var wrapperWidth=$firstChild.outerWidth()*options.displaySlideQty;return wrapperWidth;}
function getWrapperHeight(){var wrapperHeight=$firstChild.outerHeight()*options.displaySlideQty;return wrapperHeight;}
function getArraySample(array,start,length,direction){var sample=[];var loopLength=length;var startPopulatingArray=false;if(direction=='backward'){array=$.makeArray(array);array.reverse();}
while(loopLength>0){$.each(array,function(index,val){if(loopLength>0){if(!startPopulatingArray){if(index==start){startPopulatingArray=true;sample.push($(this).clone());loopLength--;}}else{sample.push($(this).clone());loopLength--;}}else{return false;}});}
return sample;}
this.each(function(){base.initShow();});return this;}
jQuery.fx.prototype.cur=function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop];}
var r=parseFloat(jQuery.css(this.elem,this.prop));return r;}})(jQuery);

eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([237-9n-zA-Z]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(s(m){3.fn.pngFix=s(c){c=3.extend({P:\'blank.gif\'},c);8 e=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 5.5")!=-1);8 f=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 6.0")!=-1);p(3.browser.msie&&(e||f)){3(2).B("img[n$=.C]").D(s(){3(2).7(\'q\',3(2).q());3(2).7(\'r\',3(2).r());8 a=\'\';8 b=\'\';8 g=(3(2).7(\'E\'))?\'E="\'+3(2).7(\'E\')+\'" \':\'\';8 h=(3(2).7(\'F\'))?\'F="\'+3(2).7(\'F\')+\'" \':\'\';8 i=(3(2).7(\'G\'))?\'G="\'+3(2).7(\'G\')+\'" \':\'\';8 j=(3(2).7(\'H\'))?\'H="\'+3(2).7(\'H\')+\'" \':\'\';8 k=(3(2).7(\'V\'))?\'float:\'+3(2).7(\'V\')+\';\':\'\';8 d=(3(2).parent().7(\'href\'))?\'cursor:hand;\':\'\';p(2.9.v){a+=\'v:\'+2.9.v+\';\';2.9.v=\'\'}p(2.9.w){a+=\'w:\'+2.9.w+\';\';2.9.w=\'\'}p(2.9.x){a+=\'x:\'+2.9.x+\';\';2.9.x=\'\'}8 l=(2.9.cssText);b+=\'<y \'+g+h+i+j;b+=\'9="W:X;white-space:pre-line;Y:Z-10;I:transparent;\'+k+d;b+=\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;\';b+=\'J:K:L.t.M(n=\\\'\'+3(2).7(\'n\')+\'\\\', N=\\\'O\\\');\';b+=l+\'"></y>\';p(a!=\'\'){b=\'<y 9="W:X;Y:Z-10;\'+a+d+\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;">\'+b+\'</y>\'}3(2).hide();3(2).after(b)});3(2).B("*").D(s(){8 a=3(2).11(\'I-12\');p(a.A(".C")!=-1){8 b=a.13(\'url("\')[1].13(\'")\')[0];3(2).11(\'I-12\',\'none\');3(2).14(0).15.J="K:L.t.M(n=\'"+b+"\',N=\'O\')"}});3(2).B("input[n$=.C]").D(s(){8 a=3(2).7(\'n\');3(2).14(0).15.J=\'K:L.t.M(n=\\\'\'+a+\'\\\', N=\\\'O\\\');\';3(2).7(\'n\',c.P)})}return 3}})(3);',[],68,'||this|jQuery||||attr|var|style||||||||||||||src|navigator|if|width|height|function|Microsoft|appVersion|border|padding|margin|span|px|indexOf|find|png|each|id|class|title|alt|background|filter|progid|DXImageTransform|AlphaImageLoader|sizingMethod|crop|blankgif|appName|Internet|Explorer|parseInt|MSIE|align|position|relative|display|inline|block|css|image|split|get|runtimeStyle'.split('|'),0,{}));


var langue=new Object();
switch (cfg["langueAbr"])
{
 case 'fr':
 langue.nomLangue = 'Français';
 langue.prenom = 'prenom';
 langue.nom  = 'nom';
 langue.saisons = ["VIDE","Hiver","Automne","Été","Printemps"];
 langue.estEnvoye = 'Ce formulaire a déjà été envoyé.';
 langue.mois   = ["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"];
 langue.moisabr  = ['janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin', 'juill.', 'aout', 'sept.', 'oct.', 'nov.', 'dec.'];
 langue.jours   = ["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"];
 langue.joursMin = ["D","L","M","M","J","V","S"];
 langue.joursAbr = ["dim.","lun.","mar.","mer.","jeu.","ven.","sam."];
 break;
 
 case 'en': 
 langue.nomLangue = 'English';
 langue.prenom = 'firstname';
 langue.nom  = 'name';
 langue.saisons = ["VIDE","Winter","Autumn","Summer","Spring"];
 langue.estEnvoye = 'This for has already been sent.';
 langue.mois   = ["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"];
 langue.moisAbr  = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
 langue.jours   = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
 langue.joursMin = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
 langue.joursAbr = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
 break;
}

jQuery(document).ready(function($) {
if($.browser.msie && $.browser.version <= 6){
 $(document).pngFix();
}
activerMenus('nav',500);
if($('#slideshowAccueil').length > 0 && $('#slideshowAccueil ul li').length > 1){
$('#slideshowAccueil ul').bxSlider({
 displaySlideQty: 1,
 moveSlideQty: 1,
 controls:false,
 pager:true,
 pagerSelector:'.pagesSlideshow',
 speed:1500,
 auto:true,
 pause:5000
});
$('#boiteSlideshow .pagesSlideshow').css('width',$('#slideshowAccueil .pagesSlideshow').width()+'px').css('left',(($('#boiteSlideshow .pagesSlideshow').parent().width()/2)-($('#boiteSlideshow .pagesSlideshow').width()/2))+'px');
}

$("a[href^='http:'],a[href^='https:']")
 .not("[href*='" + location.hostname + "']").attr('target','_blank')
 .not(":has(img)")
 .not("[id]")
 .not(".twitter-share-button")
 .after('<img src="/images/icones/icone_externe.gif" width="12" height="12" alt="external link" style="margin-left:3px;"/>');

 $('.antiSpam').each(function(i) {
 jQuery(this).html(AntiSpam(jQuery(this).html())).toggle();
});

$("a[href$='.pdf'],a[href$='.doc'],a[href$='.docx'],a[href$='.rar'],a[href$='.zip']").attr('target','_blank').click(function() {CompterCliques(this.href)});


});

function ajouterClassesObligatoires(nomFormulaire){
if(typeof(nomFormulaire) == 'undefined'){
nomFormulaire = 'Donnees';
}
var nomFormulaire = "form[name=" + nomFormulaire +"]";
$(nomFormulaire).find(':input,select,textarea').each(function(){
if($(this).rules().required == true) {
 if($(this).is(':radio')){
 //$(this).closest('.ensembleCheckbox').sibblings('label').addclass('obl');
 $('#lbl_' + $(this).attr('name')).addClass('obl');
}else if($(this).is(':checkbox')){
 $(this).closest('.boiteChamp').children('label').addClass('obl');
}else{
 $(nomFormulaire +' :[for^='+ $(this).attr('name').replace('[]','') +']').addClass('obl');
}
}
});
}

