function isEmptyOnBlur(element)
{
   if(element.value == '')
   {
      element.style.borderColor = '#C33D1F';
   }
   else
   {
      element.style.borderColor = '#E2DAC7';
   }
}




function isEmpty(id)
{
   var data = document.getElementById(id).value;
   
   if(data === "" ||
      data === 0 ||
      data === "0" ||
      data === null ||
      data === false ||
      typeof data === 'undefined')
   {
      document.getElementById('selectsearch[type]').style.color   = '#C33D1F';
      return false;
   }
   else
   {
      document.getElementById('selectsearch[type]').style.color   = '#FFFFFF';
      return true;
   }
}




function isNumeric(id)
{
   var data = document.getElementById(id).value;
   
   if((typeof(data) === 'number' || typeof(data) === 'string') && data !== '' && !isNaN(data))
   {
      //document.getElementById(id).style.borderColor   = '#868686';
      document.getElementById(id+'Label').style.color = '#868686';
      return true;
   }
   else
   {
      //document.getElementById(id).style.borderColor   = '#C33D1F';
      document.getElementById(id+'Label').style.color = '#C33D1F';
      return false;
   }
}




function isDate(id)
{
   var date = document.getElementById(id).value;
   var exp  = new RegExp("(\\d{2}/?){2}(\\d{4}/?){1}", "g");
   
   if(exp.exec(date))
   {
      //document.getElementById(id).style.borderColor   = '#868686';
      document.getElementById(id+'Label').style.color = '#868686';
      return true;
   }
   else
   {
      //document.getElementById(id).style.borderColor   = '#C33D1F';
      document.getElementById(id+'Label').style.color = '#C33D1F';
      return false;
   }
}




function checkForm()
{
   var type    = isEmpty('syndicationCdtType');
   var duree   = isNumeric('syndicationCdtDuree');
   var arrivee = isDate('syndicationCdtArrivee');

   
   if(!duree || !arrivee || !type)
   {
      alert('Les données ne sont pas correctes, veuillez les corriger.');
      return false;
   }
   else
   {
      return true;
   }
}

/*window.addEvent('domready', function() { 
   new vlaDatePicker('arrivee', { openWith: 'togglePicker', offset: { y: -2, x: 2 }, separateInput: { day: 'day', month: 'month', year: 'year' } });
});
*/
