/* generated javascript */
if (!window.skin) {
	var skin = 'monaco';
	var stylepath = 'http://images.wikia.com/common/releases_200911.3/skins';
}

/* MediaWiki:Common.js */
//<pre> N’importe quel JavaScript ici sera chargé pour n’importe quel utilisateur et pour chaque page accédée.


//============================================================
//
// Boîtes déroulantes
//
//============================================================
 // BEGIN Dynamic Navigation Bars (experimantal)
 
 // set up the words in your language
 var NavigationBarHide = '[ Cacher ]';
 var NavigationBarShow = '[ Montrer ]';
 
 var NavigationBarShowDefault = 0;
 
 // shows and hides content and picture (if available) of navigation bars
 // Parameters:
 //     indexNavigationBar: the index of navigation bar to be toggled
 function toggleNavigationBar(indexNavigationBar)
{
   var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
   var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);

   if (!NavFrame || !NavToggle) {
       return false;
   }

   // ajout par Dake - permet de créer un titre en lieu et place du "Dérouler" grâce
   // à l'attribut "title" du tag.
   var ShowText;

   if (NavFrame.title == undefined || NavFrame.title.length == 0 ) {
    ShowText = NavigationBarShow;
   } else {
    ShowText = NavFrame.title;
   }

   // if shown now
   if (NavToggle.firstChild.data == NavigationBarHide) {
       for (
               var NavChild = NavFrame.firstChild;
               NavChild != null;
               NavChild = NavChild.nextSibling
           ) {
           if (NavChild.className == 'NavPic') {
               NavChild.style.display = 'none';
           }
           if (NavChild.className == 'NavContent') {
               NavChild.style.display = 'none';
           }
           if (NavChild.className == 'NavToggle') {
               NavChild.firstChild.data = ShowText;
           }
       }

   // if hidden now
   } else if (NavToggle.firstChild.data == ShowText) {
       for (
               var NavChild = NavFrame.firstChild;
               NavChild != null;
               NavChild = NavChild.nextSibling
           ) {
           if (NavChild.className == 'NavPic') {
               NavChild.style.display = 'block';
           }
           if (NavChild.className == 'NavContent') {
               NavChild.style.display = 'block';
           }
           if (NavChild.className == 'NavToggle') {
               NavChild.firstChild.data = NavigationBarHide;
           }
       }
   }
}

// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
   var indexNavigationBar = 0;
   // iterate over all < div >-elements
   for(
           var i=0;
           NavFrame = document.getElementsByTagName("div")[i];
           i++
       ) {
       // if found a navigation bar
       if (NavFrame.className == "NavFrame") {

           indexNavigationBar++;
           var NavToggle = document.createElement("a");
           NavToggle.className = 'NavToggle';
           NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
           NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');

           var NavToggleText = document.createTextNode(NavigationBarHide);
           NavToggle.appendChild(NavToggleText);

           // add NavToggle-Button as first div-element 
           // in < div class="NavFrame" >
           NavFrame.insertBefore(
               NavToggle,
               NavFrame.firstChild
           );
           NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
       }
   }
   // if more Navigation Bars found than Default: hide all
   if (NavigationBarShowDefault < indexNavigationBar) {
       for(
               var i=1; 
               i<=indexNavigationBar; 
               i++
       ) {
           toggleNavigationBar(i);
       }
   }
}

addOnloadHook(createNavigationBarToggleButton);
 
 // END Dynamic Navigation Bars

 /** Title rewrite ********************************************************
  * Rewrites the page's title, used by [[Modèle:Titre de l'article]]
  * By [http://www.uncyclopedia.org/wiki/User:Sikon Sikon]
  */
 
 function rewriteTitle()
 {
    if(typeof(SKIP_TITLE_REWRITE) != 'undefined' && SKIP_TITLE_REWRITE)
        return;
 
    var titleDiv = document.getElementById('title-meta');
 
    if(titleDiv == null || titleDiv == undefined)
        return;
 
    var cloneNode = titleDiv.cloneNode(true);
    var firstHeading = YAHOO.util.Dom.getElementsByClassName('firstHeading', 'h1', document.getElementById('content') )[0];
    var node = firstHeading.childNodes[0];
 
    // new, then old!
    firstHeading.replaceChild(cloneNode, node);
    cloneNode.style.display = "inline";
 
    var titleAlign = document.getElementById('title-align');
    firstHeading.style.textAlign = titleAlign.childNodes[0].nodeValue;
 }
 
 addOnloadHook(rewriteTitle, false);


