function affiche(chaine){
	alert(chaine);
}

function setLang(){
	var selLang=document.getElementById("selLang");
	window.location.href="setLang.php?id="+selLang.value; 
}

function setLangAd(){
	var selLang=document.getElementById("selLang");
	window.location.href="setLangAd.php?id="+selLang.value; 
}

function verfiFormAdmin(){
	var login=document.getElementById("login");
	var pwd=document.getElementById("pwd");
	var phrase="Veuillez verifier les champs suivants :\n";
	var valRetour=true;
	
	if(login.value==""){
		phrase=phrase+" - Username\n";
		valRetour=false;
	}
	if(pwd.value==""){
		phrase=phrase+" - Password\n";
		valRetour=false;
	}
	
	if(valRetour)
		return valRetour;
	else{
		alert(phrase);
		return valRetour;
	}
}
function verifFormMenu(){
	var lblNom=document.getElementById("lblNom");
	var lblUrl=document.getElementById("lblUrl");
	var linkToUrl=document.getElementById("linkToUrl");
	var valRet = true;
	var message = "Veuillez completer les champs suivants :\n";
	
	if(lblNom.value==""){
		message = message + " - nom\n";
		valRet = false;
	}
	
	if(((lblUrl.value.indexOf("://",0))==-1)&&(linkToUrl.checked)){
		message = message + " - Le lien doit commencer par http://\n";
		valRet = false;
	}
	
	if(valRet)
		return valRet;
	else{
		alert(message);
		return valRet;
	}
}

function suppMenu(id,idC){
	if (confirm("Etes-vous sûr de vouloir supprimer ce menu ?")) {
		document.location = "index_admin.php?module=menu&action=supprimer&id=" + id +"&idC=" + idC;
	}
}

function suppLang(id){
	if (confirm("Etes-vous sûr de vouloir supprimer cette langue ?")) {
		document.location = "index_admin.php?module=langues&action=supprimer&id=" + id;
	}
}

function suppCom(id,file){
	if (confirm("Etes-vous sûr de vouloir supprimer ce commentaire ?")) {
		document.location = "index_admin.php?module=modules&who=livredor&file="+ file +"&action=actDel&idCom=" + id;
	}
}

function verifFormSite(){
	var lblTitre=document.getElementById("lblTitre");
	var lblTitreMenu=document.getElementById("lblTitreMenu");
	var phrase="Veuillez verifier les champs suivants :\n";
	var valRetour=true;
	
	if(lblTitre.value==""){
		phrase=phrase+" - Titre\n";
		valRetour=false;
	}
	if(lblTitreMenu.value==""){
		phrase=phrase+" - Titre du menu\n";
		valRetour=false;
	}
	
	if(valRetour)
		return valRetour;
	else{
		alert(phrase);
		return valRetour;
	}
}

function suppUser(id){
	if (confirm("Etes-vous sûr de vouloir supprimer cet utilisateur ?")) {
		document.location = "index_admin.php?module=utilisateurs&action=supprimer&id=" + id;
	}
}

function verifFormUsers(){
	var lblNom=document.getElementById("lblNom");
	var lblPwd=document.getElementById("lblPwd");
	var idUser=document.getElementById("idUser");
	
	var phrase="Veuillez verifier les champs suivants :\n";
	var valRetour=true;
	
	if(lblNom.value==""){
		phrase=phrase+" - Login\n";
		valRetour=false;
	}
	
	if((lblNom.value=="admin")&&(idUser==null)){
		phrase=phrase+" - L'utilisateur admin, ne peux être créer\n";
		valRetour=false;
	}
	
	if(lblPwd.value==""){
		phrase=phrase+" - Mot de passe\n";
		valRetour=false;
	}
	
	if(valRetour)
		return valRetour;
	else{
		alert(phrase);
		return valRetour;
	}
}

function actionChampSupp(chaine) {
	var chSupp = document.getElementById(chaine);
	var btnRadioMod = document.getElementById("linkToPage");
	var btnRadioUrl = document.getElementById("linkToUrl");
  	
  	if(btnRadioMod.checked) {
 		chSupp.style.display="block";
		btnRadioUrl.checked = false;
		actionChampSupp2('chSuppl');	
	}		
 	else {
 		chSupp.style.display="none";
	}
}

function actionChampSupp2(chaine) {
	var chSupp = document.getElementById(chaine);
	var btnRadioUrl = document.getElementById("linkToUrl");
	var btnRadioMod = document.getElementById("linkToPage");
  	
  	if(btnRadioUrl.checked) {
 		chSupp.style.display="block";
		btnRadioMod.checked = false;
		actionChampSupp('chSupp');		
	}		
 	else {
 		chSupp.style.display="none";
	}
}

function afficheAide(chaine) {
	var chSupp = document.getElementById('note'+chaine);
	var sh = document.getElementById('sh'+chaine);
	var hi = document.getElementById('hi'+chaine);
  	
  	if(chSupp.style.display=="block") {
 		chSupp.style.display="none";
		hi.style.display="none";
		sh.style.display="block";		
	}		
 	else {
 		chSupp.style.display="block";
		sh.style.display="none";
		hi.style.display="block";
	}
}

function popupcentree(page,largeur,hauteur) {
     var top=(screen.height-hauteur)/2;
     var left=(screen.width-largeur)/2;
     window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+",resible=no"); 
} 
