/* generated javascript */
var skin = 'monobook';
var stylepath = '/amerwiki/skins';

/* MediaWiki:Common.js */
/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */

/* MediaWiki:Monobook.js */
/* <pre> <nowiki> */

//============================================================
//
// Barre d'outil
//
//============================================================

//============================================================
// Générateur de tableaux
//============================================================

/**
 *
 * English: Generate an array using Mediawiki syntax
 *
 * @author: fr:user:dake
 * @version: 0.1
 */
 
function generateTableau(nbCol, nbRow, border, styleHeader, styleLine)
{
	var code = "\n";
	if (styleHeader==1) {
		code += '{{entête tableau charte}}\n';
	} else {
		code += '{| border="' + border + '"\n';
		code += '|+ Titre du tableau\n';
	}
	
	for (var i=0; i<nbCol; i++) code += '! en-tête ' + i + '\n';
	
	for (var j=0; j<nbRow; j++) {
		if ((j+1)%2==0 && styleLine==1) {
			code += '|-{'+'{ligne grise}'+'}\n';
		} else {		
			code += '|-----\n';
		}
		
		for (var i=0; i<nbCol; i++) code += '| élément\n';
	}
	
	code += '|}';
	insertTags('','', code);
}

/**
 *
 * English: Open a popup with parameters to generate an array. 
 * The number of rows/columns can be modified. Some additional
 * parameters are related to templates available on :fr
 *
 * @author: fr:user:dake
 * @version: 0.1
 */
 
function popupTableau()
{
  var popup = window.open('','name','height=400,width=500');
  
  javaCode =  '<script type="text\/javascript">function insertCode(){';
  javaCode += 'var row = parseInt(document.paramForm.inputRow.value); ';
  javaCode += 'var col = parseInt(document.paramForm.inputCol.value); ';
  javaCode += 'var bord = parseInt(document.paramForm.inputBorder.value); ';
  javaCode += 'var styleHeader = document.paramForm.inputHeader.checked; ';
  javaCode += 'var styleLine = document.paramForm.inputLine.checked; ';
  javaCode += 'window.opener.generateTableau(col,row,bord,styleHeader,styleLine); ';
  javaCode += '}<\/script>';
  
  popup.document.write('<html><head><title>Paramètres du tableau</title>');
  popup.document.write('<script type="text\/javascript" src="\/skins\/common\/wikibits.js"><!-- wikibits js --><\/script>');
  popup.document.write('<style type="text\/css" media="screen,projection">/*<![CDATA[*/ @import "\/skins-1.5\/monobook\/main.css?5"; /*]]>*/<\/style>');
  popup.document.write(javaCode); 
  popup.document.write('</head><body>');
  popup.document.write('<p>Veuillez entrer les paramètres du tableau : </p>');
  popup.document.write('<form name="paramForm">');
  popup.document.write('Nombre de lignes : <input type="text" name="inputRow" value="3" ><p>');
  popup.document.write('Nombre de colonnes : <input type="text" name="inputCol" value="3" ><p>');
  popup.document.write('Largeur de la bordure : <input type="text" name="inputBorder" value="1" ><p>');
  popup.document.write('En-tête en gris (style « charte graphique ») : <input type="checkbox" name="inputHeader" checked="1" ><p>');
  popup.document.write('Lignes grises alternées (style « charte graphique ») : <input type="checkbox" name="inputLine" checked="1" ><p>');
  popup.document.write('</form">');
  popup.document.write('<p><a href="javascript:insertCode()"> Insérer le code dans la fenêtre d\'édition</a></p>');
  popup.document.write('<p><a href="javascript:self.close()"> Fermer</a></p>');
  popup.document.write('</body></html>');
  popup.document.close();
}

//============================================================
// Insertion de nouveaux boutons dans la barre d'outil
//============================================================