////////////////////  test
/*
	the ContentLoader class to encapsulate "creative differences" with XHR
	
    Usage:
        - construct a ContentLoader object: var loader = new ContentLoader();
        - set necessary state parameters (via fields); e.g. loader.myvar = 'mytext';
        - set the callback: loader.callback = myfunc;
        - send the request:
            loader.send(url, postdata = null, contentType = 'application/x-www-form-urlencoded');
            (if postdata isn't null or omitted, POST is used, otherwise GET)
        - the callback function is called when the content is loaded
            - the ContentLoader object is this
            - the raw response data is this.text
            - the XML DOM object, if any, is this.document
*/
function ContentLoader()
{
    this.cache = true;
}

ContentLoader.prototype.enableCache = function(caching)
{
    this.cache = (caching == null) ? true : this.cache;
}

ContentLoader.prototype.createRequest = function()
{
	if(typeof(XMLHttpRequest) != 'undefined')
	{
		return new XMLHttpRequest();
	}
	else if(typeof(ActiveXObject) != 'undefined')
	{
		return new ActiveXObject("Msxml2.XMLHTTP");
	}
	
	return null;
}

ContentLoader.prototype.send = function(url, postdata, contentType)
{
	var method = (postdata == null) ? 'GET' : 'POST';
	this.request = this.createRequest();
	this.request.open(method, url);

	if(!this.cache)
		this.request.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );

	var request = this.request;
	var loader = this;
	
	if(postdata == null)
	{
	    if(contentType == null)
	        contentType = 'application/x-www-form-urlencoded';
	
	    request.setRequestHeader('Content-type', contentType);
	}
	
	var f = function()
    {
    	if(request.readyState == 4)
    	{
    		loader.text = request.responseText;
    		loader.document = request.responseXML;
    		request = null;
    		loader.request = null;
    		loader.callback();
    	}
    }
	
	this.request.onreadystatechange = f;
	this.request.send(postdata);
}
/*
	end ContentLoader
*/


function fillEditSummaries()
{
    var label = document.getElementById("wpSummaryLabel");

    if(label == null)
        return;

    var comboString = "<p>Résumés prédéfinis : <select id='stdSummaries' onchange='onStdSummaryChange()'></select></p>";
    label.innerHTML = comboString + label.innerHTML;

    requestComboFill('stdSummaries', 'Modèle:Résumés prédéfinis');
}

function onStdSummaryChange()
{
    var combo = document.getElementById("stdSummaries");
    var value = combo.options[combo.selectedIndex].value;

    if(value != "")
        document.getElementById("wpSummary").value = value;
}

function requestComboFill(id, page)
{
    var loader = new ContentLoader();
    loader.comboID = id;
    loader.callback = onComboDataArrival;
    loader.send('/index.php?title=' + page + '&action=raw&ctype=text/plain');
}
function onComboDataArrival()
{
    fillCombo(this.text, this.comboID);
}

function fillCombo(text, comboid)
{
    var combo = document.getElementById(comboid);
    var lines = text.split("\n");

    for(var i = 0; i < lines.length; i++)
    {
        var value = lines[i].indexOf("-- ") == 0 ? lines[i].substring(3) : "";
        var option = document.createElement('option');
        option.setAttribute('value', value);
        option.appendChild(document.createTextNode(lines[i]));
        combo.appendChild(option);
    }
}
/*
    end combo fill code
*/


addOnloadHook(fillEditSummaries);

//// LinkSuggest improvements. Original code modified by [[w:User:Ciencia Al Poder]]

