// Ajax minitchat
function loadStart() {
  	checkMessage();
  	checkConnectes();
	new PeriodicalExecuter(checkMessage, 10);
	new PeriodicalExecuter(checkConnectes, 30);
}

function checkMessage() {
	new Ajax.Updater('minitchat', 'minitchat.php', { method: 'post', onComplete: scrollDown });
}

function checkConnectes() {
	new Ajax.Updater('nbConnectes', 'nbConnectes.php', { method: 'post' });
}

function scrollDown() {
	$(minitchat).scrollTop +=1000;
}

function sendMsg() {
	new Ajax.Updater('minitchat', 'minitchat.php', { method: 'post', parameters: $('form_minitchat').serialize(true), onComplete: scrollDown });
	document.form_minitchat.message.value = '';
}

function loadPage(page) {
	$(cadrePhoto).style.visibility = 'hidden';
	new Ajax.Updater('div_centre', page + '.php', { method: 'post' });
}
// Fin ajax minitchat

function MM_findObj(n, d) { //v4.01
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function findImageSize(img) {
    if ((img=MM_findObj(img)) != null)
        return [img.width, img.height];
    return [-1, -1];
}

function findPosition(obj) {
    if ((obj=MM_findObj(obj)) != null) {
        if (obj.offsetParent) {		// IE, mozilla
            for(var posX = 0, posY = 0; obj.offsetParent; obj = obj.offsetParent) {
                posX += obj.offsetLeft;
                posY += obj.offsetTop;
            }
            return [posX, posY];
        } else {			// Netscape
            return [obj.x, obj.y];
        }
    }
    return [-1, -1];
}

function hideAllMenus() {
	for (i=1; i < 10; i++) {
		showHideLayer('menu' + i, 'hide');
    }
    return false;
}

function showHideLayer(calque, action, display) {
    var a, b;
    action = (action == 'show') ? 'visible' : 'hidden';
    if ((a=MM_findObj(calque)) != null) {
        b = (document.layers) ? a : a.style;
        b.visibility = action;
        if (display == 'block')
            b.display="block";
        else if (display == 'none')
            b.display="none";
    }
    return false;
}

// positionne le layer relativement à un objet
// en ajoutant x et y aux coordonnées
function LayerPosObject(obj, calque, x, y) {
	var a, b, posX, posY;
	var arrayPos = new Array();
	arrayPos = findPosition(obj);
	if ((a=MM_findObj(calque)) != null && arrayPos[0] != -1) {
		b = (document.layers) ? a : a.style;
		b.left = arrayPos[0] + x;
		// si ca dépasse de l'ecran, on retourne le calque
		if ((arrayPos[0] + x + a.clientWidth) > document.body.clientWidth) {
            b.left =  document.body.clientWidth - a.clientWidth - 1;
    	}
		b.top = arrayPos[1] + y;
		showHideLayer(calque, 'show');
	}
	return false;
}

// positionne le layer relativement à la position de la souris
// en ajoutant x et y aux coordonnées
function LayerPosMouse(e, calque, x, y) {
    if(!e) {
        if(window.event)
            e = window.event;
        else
            return false;
    }
    var a, b, posX, posY;
    if ((a=MM_findObj(calque)) != null) {
        b = (document.layers)? a : a.style;
        posX = (e.clientX) ? e.clientX : e.pageX;		// clientX : IE, mozilla, konqueror    pageX : netscape, mozilla
        posY = (e.clientY) ? e.clientY : e.pageY;
        // on rajoute aux coordonnées, le scroll de la page
        if(!(window.navigator.userAgent.indexOf('Opera') + 1)) {
            if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
                //IE 4, 5 & 6 (in non-standards compliant mode)
                posX += document.body.scrollLeft;
                posY += document.body.scrollTop;
            } else if( document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
                //IE 6 (in standards compliant mode)
                posX += document.documentElement.scrollLeft;
                posY += document.documentElement.scrollTop;
            }
        }
        b.left = posX + x;
        b.top = posY + y;
        showHideLayer(calque, 'show');
    }
    return false;
}

