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

/* MediaWiki:Common.js */
/* 
Tools: [http://memory-alpha.org/en/index.php?title=-&action=raw&smaxage=0&gen=js reload cache]
<pre><nowiki>
*/
/* tooltips and access keys */
ta = new Object();
ta['pt-userpage'] = new Array('.','La mia pagina utente'); 
ta['pt-anonuserpage'] = new Array('.','The user page for the ip you\'re editing as'); 
ta['pt-mytalk'] = new Array('n','La mia pagina discussioni'); 
ta['pt-anontalk'] = new Array('n','Discussion about edits from this ip address'); 
ta['pt-preferences'] = new Array('','Le mie preferenze'); 
ta['pt-watchlist'] = new Array('l','List of pages I\'m monitoring for changes'); 
ta['pt-mycontris'] = new Array('y','Lista dei miei contributi'); 
ta['pt-login'] = new Array('o','Sei caldamente invitato ad effettuare il log in; tuttavia non è indispensabile'); 
ta['pt-anonlogin'] = new Array('o','Sei caldamente invitato ad effettuare il log in; tuttavia non è indispensabile'); 
ta['pt-logout'] = new Array('o','Log out'); 
ta['ca-talk'] = new Array('t','Discussioni sul contenuto della pagina'); 
ta['ca-edit'] = new Array('e','Tu puoi modificare questa pagina; usa sempre il pulsante anteprima prima di salvare'); 
ta['ca-addsection'] = new Array('+','Aggiungi un commento a questa discussione'); 
ta['ca-viewsource'] = new Array('e','Questa pagina è protetta; puoi solo visualizzare il sorgente'); 
ta['ca-history'] = new Array('h','Precedenti versioni di questa pagina'); 
ta['ca-protect'] = new Array('=','Proteggi questa pagina'); 
ta['ca-delete'] = new Array('d','Delete this page'); 
ta['ca-undelete'] = new Array('d','Restore the edits done to this page before it was deleted'); 
ta['ca-move'] = new Array('m','Move this page'); 
ta['ca-nomove'] = new Array('','You don\'t have the permissions to move this page'); 
ta['ca-watch'] = new Array('w','Aggiungi questa pagina ai tuoi osservati speciali'); 
ta['ca-unwatch'] = new Array('w','Rimuovi questa pagina dai tuoi osservati speciali'); 
ta['search'] = new Array('','Cerca in Memory Alpha'); 
ta['p-logo'] = new Array('z','Pagina principale'); 
ta['n-mainpage'] = new Array('z','Visita la pagina principale'); 
ta['n-Main-page'] = new Array('z','Visita la pagina principale'); 
ta['n-portal'] = new Array('','About the project, what you can do, where to find things'); 
ta['n-Chat'] = new Array('','IRC, the place to chat');
ta['n-currentevents'] = new Array('','Find background information on current events'); 
ta['n-recentchanges'] = new Array('r','The list of recent changes in the wiki'); 
ta['n-randompage'] = new Array('x','Load a random page'); 
ta['n-help'] = new Array('/','The place to find out information'); 
ta['n-sitesupport'] = new Array('','Support us'); 
ta['t-whatlinkshere'] = new Array('j','List of all wiki pages that link here'); 
ta['t-recentchangeslinked'] = new Array('k','Recent changes in pages linking to this page'); 
ta['feed-rss'] = new Array('','RSS feed for this page'); 
ta['feed-atom'] = new Array('','Atom feed for this page'); 
ta['t-contributions'] = new Array('','View the list of contributions of this user'); 
ta['t-emailuser'] = new Array('','Send a mail to this user'); 
ta['t-upload'] = new Array('u','Upload images or media files'); 
ta['t-specialpages'] = new Array('q','List of all special pages'); 
ta['ca-nstab-main'] = new Array('c','View the content page'); 
ta['ca-nstab-user'] = new Array('c','View the user page'); 
ta['ca-nstab-media'] = new Array('c','View the media page'); 
ta['ca-nstab-special'] = new Array('','This is a special page; you can\'t edit the page itself.'); 
ta['ca-nstab-wp'] = new Array('c','View the project page'); 
ta['ca-nstab-image'] = new Array('c','View the image page'); 
ta['ca-nstab-mediawiki'] = new Array('c','View the system message'); 
ta['ca-nstab-template'] = new Array('c','View the template'); 
ta['ca-nstab-help'] = new Array('c','View the help page'); 
ta['ca-nstab-category'] = new Array('c','View the category page');