if (window.YAHOO && YAHOO.example && YAHOO.example.AutoCompleteTextArea) {
	YAHOO.example.AutoCompleteTextArea.prototype._localisations = [
		['Talk','Discuter'],
		['User','Utilisateur'],
		['User talk','Discussion Utilisateur'],
		['Project','Guild Wars Wikia'],
		['Project talk','Discussion Guild Wars Wikia'],
		['Image','Image'],
		['Image talk','Discussion Image'],
		['MediaWiki','MediaWiki'],
		['MediaWiki talk','Discussion MediaWiki'],
		['Template','Modèle'],
		['Template talk','Discussion Modèle'],
		['Help','Aide'],
		['Help talk','Discussion Aide'],
		['Category','Catégorie'],
		['Category talk','Discussion Catégorie']
	];

	YAHOO.example.AutoCompleteTextArea.prototype._localize = function(sItem, bEngToLang){
		if (!sItem || !sItem.length || !this._localisations || !this._localisations.length) return sItem;
		for (var i=0; i<this._localisations.length; i++){
			var sIn = this._localisations[i][(bEngToLang?0:1)].toString()+':';
			var sOut = this._localisations[i][(bEngToLang?1:0)].toString()+':';
			if (sItem.toLowerCase().indexOf(sIn.toLowerCase())==0){
				sItem = sOut+sItem.substr(sIn.length, sItem.length-1);
				break;
			}
		}
		return sItem;
	};

	YAHOO.example.AutoCompleteTextArea.prototype._updateValue = function(oItem) {

		this.track('success');
		this._suggestionSuccessful = true;

		this._elTextbox.focus();

		var scrollTop = this._elTextbox.scrollTop;
		var text = this._elTextbox.value.replace(/\r/g, "");
		var caret = this.getCaret(this._elTextbox);

		for(var i = caret; i >= 0; i--) {
			if(text.charAt(i - 1) == "[" || text.charAt(i - 1) == "{") {
				break;
			}
		}

		var textBefore = text.substr(0, i);
		var newVal = textBefore + ((this._bIsTemplate && this._bIsSubstTemplate) ? 'subst:' : '' ) + (this._bIsColon ? ':' : '') + oItem._oResultData[1] + (text.charAt(i - 1) == "{" ? "}}" : "]]") + text.substr(i + this._originalQuery.length);
		this._elTextbox.value = newVal;

		if(YAHOO.env.ua.ie > 0) {
			caret = caret - this.row + 1;
		}

		this.setCaret(this._elTextbox, i + (this._bIsColon ? 1 : 0) + ((this._bIsTemplate && this._bIsSubstTemplate) ? 6 : 0 ) + oItem._oResultData[1].length + 2);
		this._oCurItem = oItem;
		this._elTextbox.scrollTop = scrollTop;
	};

	YAHOO.example.AutoCompleteTextArea.prototype._sendQuery = function(sQuery) {
		var text = this._elTextbox.value.replace(/\r/g, "");
		var caret = this.getCaret(this._elTextbox);
		var sQueryStartAt;

		// also look forward, to see if we closed this one
		for(var i = caret; i < text.length; i++) {
			var c = text.charAt (i) ;
			if((c == "[") && (text.charAt(i - 1) == "[")) {
				break ;			
			}
			if((c == "{") && (text.charAt(i - 1) == "{")) {
				break ;			
			}
			if((c == "]") && (text.charAt(i - 1) == "]")) {
				return ;			
			}
			if((c == "}") && (text.charAt(i - 1) == "}")) {
				return ;			
			}
		}
		
		for(var i = caret; i >= 0; i--) {
			var c = text.charAt(i);
			if(c == "]" || c == "|") {
				if ( (c == "|") || ( (c == "]") && (text.charAt(i-1) == "]") ) ) {
					this._toggleContainer(false) ;
				}
				return;
			}
			if(c == "}" || c == "|") {
				if ( (c == "|") || ( (c == "}") && (text.charAt(i-1) == "}") ) ) {
					this._toggleContainer(false) ;
				}
				return;
			}
			if((c == "[") && (text.charAt(i - 1) == "[")) {
				this._originalQuery = text.substr(i + 1, (caret - i - 1));
				sQueryReal = this._originalQuery
				if (this._originalQuery.indexOf(':')==0){
					this._bIsColon = true;
					sQueryReal = sQueryReal.replace(':','');
				} else {
					this._bIsColon = false;
				}
				sQueryReal = this._localize(sQueryReal, false);
				this._bIsTemplate = false;
				sQueryStartAt = i;
				break;
			}
			if((c == "{") && (text.charAt(i - 1) == "{")) {
				this._originalQuery = text.substr(i + 1, (caret - i - 1));
				this._bIsColon = false;
				if (this._originalQuery.length >= 6 && this._originalQuery.toLowerCase().indexOf('subst:') == 0){
					sQueryReal = "Template:"+this._originalQuery.replace(/subst:/i,'');
					this._bIsSubstTemplate = true;
				} else if (this._originalQuery.indexOf(':')==0){
					sQueryReal = this._localize(this._originalQuery.replace(':',''), false);
					this._bIsColon = true;
				} else {
					sQueryReal = "Template:"+this._originalQuery;
					this._bIsSubstTemplate = false;
				}
				this._bIsTemplate = true;
				sQueryStartAt = i;
				break;
			}
		}

		if(sQueryStartAt >= 0 && sQueryReal.length > 2) {
			YAHOO.example.AutoCompleteTextArea.superclass._sendQuery.call(this, encodeURI(sQueryReal).replace(/%[0-9A-F]{2}/g,'_'));
		}
	};

	YAHOO.example.AutoCompleteTextArea.prototype.doBeforeExpandContainer = function(elTextbox, elContainer, sQuery, aResults) {
		for (var i=0, aList=elContainer.getElementsByTagName('li'); i<aList.length; i++){
			if (aList[i]._sResultKey){
				if (this._bIsTemplate){
					aList[i].innerHTML = aList[i].innerHTML.replace('Template:','');
					aList[i]._sResultKey = aList[i]._sResultKey.replace('Template:','');
					for (var j=0; j<aList[i]._oResultData.length; j++){
						aList[i]._oResultData[j] = aList[i]._oResultData[j].replace('Template:','');
					}
				} else {
					aList[i].innerHTML = this._localize(aList[i].innerHTML, true);
					aList[i]._sResultKey = this._localize(aList[i]._sResultKey, true);
					for (var j=0; j<aList[i]._oResultData.length; j++){
						aList[i]._oResultData[j] = this._localize(aList[i]._oResultData[j], true);
					}
				}
			}
		}

		var position = this.getCaretPosition(elTextbox);
		elContainer.style.left = position[0] + 'px'
		elContainer.style.top = position[1] + 'px'

		/* #3378  */
		var maxLen = 20;

		for (var n=0; n<aResults.length; n++) {
			var len = aResults[n][0].length;
			if (maxLen < len) maxLen = len;
		}

		elContainer.style.width = Math.round((maxLen*7.5) < 400 ? maxLen*7.5 : 400) +'px';

		if (!this.isContainerOpen()) {
			this.track('open');
			this._suggestionSuccessful = false;
		}

		return true;
	};
}