//Remplit la variable mwCustomEditButtons (voir /skins/commons/wikibits.js) pour ajouter des boutons à la barre d'outils
function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText)
{
 mwCustomEditButtons[mwCustomEditButtons.length] =
 {"imageFile": imageFile,
  "speedTip": speedTip,
  "tagOpen": tagOpen,
  "tagClose": tagClose,
  "sampleText": sampleText};
}

addCustomButton('http://aurphil.net/amerwiki/skins/commons/images/btn/Btn_toolbar_rayer.png','Rayer',"<s>","</s>",'');
addCustomButton('http://aurphil.net/amerwiki/skins/commons/images/btn/Btn_toolbar_enum.png','Énumération',"\\n# élément 1\\n# élément 2\\n# élément 3","",'');
addCustomButton('http://aurphil.net/amerwiki/skins/commons/images/btn/Btn_toolbar_liste.png','Liste',"\\n* élément A\\n* élément B\\n* élément C","",'');
addCustomButton('http://aurphil.net/amerwiki/skins/commons/images/btn/Btn_toolbar_gallery.png','Galerie d\'images',"\\n<gallery>\\nImage:M63.jpg|[[M63]]\\nImage:Mona Lisa.jpg|[[La Joconde]]\\nImage:Truite arc-en-ciel.jpg|Une [[truite]]\\n</gallery>","",'');
addCustomButton('http://aurphil.net/amerwiki/skins/commons/images/btn/Btn_toolbar_commentaire.png','Commentaire',"<!--","-->",'');
addCustomButton('http://aurphil.net/amerwiki/skins/commons/images/btn/Button_redirect.png','Redirection',"#REDIRECT [[","]]",'nom de la destination');
addCustomButton('http://aurphil.net/amerwiki/skins/commons/images/btn/Button_category03.png','Catégorie',"[[Catégorie:","]]",'nom de la catégorie');

//Ressemble à la fonction de /skins/commons/wikibits.js pour insérer un autre lien que insertTags
function marque_tab()
{
 var toolbar = document.getElementById('toolbar');
 if (!toolbar) return false;
 
 var textbox = document.getElementById('wpTextbox1');
 if (!textbox) return false;
 
 if (!document.selection && textbox.selectionStart == null)
 return false;
 
 var image = document.createElement("img");
 image.width = 23;
 image.height = 22;
 image.src = 'http://aurphil.net/amerwiki/skins/commons/images/btn/Button_array.png';
 image.border = 0;
 image.alt = 'Tableau';
 image.title = 'Tableau';
 image.style.cursor = "pointer";
 image.onclick = function() {
   popupTableau();
   return false;
 }
 toolbar.appendChild(image);
}

addOnloadHook(marque_tab);

/**
 * Déplacement des [modifier]
 *
 * Correction des titres qui s'affichent mal en raison de limitations dues à MediaWiki.
 *
 * Copyright 2006, Marc Mongenet. Licence GPL et GFDL.
 *
 * The function looks for <span class="editsection">, and move them
 * at the end of their parent and display them inline in small font.
 * var oldEditsectionLinks=true disables the function.
 */
function setModifySectionStyle() 
{
 
        var process = function(list)
        {
                for(var i=0;i!=list.length;i++)
                {
                        var span=list[i].firstChild
 
                        if (span.className == "editsection") 
                        {
                                span.style.fontSize = "xx-small";
                                span.style.fontWeight = "normal";
                                span.style.cssFloat = span.style.styleFloat = "none";
                                span.parentNode.appendChild(document.createTextNode(" "));
                                span.parentNode.appendChild(span);
                        }
                }
        }
 
        try 
        {
                if (!(typeof oldEditsectionLinks == 'undefined' || oldEditsectionLinks == false)) return;
                process(document.getElementsByTagName("h2"));
                process(document.getElementsByTagName("h3"));
                process(document.getElementsByTagName("h4"));
                process(document.getElementsByTagName("h5"));
                process(document.getElementsByTagName("h6"));
 
        }
        catch (e) { }
}

addOnloadHook(setModifySectionStyle);


/* </nowiki> </pre> */