/* Umieszczony tutaj kod JavaScript zostanie załadowany przez każdego użytkownika, podczas każdego ładowania strony. */
// **************************************************
// Experimental javascript countdown timer (Splarka)
// Version 0.0.3
// **************************************************
//
// Usage example:
//  <span class="countdown" style="display:none;">
//  Only <span class="countdowndate">January 01 2007 00:00:00 </span> until New years.
//  </span>
//  <span class="nocountdown">Javascript disabled.</span>

function updatetimer(i) {
  var now = new Date();
  var then = timers[i].eventdate;
  var diff = count=Math.floor((then.getTime()-now.getTime())/1000);

  // catch bad date strings
  if(isNaN(diff)) { 
    timers[i].firstChild.nodeValue = '** ' + timers[i].eventdate + ' **' ;
    return;
  }

  // determine plus/minus
  if(diff<0) {
    diff = -diff;
    var tpm = 'sono passati ';
  } else {
    var tpm = 'mancano ancora ';
  }

  // calcuate the diff
  var left = (diff%60) + ' s';
    diff=Math.floor(diff/60);
  if(diff > 0) left = (diff%60) + ' m ' + left;
    diff=Math.floor(diff/60);
  if(diff > 0) left = (diff%24) + ' h ' + left;
    diff=Math.floor(diff/24);
  if(diff > 0) left = diff + ' d ' + left
  timers[i].firstChild.nodeValue = tpm + left;

  // a setInterval() is more efficient, but calling setTimeout()
  // makes errors break the script rather than infinitely recurse
  timeouts[i] = setTimeout('updatetimer(' + i + ')',1000);
}

function checktimers() {
  //hide 'nocountdown' and show 'countdown'
  var nocountdowns = getElementsByClassName(document, 'span', 'nocountdown');
  for(var i in nocountdowns) nocountdowns[i].style.display = 'none'
  var countdowns = getElementsByClassName(document, 'span', 'countdown');
  for(var i in countdowns) countdowns[i].style.display = 'inline'

  //set up global objects timers and timeouts.
  timers = getElementsByClassName(document, 'span', 'countdowndate');  //global
  timeouts = new Array(); // generic holder for the timeouts, global
  if(timers.length == 0) return;
  for(var i in timers) {
    timers[i].eventdate = new Date(timers[i].firstChild.nodeValue);
    updatetimer(i);  //start it up
  }
}
addOnloadHook(checktimers);

// **************************************************
//  - end -  Experimental javascript countdown timer
// **************************************************


//********************************************************************************
// Start "Hidden appearances section/interactive tree" script; by [[User:Bp]]
//********************************************************************************
function toggleAppearancesPane(eid) {
	e = document.getElementById(eid);
	if (e) { e.className = (e.className == "hiddenlist") ? "visiblelist" : "hiddenlist"; }
}

function showAppearancesPane(eid) {
	e = document.getElementById(eid);
	if (e) { e.className = "visiblelist"; }
}

function hideAppearancesPane(eid) {
	e = document.getElementById(eid);
	if (e) { e.className = "hiddenlist"; }
}
// -----

var tree = 0;
var pane = 0;
var paneListForThisTree = new Array();
var descriptionString = new String("Questa lista contiene %d elementi."); //%d is where the number of items is inserted

var smallTreeCount = 8; // less leaves than this, the tree will be open at first
var interactiveTrees = 1; // set this to 0 in user.js to turn this off

function button(text,onclick,cls) {
	var b = document.createElement('a');
	b.innerHTML = text;
	b.href="javascript:"+onclick;
	b.className = cls;
	return b;
}