function LienWikiOfficiel() {
  var h1 = $('h1.firstHeading');
  var lien = $('#wiki_officiel');

  if(lien == null)
        return;

    lien.style.display = "block"; /* annule display:none par défaut */
    lien.style.borderWidth = "1px";
    lien.style.borderStyle = "solid";
    lien.style.borderColor = "white";
    
    h1.innerHTML = lien.HTML + h1.innerHTML; /* déplacement de l'élément */
  
}

$(document).ready(function() {

LienWikiOfficiel()

if (wgPageName != 'Spécial:Téléchargement') {
 return;
}

$('#wpUploadDescription').append(document.createTextNode("{{Fichier\r\n|description=\r\n|source=\r\n|auteur=\r\n|licence=\r\n|autres versions=\r\n|catégorie=\r\n}}"));

});







//</pre>

/* MediaWiki:Monaco.js */


/*
function fillEditSummaries()
{
    var label = document.getElementById("edit_enhancements_toolbar");

    if(label == null)
        return;

    var comboString = "<p>Résumés prédéfinis : <select id='stdSummaries' onchange='onStdSummaryChange()'></select></p>";
    label.innerHTML = comboString + label.innerHTML;

    requestComboFill('stdSummaries', 'Modèle:Résumés prédéfinis');
}
*/