function AskConfirmation(phrase, action) {
	var confirmation = confirm(phrase);
	if (confirmation == true) {
		eval(action);
	}
}
function radioDefault (champ) {
  if (typeof(champ) == "string") {
    var champ = document.getElementsByName(champ);
  }
	for(var i=0; i<champ.length; i++) {
		champ[i].className = "box";
	}
}
function ClearDropdownList (liste) {
	liste.options.length = 0;
	while (liste.childNodes[0]) {
		liste.childNodes[0].removeNode();
	}
}
function DeleteSelection (form, delete_type) {
	switch (delete_type) {
	default :
		var confirmation = confirm("Vous allez effacer la selection, voulez-vous continuer ?");
		var action = "delete";
		break;
	case "categorie" :
		var confirmation = confirm("Vous allez effacer la categorie et son contenu, voulez-vous continuer ?");
		var action = "delete_categorie";
		break;
	case "id" :
		var confirmation = confirm("Vous allez effacer cette entrée, voulez-vous continuer ?");
		var action = "delete_id";
		break;
	}
	if (confirmation == true) {
		form.sql_action.value = action;
		form.submit();
		return true;
	} else {
		return false;
	}
}
function changeSQLAction (form, valeur) {
	form.sql_action.value = valeur;
	form.submit();
}
function selectAllBoxes (boxlist) {
	for(var i=0; i<boxlist.length; i++) {
    boxlist[i].checked = true;
	}
}
function checkInputField (champ, type) {
	switch (type) {
	case "checkbox" :
	  if (typeof(champ) == "string") {
      var champ = document.getElementsByName(champ);
    }
		var isset = 0;
		for(var i=0; i<champ.length; i++) {
			if (champ[i].checked === true) {
				isset = 1;
			}
		}
		if (!isset) {
			for(var i=0; i<champ.length; i++) {
				champ[i].className = "box_error";
			}
			result="error";
		}
		break;
	case "textField" :
		if (champ.value == "" || champ.value == " ") {
			if (champ.className == "entier") {
				champ.className = "price_error";
			} else {
				champ.className = "error";
			}
			result="error";
		}
		break;
	case "select" :
		if (champ.value == "") {
			if (champ.className == "jour") {
				champ.className = "jour_error";
			} else if (champ.className == "mois") {
				champ.className = "mois_error";
			} else if (champ.className == "annee") {
				champ.className = "annee_error";
			} else {
				champ.className = "error";
			}
			result="error";
		}
		break;
	case "email" :
		if (champ.value == "" || champ.value == " ") {
			champ.className = "error";
			result="error";
		} else {
			var maReg = new RegExp ("^\\w[\\w+\.\-]*@[\\w\-]+\.\\w[\\w+\.\-]*\\w$", "gi") ;
			if(champ.value.search(maReg) == -1){
				result="error";
				champ.className = "error";
			}
		}
		break;
	}
}