function recursiveCountAndMark(e, depth, nocount) {
	var si = e.firstChild;
	var total = 0;
	while(si) {
		var tn = (si.tagName) ? si.tagName.toLowerCase() : '';
		if (tn == "li") { total++; }
		var subtotal = recursiveCountAndMark(si, depth+1, nocount);
		if (tn == "ul" || tn == "ol") {
			if (depth > 1) {
				si.id = "Pane" + pane++;
				paneListForThisTree.push(si.id);
				si.className = "hiddenlist";

				si.parentNode.insertBefore(document.createTextNode('('), si);
				si.parentNode.insertBefore(button( (nocount) ? "+/-" : subtotal, "toggleAppearancesPane(\""+si.id+"\")", "listexpand"), si);
				si.parentNode.insertBefore(document.createTextNode(')'), si);
				total--; // don't count the li that this ul/ol is in
			} else {
				// we are finished and this is the top ul/ol
				if (subtotal < smallTreeCount) { // this small enough they can be visible right away
					for (var i=0;i<paneListForThisTree.length;i++) {
						toggleAppearancesPane(paneListForThisTree[i]);
					}
				}
				var allonexec = '{';
				var alloffexec = '{';
				for (var i=0;i<paneListForThisTree.length;i++) {
					allonexec += "showAppearancesPane(\""+paneListForThisTree[i]+"\"); ";
					alloffexec += "hideAppearancesPane(\""+paneListForThisTree[i]+"\"); ";
				}
				allonexec += '}'; alloffexec += '}';

			        var ds = (nocount) ? "" : descriptionString.replace(/\%d/g, subtotal);
				si.parentNode.insertBefore(document.createTextNode(ds + ' ('), si);
				si.parentNode.insertBefore(button("mostra", allonexec, "listexpand"), si);
				si.parentNode.insertBefore(document.createTextNode(' • '), si);
				si.parentNode.insertBefore(button("nascondi", alloffexec, "listexpand"), si);
				si.parentNode.insertBefore(document.createTextNode(')'), si);
			}
		}
		total += subtotal;
		si = si.nextSibling;
	}
	return total;
}

function doAppearancesTrees() {
	if (!interactiveTrees) { return; }

	var divs = document.getElementsByTagName("div");
	for (var i = 0; i < divs.length; i++) {
		if (divs[i].className.match(/\bappear\b/)) {
			recursiveCountAndMark(divs[i], 0, (divs[i].className.match(/\bnocount\b/)) ? 1 : 0);
			paneListForThisTree = new Array();
			tree++;
		}
	}

	// fix a bug noticed by renegade54
	// jump to the named anchor again
	if (window.location.hash && tree > 0) {
		// still won't work 100% in safari and khtml
		if (navigator.userAgent.indexOf("MSIE") != -1) {
			window.location = window.location.hash; // -- causes Firefox to fire onload events
		} else {
			window.location.hash = window.location.hash;
		}
	}

}

hookEvent("load", doAppearancesTrees);
// End "Hidden Appearances section" script

//********************************************************************************
// Start "Interactive quotes" script; by [[User:Bp]]
//********************************************************************************
function speakerLabel(text) {
	var spkr = document.createElement('span');
	spkr.innerHTML = text + ": ";
	spkr.className = "speaker-label";
	return spkr;
}

function explicitQuoteOn(event, e) {
	var si = (e) ? e.firstChild : this.firstChild;
	while(si) {
		explicitQuoteOn(event, si);
		if (si.className == "dialogue-inside") {
			si.className = "dialogue-inside-highlight";
		} else if (si.className == "quoteline") {
			if (si.childNodes[0].className != "speaker-label") {
				if (si.title != '') {
					si.insertBefore(speakerLabel(si.title), si.childNodes[0]);
					si.title = '';
				}
			}
			if (si.childNodes[0].className == "speaker-label") {
				si.childNodes[0].style.display = "inline";
			}
		}
		si = si = si.nextSibling;
	}
}

function explicitQuoteOff(event, e) {
	var si = (e) ? e.firstChild : this.firstChild;
	while(si) {
		explicitQuoteOff(event, si);
		if (si.className == "dialogue-inside-highlight") {
			si.className = "dialogue-inside";
		} else if (si.className == "quoteline") {
			if (si.childNodes[0].className == "speaker-label") {
				si.childNodes[0].style.display = "none";
			}
		}
		si = si = si.nextSibling;
	}
}

var explicitQuotes = 0;

function doQuotes() {
	if (!explicitQuotes) { return; }

	var dumbevent;
	var divs = document.getElementsByTagName("div");
	for (var i = 0; i < divs.length; i++) {
		if (divs[i].className == 'dialogue') {
			if (explicitQuotes == 1) {
				divs[i].onmouseover = explicitQuoteOn;
				divs[i].onmouseout = explicitQuoteOff;
			} else {
				explicitQuoteOn(dumbevent, divs[i]);
			}
		}
	}
}

hookEvent("load", doQuotes);
// End "Interactive quotes" script

//********************************************************************************
// Start "Articletype positioning" script; by [[User:Bp]]
//********************************************************************************
function moveArticletypeDiv() {
  var fooel = document.getElementById('ma-article-type');
  var artel = document.getElementById('article');
  var titel = document.getElementById('top');
  fooel = fooel.parentNode.removeChild(fooel);
  if (artel!=null) {
    artel.parentNode.insertBefore(fooel,artel);
  } else {
    //fall back to a position before H1 - useful for monobook skin
    titel.parentNode.insertBefore(fooel,titel);
  }
}