// positionne le layer relativement à une image
// en ajoutant x et y aux coordonnées
function LayerPosImage(img, calque, mode, x, y) {
	var browserName=navigator.appName; 
	if (browserName=="Netscape"){ 
 		y = y - 1;
	}
	var a, b, posX, posY;
	var arrayPos = new Array();
	var arrayImgSize = new Array();
	arrayPos = findPosition(img);
	arrayImgSize = findImageSize(img)
	if ((a=MM_findObj(calque)) != null && arrayPos[0] != -1 && arrayImgSize[0] != -1) {
		posX = arrayPos[0];
		posY = arrayPos[1];
		if (mode == "right") {
			posX += arrayImgSize[0];
		} else if (mode == "bottom") {
			posY += arrayImgSize[1];
		}
		b = (document.layers) ? a : a.style;
		b.left = posX + x;
		b.top = posY + y;
		showHideLayer(calque, 'show');
	}
	return false;
}

function MM_preloadImages() { //v3.0
/*	img = new Array();
	myArray = new Array("fond_ecran.jpg", "fond_menu.gif", "bandeau.jpg", "pipe.gif", "arrondi", "image_centre", "fond_gauche", "filet_doree", "doree_long");
	for (i=0; i < myArray.length; i++) {
		img[i] = new Image;
		img[i].src="/images/<? echo $theme ?>/" + myArray[i];
	}*/
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function reload_livre() {
	with (document.livre) {
		if (document.livre.filtre) {
		document.location.href="index.php?choix=livre&choix_livre=" + choix_livre.options[choix_livre.selectedIndex].value + "&filtre=" + filtre.value;
		} else {
		document.location.href="index.php?choix=livre&choix_livre=" + choix_livre.options[choix_livre.selectedIndex].value;
		}
	}
}

function reload_poemes() {
	with (document.poemes) {
		document.location.href="index.php?choix=poemes&choix_poemes=" + choix_poemes.options[choix_poemes.selectedIndex].value;
	}
}

function reload_bestof() {
	with (document.bestof) {
		document.location.href="index.php?choix=bestof&choix_bestof=" + choix_bestof.options[choix_bestof.selectedIndex].value;
	}	
}

function reload_temoignages() {
	with (document.temoignages) {
		document.location.href="index.php?choix=temoignages&id_sujet=" + id_sujet.options[id_sujet.selectedIndex].value;
	}
}

function reload_mes_photos() {
	with (document.upload) {
		document.location.href="index.php?choix=mes_photos&id_compte=" + id_compte.options[id_compte.selectedIndex].value;
	}
}

function reload_mes_photos2() {
	with (document.upload) {
		if (document.upload.id_compte!=null) {
			document.location.href="index.php?choix=mes_photos&id_compte=" + id_compte.options[id_compte.selectedIndex].value + "&num_photo=" + num_photo.options[num_photo.selectedIndex].value;
		} else {
			document.location.href="index.php?choix=mes_photos&num_photo=" + num_photo.options[num_photo.selectedIndex].value;
		}
	}	
}

function reload_admin_news(param) {
	with (document.admin_news) {
		if (param==1)
			document.location.href="index.php?choix=admin_news&categorie=" + categorie.options[categorie.selectedIndex].value;
		else {
			if (id_news.selectedIndex != 0)
				document.location.href="index.php?choix=admin_news&categorie=" + categorie.options[categorie.selectedIndex].value + "&id_news=" + id_news.options[id_news.selectedIndex].value;
			else {
				auteur.value="";
				titre.value="";
				texte.value="";
				date.value="";
				heure.value="";
				online.selectedIndex=0;
				auteur.focus();
			}
		}
	}
}

function effacer(choix, id_msg, complement) {
	if (confirm("Etes-vous sûr de vouloir effacer ce message ? ")) {
		adresse = "index.php?choix=" + choix + "&option=effacer&id_msg=" + id_msg;
		if (complement != null && complement != "")
			adresse += "&" + complement;
		document.location.href=adresse;
	}
	return false;
}

function effacer_lien(id_lien) {
	if (confirm("Etes-vous sûr de vouloir effacer ce lien ? "))
		document.location.href="index.php?choix=menus_persos&id_deleted_lien=" + id_lien;
	return false;
}

function add_smileys(symbole) {
	with (document.livre) {
		message.value = message.value + symbole;
		message.focus();
	}
	return false;
}

function validation_livre() {
	with (document.livre) {
		if (message.value=="") {
			alert("Vous devez saisir un message");
			message.focus();
			return false;
		}
		if (choix.value=="messages_perso") {
			if (elements["dest[]"].options.length == 0 || elements["dest[]"].options.length > 10) {
				alert("Vous devez choisir au moins un destinataire");
				return false;
			} else {
				for(var i=0; i < elements["dest[]"].options.length; i++)
					elements["dest[]"].options[i].selected = true;
			}
		}
		document.livre.submit();
		return false;
	}
}

function validation_compte1() {
	with (document.compte) {
		erreur = "";
		if (pseudo.value=="")
			erreur += "Le pseudo est obligatoire\n";
		else if (!control_pseudo(pseudo))
			erreur += "Votre pseudo contient des caractères interdits\n";
		if (mail.value=="")
			erreur += "L'email est obligatoire\n";		
		else if (!control_mail(mail))
			erreur += "L'email saisi n'est pas correct\n";
		if (erreur!="") {
			alert(erreur);
			return false;
		}
		document.compte.submit();
		return false;
	}
}

function validation_compte2() {
	with (document.compte) {
		erreur = "";
		if (pass.value=="")
			erreur += "Le password est obligatoire\n";
		if (pass2.value=="")
			erreur += "Vous devez confirmer votre password\n";
		if (pass.value!=pass2.value)
			erreur += "Les deux password saisis ne sont pas identiques\n";
		if (control_int(poids)==false)
			erreur += "Le poids doit être un nombre entre 0 et 999 lol\n";
		if (control_int(taille)==false)
			erreur += "La taille doit être un nombre entre 0 et 999 lol\n";
		if (mail.value=="")
			erreur += "L'email est obligatoire\n";		
		else if (control_mail(mail)==false)
			erreur += "L'email saisi n'est pas correct\n";
		erreur += control_date_combo(jour, mois, annee, "La date de naissance");
			
		if (erreur!="") {
			alert(erreur);
			return false;
		}
		document.compte.submit();
		return false;
	}
}

function control_pseudo(champs) {
	var re = /^[A-Za-z0-9_\-]+$/;
	if (!re.test(champs.value))
		return false;
	return true;
}

function control_mail(champs) {
	var re = /^[A-Za-z0-9_\-\.]+[@]\w([A-Za-z0-9_\-]+)[\.]([A-Za-z]+)/;
	if (!re.test(champs.value))
		return false;
	return true;
}

function control_int(champs) {
	if (champs.value != "") {
		var re=/^[0-9]{0,3}$/;
		if (!re.test(champs.value))
			return false;
	}
	return true;
}

function control_son(champs) {
	if (champs.value!="") {
		var re=/mid|wav/;
		if (!re.test(champs.value.toLowerCase())) {
			alert("Vous devez choisir un fichier .wav ou .mid");
		}
	}
}

function control_photo(champs) {
	if (champs.value!="") {
		var re=/jpg|jpeg|gif/;
		if (!re.test(champs.value.toLowerCase())) {
			alert("Vous devez choisir un fichier .gif ou .jpg");
		}
	}
}

function control_date_combo(champ1, champ2, champ3, messages) {
	valeur=champ1.options[champ1.selectedIndex].value + "/" + champ2.options[champ2.selectedIndex].value + "/" + champ3.options[champ3.selectedIndex].value; 
	if (valeur=="0/0/0")
		return "";
	var re = /(\d{2})[.\/ ]+(\d{2})[.\/ ]+(\d{4})/
	if (!re.test(valeur))
		return messages + " n'est pas valide\n";
	else {
		MyRes = re.exec(valeur)
		UserEntry = parseInt(MyRes[1],10) + '/' + parseInt(MyRes[2],10) + '/' + parseInt(MyRes[3],10)
		MyDate = new Date(parseInt(MyRes[3],10), parseInt(MyRes[2],10)-1, parseInt(MyRes[1],10))
		CompDate = MyDate.getDate() + '/' + eval(MyDate.getMonth()+1) + '/' + MyDate.getFullYear()
		if (UserEntry != CompDate)
			return messages + " n'est pas valide\n";
	}
	return "";
}

function validation_oublie_pass() {
	with (document.oublie) {
		erreur = "";
		if (mail.value=="")
			erreur += "L'email est obligatoire\n";
		else if (control_mail(mail)==false)
			erreur += "L'email saisi n'est pas correct\n";
		if (erreur!="") {
			alert(erreur);
			return false;
		}
		document.oublie.submit();
		return false;
	}
}

function validation_parrainage() {
	with (document.parrainage) {
		erreur = "";
		if (nom.value=="")
			erreur += "Le nom est obligatoire\n";
		if (mail.value=="")
			erreur += "L'email est obligatoire\n";
		else if (!control_mail(mail))
			erreur += "L'email saisi n'est pas correct\n";
		if (erreur!="") {
			alert(erreur);
			return false;
		}
		document.parrainage.submit();
		return false;
	}
}

function validation_upload() {
	if (document.upload.fichier != null && document.upload.fichier.value=="")
		alert("Veuillez choisir un fichier");
	else
		document.upload.submit();
	return false;
}

// fonction pour les combos des messages perso
function move(fbox,tbox,add) {
	for(var i=0; i<fbox.options.length; i++) {
		if(fbox.options[i].selected && fbox.options[i].value != "") {
			if (add) {
				if (tbox.options.length < 10) {
					trouve = false;
					for(var j=0; j<tbox.options.length; j++) {
						if (fbox.options[i].value == tbox.options[j].value)
							trouve = true;
					}
					if (!trouve) {
						var no = new Option();
						no.value = fbox.options[i].value;
						no.text = fbox.options[i].text;
						tbox.options[tbox.options.length] = no;
						/*fbox.options[i].value = "";
						fbox.options[i].text = "";*/
					}
				}
			} else {	
				/*var no = new Option();
				no.value = fbox.options[i].value;
				no.text = fbox.options[i].text;
				tbox.options[tbox.options.length] = no;*/
				fbox.options[i].value = "";
				fbox.options[i].text = "";
			}
   		}
	}
	if (add) SortD(tbox);
	else BumpUp(fbox);
}

function BumpUp(box)  {
	for(var i=0; i<box.options.length; i++) {
		if(box.options[i].value == "")  {
			for(var j=i; j<box.options.length-1; j++)  {
				box.options[j].value = box.options[j+1].value;
				box.options[j].text = box.options[j+1].text;
			}
			var ln = i;
			break;
   		}
	}
	if(ln < box.options.length)  {
		box.options.length -= 1;
		BumpUp(box);
	}
}

function SortD(box)  {
	var temp_opts = new Array();
	var temp = new Object();
	for(var i=0; i<box.options.length; i++)  {
		temp_opts[i] = box.options[i];
	}
	for(var x=0; x<temp_opts.length-1; x++)  {
		for(var y=(x+1); y<temp_opts.length; y++)  {
			if(temp_opts[x].text > temp_opts[y].text)  {
				temp = temp_opts[x].text;
				temp_opts[x].text = temp_opts[y].text;
				temp_opts[y].text = temp;
				temp = temp_opts[x].value;
				temp_opts[x].value = temp_opts[y].value;
				temp_opts[y].value = temp;
      		}
   		}
	}
	for(var i=0; i<box.options.length; i++)  {
		box.options[i].value = temp_opts[i].value;
		box.options[i].text = temp_opts[i].text;
   	}
}

function effacer_persos() {
	if (confirm("Etes-vous sûr de vouloir effacer ces messages ?"))
		document.messages_perso.submit();
	return false;
}

var zoom="";
function zoom_photo(id_fiesta, nom_photo, largeur, hauteur) {
	if (navigator.platform.indexOf('Win') > -1) {
		if (zoom!="" && !zoom.closed)
			zoom.close();
		zoom=window.open('zoom.php?id_fiesta=' + id_fiesta + '&nom_photo=' + nom_photo,'zoom','status=yes,width=' + largeur + ',height=' + hauteur);
	} else
		window.open('zoom.php?id_fiesta=' + id_fiesta + '&nom_photo=' + nom_photo,'zoom','status=yes,width=' + largeur + ',height=' + hauteur);
	return false;
}

function ecouter() {
	with (document.compte) {
		if (fichier.value!="") {
			var re=/mid|wav/;
			if (re.test(fichier.value)) {
				window.open("ecouter.php?son=" + fichier.value,"Ecouter","width=100,height=100");
			} else
				alert("Vous devez choisir un fichier .mid ou .wav");
		}
	}
	return false;
}

function ecouter2(son) {
	var re=/mid|wav/;
	if (re.test(son)) {
		window.open("ecouter.php?son=" + son,"Ecouter","width=100,height=100");
	}
	return false;
}

function diaporama(fichier, legende) {
	if (fichier != document.photoFiche.src) {
		document.photoFiche.src=fichier;
		document.photoFiche.alt=legende;
	}
	return false;
}

function effacer_recette(categorie, recette) {
	if (confirm("Voulez-vous effacer cette recette ?"))
		document.location.href="index.php?choix=liste_recettes&categorie=" + categorie + "&recette=" + recette;
	return false;
}

function visualiser_son() {
	window.open("visualisation_son.php", "Modifier", "status=yes,width=250,height=200");
	return false;
}

function visualiser_photo(indice) {
	window.open("visualisation_photo.php?indice=" + indice, "Modifier", "status=yes,width=240,height=280");
	return false;
}

function supprimer_photo(indice) {
	if (confirm("Etes-vous sûr de vouloir supprimer cette photo ?"))
		document.location.href="save_mes_photos.php?choix=suppr&option=" + indice;
	return false;
}

function placeCadre() {
	LayerPosImage('photoFiche', 'cadrePhoto', '', -3, -6);
}

function validation_admin_news() {
	with (document.admin_news) {
		if (titre.value == "" || texte.value == "" || date.value == "" || heure.value == "" || auteur.value == "") {
			alert("Vous devez remplir tous les champs");
			return false;
		}
		var re = /(\d{4})[-]+(\d{2})[-]+(\d{2})/
		if (!re.test(date.value)) {
			alert("La date n'est pas au bon format");
			return false;
		} else {
			MyRes = re.exec(date.value)
			UserEntry = parseInt(MyRes[1],10) + '-' + parseInt(MyRes[2],10) + '-' + parseInt(MyRes[3],10)
			MyDate = new Date(parseInt(MyRes[1],10), parseInt(MyRes[2],10)-1, parseInt(MyRes[3],10))
			CompDate = MyDate.getFullYear() + '-' + eval(MyDate.getMonth()+1) + '-' + MyDate.getDate()
			if (UserEntry != CompDate) {
				alert(date.value + " n'est pas une date valide");
				return false;
			}
		}

		submit();
	}
	return false;
}

function effacer_admin_news() {
	with (document.admin_news) {
		if (id_news.selectedIndex == 0)
			alert("Vous devez sélectionner une news");
		else {
			if (confirm("Etes-vous sûr de vouloir effacer définitivement cette news ? "))
				document.location.href="index.php?choix=admin_news&option=effacer&categorie=" + categorie.options[categorie.selectedIndex].value + "&id_news=" + id_news.options[id_news.selectedIndex].value;
		}
	}
	return false;
}

function popupnews(id_news, categorie, debut) {
	var top=(screen.height-300)/2;
  	var left=(screen.width-400)/2;
	Potonews=window.open("popupnews.php?id_news=" + id_news + "&categorie=" + categorie + "&debut=" + debut,"Potonews","top=" + top + ",left=" + left + ",width=400,height=300,status=yes,resizable=yes,scrollbars=yes");
	Potonews.focus();
}

function popuptchat() {
	var top=(screen.height-300)/2;
  	var left=(screen.width-400)/2;
	tchat=window.open("popuptchat.php","tchat","top=" + top + ",left=" + left + ",width=250,height=200,status=yes,resizable=yes,scrollbars=yes");
	tchat.focus();
}

function valid_tchat(realpseudo) {
	var salon;
	with (document.monform) {
		message = "";
		if (nick.value!="") {
			if (!control_pseudo(nick))
				message = "Votre pseudo contient des caractères interdits\n";
		} else
			message = "Veuillez saisir un pseudo\n";
		if (message != "") {
			alert(message);
			return false;
		} else {
			if (navigator.appVersion.substring(0,1) >= 4) {
				var wid = (screen.width-9);
				var hei = (screen.height-75);
				var wid2 = (screen.width-29);
				var hei2 = (screen.height - 188);
				if (wid > 1013)
					wid2 = 997;
				if (hei > 690)
					hei2 = 572;
				document.monform.width.value = wid2;
				document.monform.height.value = hei2;
			}
			var adresse = "/tchat/tchat.php?width=" + wid2 + "&height=" + hei2 + "&nick=" + document.monform.nick.value + "&channel=" + document.monform.channel.value + "&realpseudo=" + realpseudo;
			window.open(adresse,"PotoTchat","left=0,top=0,width=" + wid + ",height=" + hei + ",status=yes,resizable=yes");
		}
	}
	return false;
}

function confirm_desinscription() {
	with (document.desinscription) {
		if (confirm("Etes-vous sûr de vouloir supprimer votre compte"))
			submit();
	}	
	return false;
}

function confirm_delete_compte() {
	with (document.delete_compte) {
		if (confirm("Etes-vous sûr de vouloir effacer le compte d'id " + id_compte.options[id_compte.selectedIndex].value))
			submit();
	}	
	return false;
}

function validation_recette() {
	with (document.recette) {
		erreur = "";
		if (nom.value=="")
			erreur += "Le nom est obligatoire\n";
		if (description.value=="")
			erreur += "La description est obligatoire\n";
		if (nb_personnes.value!=null && control_int(nb_personnes)==false)
			erreur += "Le nombre de personnes doit être un chiffre\n";
		if (ingredients.value=="")
			erreur += "Les ingrédients sont obligatoires\n";
		if (tps_preparation.value=="")
			erreur += "Le temps de préparation est obligatoire\n";
		if (preparation.value=="")
			erreur += "La préparation est obligatoire\n";
		if (erreur!="") {
			alert(erreur);
			return false;
		}
		document.recette.submit();
		return false;
	}
}

function validation_recherche() {
	with (document.livre) {
		le_jour = jour.options[jour.selectedIndex].value
		le_mois = mois.options[mois.selectedIndex].value
		l_annee = annee.options[annee.selectedIndex].value
		if (le_jour < "10")
			le_jour=le_jour.substring(1,2)
		if (le_mois < "10")
			le_mois=le_mois.substring(1,2)
		
		UserEntry = le_jour + '/' + le_mois + '/' + l_annee;
		MyDate = new Date(l_annee, le_mois - 1, le_jour);
		CompDate = MyDate.getDate() + '/' + eval(MyDate.getMonth()+1) + '/' + MyDate.getFullYear();
		if (UserEntry != CompDate) {
			alert("Ce n'est pas une date valide");
			return false;
		}
		if (document.livre.choix_type!=null && !choix_type[2].checked && mot.value == "") {
			alert("Vous devez taper un mot");
			return false;
		}
		submit();
		return false;
	}
}

function reload_admin_liens(param) {
	with (document.admin_liens) {
		if (param == 1) {
			if (cat_id.selectedIndex == 0)
				cat_nom.value = "";
			else
				cat_nom.value = cat_id.options[cat_id.selectedIndex].text;
		}
		if (param == 2) {
			document.location.href="index.php?choix=admin_liens&lien_id_cat=" + lien_id_cat.options[lien_id_cat.selectedIndex].value;
		}
		if (param == 3) {
			if (lien_id.selectedIndex == 0) {
				lien_nom.value = "";
				lien_desc.value = "";
				lien_url.value = "";			
			} else
				document.location.href="index.php?choix=admin_liens&lien_id_cat=" + lien_id_cat.options[lien_id_cat.selectedIndex].value + "&lien_id=" + lien_id.options[lien_id.selectedIndex].value;		
		}
	}
}

function effacer_admin_liens(param) {
	with (document.admin_liens) {
		if (param == "cat") {
			if (cat_id.selectedIndex == 0)
				alert("Vous devez sélectionner une catégorie");
			else {
				if (confirm("Etes-vous sûr de vouloir effacer cette catégorie ? "))
					document.location.href="index.php?choix=admin_liens&option=D&id_cat=" + cat_id.options[cat_id.selectedIndex].value;
			}
		} else {
			if (lien_id.selectedIndex == 0)
				alert("Vous devez sélectionner un lien");
			else {
				if (confirm("Etes-vous sûr de vouloir effacer ce lien ? "))
					document.location.href="index.php?choix=admin_liens&option=D&id_lien=" + lien_id.options[lien_id.selectedIndex].value;
			}
		}
	}
	return false;
}

function validation_admin_liens(param) {
	with (document.admin_liens) {
		if (param == "cat") {
			if (cat_nom.value == "") {
				alert("Vous devez saisir un nom pour la catégorie");
				return false;
			}
			type.value="cat";
		} else {
			if (lien_nom.value == "" || lien_desc.value == "" || lien_url.value == "") {
				alert("Vous devez remplir tous les champs");
				return false;
			}
			if (lien_url.value.indexOf("http://") < 0) {
				alert("L'url du lien n'est pas valide\nElle doit commencer par http://");
				return false;
			}
			type.value="lien";			
		}
		submit();
	}
	return false;
}
