// Fonctions communes

/**
 * trim() en PHP
 */
String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g,'');
}

/**
 * Pour ajouter une fonction lorsque la page est chargée
 */
function addLoadEvent(func) {
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    var oldonload = window.onload;
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

/**
 * Gestion des combos
 */
function createOption(label, value, selected, className) {
	var opt = document.createElement("option");
	opt.value = value;
	opt.appendChild(document.createTextNode(label));
	if (selected) {
		opt.selected = 'selected';
	}
	if (className != undefined) {
		opt.className = className;
	}
	return opt;
}

function emptyCombo(combo) {
	while (combo.length > 0) {
		combo.remove(0);
	}
}


