function CheckFields(fields) {
  var i = 0;
  var noms = '';
  var optim = null;
  var error = null;

  while (i < fields.length) {
	//init
	optim = document.getElementById(fields[i]);
	error = document.getElementById('input_error-'+fields[i]);

	error.style.display = "none";
	
    if (optim.value == '' || optim.attributes.getNamedItem('defaultvalue').value == optim.value) {
      		noms += fields[i] + "\n";
	  		error.style.display = "block";
    }
    i++;
  }
  if (noms != "") {
    //alert("Vous devez remplir les champs suivants :\n" + noms);
    return false;
  }
  return true;
}

/*
* DEFAULT VALUE SYSTEM
*/



$(document).ready(function () {
	$('input, textarea').each(function () {
		if ($(this).val() == '') {
			$(this).val($(this).attr('defaultvalue'));
		}
	}).focus(function () {
		$(this).removeClass('inputerror');
		if ($(this).val() == $(this).attr('defaultvalue')) {
			$(this).val('');
		}
	}).blur(function () {
		if ($(this).val() == '') {
			$(this).val($(this).attr('defaultvalue'));
		}
	});
	$('#comment_form').submit(function () {
		$('#submiterror').remove();
		var errors = 0;
		$(this).find('textarea, input').each(function () {
			if ($(this).val() == $(this).attr('defaultvalue')) {
				$(this).val('');
			}
			if ($(this).hasClass('required') && $(this).val() == '') {
				$(this).addClass('inputerror');
				errors++;
			}
		});

		if (errors > 0) {
			$(this).find('textarea, input').each(function () {
				if ($(this).val() == '') {
					$(this).val($(this).attr('defaultvalue'));
				}
			});
			$(this).prepend('<div id="submiterror">Veuillez remplir les champs incomplés</div>');
			return false;
		}
		return true;
	});
});