hookEvent("load", moveArticletypeDiv);
// End "Articletype positioning" script


///////////////////////////////////////////////////////////////////////////////////////////////////////////

// ADVANCED AUTO REFRESHING RECENT CHANGES AND WATCHLIST
// Code courtesy of "pcj" of WoWWiki.

// INDIVIDUAL USE
// This is a modified version of the WoWWiki site-wide version.
// This version is designed for Special:Mypage/global.js use.

// WIKI-WIDE USE
// If you add it to a wiki's MediaWiki:Common.js it *should* work - however, this is untested.
// It should not conflict with your own global.js.

// WHAT IT DOES
// The code adds a checkbox at the top of Special:RecentChanges and Special:Watchlist, next to the header.
// Ticking this sets a cookie (specific to each wiki) and starts updating the list.
// This occurs silently every 60 seconds without a full page reload occurring.

///////////////////////////////////////////////////////////////////////////////////////////////////////////


ajaxPages="Special:RecentChanges,Special:Watchlist,";

function setCookie(c_name,value,expiredays) {
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

function getCookie(c_name) {
if (document.cookie.length>0) {
c_start=document.cookie.indexOf(c_name + "=")
if (c_start!=-1) { 
c_start=c_start + c_name.length+1 
c_end=document.cookie.indexOf(";",c_start)
if (c_end==-1) c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end))
} 
}
return ""
}

function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest(); //Not Internet Explorer
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP"); //Internet Explorer
} else {
//fail silently
}
}
getRCDataRO = getXmlHttpRequestObject();
var cr = new RegExp("\r", "gm");
var lf = new RegExp("\n", "gm");
var endText = new RegExp('</div>[\t\s]*?<!-- end content -->[\t\s]*?<div class="visualClear">', "mi");
var rcTimer;
var rcRefresh = 60000;
function preloadAJAXRC() {
if (skin == "monaco") {
s = 1;
} else {
s = 0;
}
ajaxRCCookie = (getCookie("ajaxload-"+wgPageName)=="on") ? true:false;
document.getElementsByTagName("h1")[0].innerHTML += '&nbsp;<span style="font-size: xx-small; border-bottom: 1px dotted; cursor:help;" title="Enable auto-refreshing page loads">AJAX:</span><input type="checkbox" id="ajaxRCtoggle" onClick="toggleRC();">';
document.getElementById("ajaxRCtoggle").checked = ajaxRCCookie;
if (getCookie("ajaxload-"+wgPageName)=="on") loadRCData();
}

function toggleRC() {
if (document.getElementById("ajaxRCtoggle").checked == true) {
setCookie("ajaxload-"+wgPageName, "on", 30);
loadRCData();
} else {
setCookie("ajaxload-"+wgPageName, "off", 30);
clearTimeout(rcTimer);
}
}

function loadRCData() {
if (getRCDataRO.readyState == 4 || getRCDataRO.readyState == 0) {
if (location.href.indexOf("/wiki/")) {
rcURL = "http://" + location.hostname + "/wiki/" + wgPageName + location.search;
} else {
rcURL = "http://" + location.hostname + "/" + wgPageName + location.search;
}
getRCDataRO.open("GET", rcURL, true);
getRCDataRO.onreadystatechange = parseRCdata;
getRCDataRO.send(null);
}
}

function parseRCdata() {
if (getRCDataRO.readyState == 4) {
textFilter = new RegExp('<div id="bodyContent">.*?</div>[\t\s]*?<!-- end content -->[\t\s]*?<div class="visualClear">', "i");
rawRCdata = getRCDataRO.responseText.replace(cr, "").replace(lf, "");
filteredRCdata = textFilter.exec(rawRCdata);
updatedText = filteredRCdata[0].replace('<div id="bodyContent">', "").replace(endText, "");
document.getElementById("bodyContent").innerHTML = updatedText;
rcTimer = setTimeout("loadRCData();", rcRefresh);
}
}

if (ajaxPages.indexOf(wgPageName)!=-1) addOnloadHook(preloadAJAXRC);

///////////////////////////////////////////////////////////////////////////////////////////////////////////

// END OF CODE

///////////////////////////////////////////////////////////////////////////////////////////////////////////

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

/* MediaWiki:Monaco.js */
