/**
 * confirmation du clic sur un lien
 * d'apres phpmyadmin
 */
function ConfirmLink(zeLink, zeMsg) {
	var is_confirmed = confirm(zeMsg);
    if (is_confirmed) {
        zeLink.href += '&ok=1';
    }
    return is_confirmed;
}

/**
 * ouvrir/fermer un bloc en CSS
 */
function showhide(id){
	var d = document.getElementById(id);
	if (d) {
		if (d.style.display=='block') {d.style.display='none';}
		else {d.style.display='block';}
	}
}

/**
 * bonus jquery
 */
$(document).ready(function(){
	if ($('#page').length ) {
		// ajoute une icone apres les liens externes
		$("#page a[@href^=\"http\"]").each(function(i){$(this).not("[@href*=\""+document.domain+"\"]").not(":has(img)").after(" <a href=\""+$(this).attr("href")+"\" onclick=\"window.open(this.href); return false;\" style=\"border: none;\"><img src=\"./img/external.gif\" alt=\"\" title=\"Ouvrir ce lien dans une nouvelle fenêtre / onglet\" /></a>");});
		
		// ajoute un 'tag' apres les liens qui ont un attribut LANG	
		$("#page a[@lang]").each(function(i){$(this).after(" <span style=\"font-size:0.9em;color:#808080\">[" + $(this).attr("lang") + "]</span>");});
	}
	
	if ($('#article').length ) {
		// agrandir/diminuer fontsize article (ftpm)
		$("#article").before('<div style="border:1px #d0d0d0 solid;padding:5px;margin:5px 0;width:66px;text-align:center;font-size:0.9em;background:#efefef"><a href="javascript:void(0);" id="ftpm_p"><img src="./img/zoom_in.png" alt="+" title="Agrandir le texte" /></a> &nbsp;<span id="ftpm" style="cursor:hand" title="Reset"></span> &nbsp;<a href="javascript:void(0);" id="ftpm_m"><img src="./img/zoom_out.png" alt="-" title="Rétrécir le texte" /></a></div>');
		
		var p = parseInt($("#article").css("font-size"));
		$("#ftpm").html(p);
	
		$("#ftpm").click(function() {
			$("#article").css("font-size", '1em');
			var p = parseInt($("#article").css("font-size"));
			$("#ftpm").html(p);
		});
		
		$("#ftpm_m").click(function() {
			var p = parseInt($("#article").css("font-size"));
			p = p - 2;
			$("#article").css("font-size", p + 'px');
			$("#ftpm").html(p);
		});
		
		$("#ftpm_p").click(function() {
			var p = parseInt($("#article").css("font-size"));
			p = p + 2;
			$("#article").css("font-size", p + 'px');
			$("#ftpm").html(p);
		});
	}

	// image cliquable des user-agent
	if ($('#admin_page').length ) {
		$(".uaaff").click(function() {
			if ($(this).attr("alt")!="1") {
				$(this).after(' <span style="color:#404040">' + $(this).attr("alt") + '</span><br />');
				$(this).attr("alt","1");
				$(this).attr("title","");
			}
			return false;
		});
	}
});
