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

/* MediaWiki:Common.js */
 // **************************************************
 // Experimental javascript countdown timer (Splarka)
 // Version 0.0.2
 // **************************************************
 // Embed with a span class="countdowntimer", eg:
 // <span class="countdowntimer" style="display:none;">April 12 2008 00:00:01 AM EST</span>
 // default replacement text can accompany, eg: <span class="notimer">*javascript required*</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;
   }
 
   // catch negative dates
   if(diff<0) {
     diff = -diff;
     var left = ' ago since';
   } else {
     var left = ' until';
   }
 
   // calcuate the diff
   left = (diff%60) + ' seconds ' + left;
     diff=Math.floor(diff/60);
   if(diff > 0) left = (diff%60) + ' minutes ' + left;
     diff=Math.floor(diff/60);
   if(diff > 0) left = (diff%24) + ' hours ' + left;
     diff=Math.floor(diff/24);
   if(diff > 0) left = diff + ' days ' + left
   timers[i].firstChild.nodeValue = left;
 
   // a setInterval() is more efficient, but calling setTimeout()
   // makes errors break the script rather than infinitely recurse
   tim[i] = setTimeout('updatetimer(' + i + ')',1000);
 }
 
 function checktimers() {
   var untimers = getElementsByClassName(document, 'span', 'notimer');
   for(var i=0;i < untimers.length; i++) {
     untimers[i].style.display = 'none';    
   }
   timers = getElementsByClassName(document, 'span', 'countdowntimer');  //global
   tim = new Array(); // generic holder for the timeouts, global
   if(timers.length == 0) return;
   for(var i=0;i < timers.length; i++) {
     timers[i].eventdate = new Date(timers[i].firstChild.nodeValue);
     timers[i].firstChild.nodeValue = '0 days 0 hours 0 minutes 0 seconds';
     timers[i].style.display = 'inline';
     updatetimer(i);  //start it up
   }
 }
 addOnloadHook(checktimers)
 
 // **************************************************
 //  - end -  Experimental javascript countdown timer
 // **************************************************

 /** Deletion reasons *****************************************************
  * Adds drop down box to delete page for choosing pre-made deletion reasons called
  * from [[Template:Stdreasons]] 
  * By [[User:Sikon|Sikon]]
  */
 var xhrReasons;
 
 addOnloadHook(fillDeleteReasons, false);
 
 function fillDeleteReasons()
 {
    var label = document.getElementById("wpReason");
 
    if(label == null)
    {
        return;
    }
 
    label = document.getElementById("contentSub");
 
    if(label == null)
    {
        return;
    }
 
    if (window.location.href.indexOf("action=delete") == -1)
    {
        return;
    }
 
    if(typeof(disableDeletionReasons) != 'undefined' && disableDeletionReasons)
    {
         return;
    }
 
    var comboString = "<br /><select id='stdReasons' onchange='onStdReasonChange()'>";
    comboString += "</select>";
    label.innerHTML += comboString;
 
    var request = getRequest();
    xhrReasons = request;
    request.open("GET", "http://illogicopedia.wikia.com/index.php?title=Template:Stdreasons&action=raw&ctype=text/plain");
    request.onreadystatechange = onRSCReasons;
    request.send(null);
 }
 
 function onStdReasonChange()
 {
    var combo = document.getElementById("stdReasons");
    var value = combo.options[combo.selectedIndex].value;
 
    if(value != "")
        document.getElementById("wpReason").value = value;
 }
 
 function getRequest()
 {
    var agt = navigator.userAgent.toLowerCase();
 
    if (agt.indexOf('msie')!=-1 && agt.indexOf('msie 7')==-1 && document.all && agt.indexOf('opera')==-1 && agt.indexOf('mac')==-1)
        return new ActiveXObject("Msxml2.XMLHTTP");
 
   var request = new XMLHttpRequest();
   return request;
 }
 
 function onRSCReasons()
 {
     fillCombo(xhrReasons, 'stdReasons');
 }
 
 function fillCombo(request, comboid)
    {
        if(request.readyState == 4)
        {
            var combo = document.getElementById(comboid);
            var lines = request.responseText.split("\n");
 
            for(var i = 0; i < lines.length; i++)
            {
                var value = lines[i].indexOf("-- ") == 0 ? lines[i].substring(3) : "";
                //combo.innerHTML += "<option value='" + value + "'>" + lines[i] + "</option>";
                var option = document.createElement('option');
                option.setAttribute('value', value);
                option.appendChild(document.createTextNode(lines[i]));
                combo.appendChild(option);
            }
        }
    }

 /** Title rewrite ********************************************************
  * Rewrites the page's title, used by [[Template:Title]]
  * By [[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 = getElementsByClass('firstHeading', document.getElementById('content'), 'h1')[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);

 /** Username replace function ([[template:USERNAME]]) *******************************
  * Inserts user name into <span id="insertusername"></span>
  * By [[wikia:User:Splarka|Splarka]]
  */
 addOnloadHook(UserNameReplace);
 
 function UserNameReplace() {
 if(typeof(disableUsernameReplace) != 'undefined' && disableUsernameReplace) return;
    for(var i=0; UserName = document.getElementsByTagName("span")[i]; i++) {
        if ((document.getElementById('pt-userpage'))&&(UserName.getAttribute('id') == "insertusername")) {
            UserName.innerHTML = wgUserName;
        }
    }
 }

 function noLogo() {
    if (document.getElementById('nologo')) document.getElementById('p-logo').style.display = 'none';
 }

/* MediaWiki:Monaco.js */
