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

/* MediaWiki:Common.js */
// '''Useful places:'''<br />
// [[MediaWiki:Common.css]]<br />
// [[MediaWiki:Common.js]]<br />
// [[MediaWiki:Monobook.css]]<br />
// [[MediaWiki:Monobook.js]]
// <pre style="overflow:scroll"><nowiki>

// [[Main Page]] JS transform. Originally from [[Wikipedia:MediaWiki:Monobook.js]]/[[Wikipedia:MediaWiki:Common.js]] and may be further modified for local use.
 function mainPageRenameNamespaceTab() {
     try {
         var Node = document.getElementById( 'ca-nstab-main' ).firstChild;
         if ( Node.textContent ) {      // Per DOM Level 3
             Node.textContent = 'Main Page';
         } else if ( Node.innerText ) { // IE doesn't handle .textContent
             Node.innerText = 'Main Page';
         } else {                       // Fallback
             Node.replaceChild( Node.firstChild, document.createTextNode( 'Main Page' ) ); 
         }
     } catch(e) {
         // bailing out!
     }
 }

 if ( wgTitle == 'Main Page' && ( wgNamespaceNumber == 0 || wgNamespaceNumber == 1 ) ) {
        addOnloadHook( mainPageRenameNamespaceTab );
 }

 function blRenameNamespaceTab() {
     try {
         var Node = document.getElementById( 'ca-nstab-project' ).firstChild;
         if ( Node.textContent ) {      // Per DOM Level 3
             Node.textContent = 'Special';
         } else if ( Node.innerText ) { // IE doesn't handle .textContent
             Node.innerText = 'Special';
         } else {                       // Fallback
             Node.replaceChild( Node.firstChild, document.createTextNode( 'Special' ) ); 
         }
     } catch(e) {
         // bailing out!
     }
 }

 if ( wgPageName == 'Inheriwiki:Title_Blacklist' && ( wgNamespaceNumber == 4 || wgNamespaceNumber == 5 ) ) {
        addOnloadHook( blRenameNamespaceTab );
 }

// Set Search link to [[Special:Search]]. Retrieved from [[w:c:starwars:MediaWiki:Monobook.js]] and Splarka and further modified for local use.
function searchLink() {
if ((document.getElementById('searchform'))&&(document.getElementById('searchform').getElementsByTagName('a').length != 0)) {
document.getElementById('searchform').getElementsByTagName('a')[0].href = wgArticlePath.replace(/\$1/,'Special:Search');
       }
}
addOnloadHook(searchLink);

// Edit counter ([[User:GHe/editcount.js]]) from [[Wikipedia:User:Interiot/Tool2/code.js]] and further modified for local use.
if (document.title.indexOf('User:GHe/editcount.js') != -1) {
  document.write('<script type="text/javascript" src="' 
    + 'http://inheritance.wikia.com/index.php?title=User:GHe/editcount.js' 
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); }

// BEGIN Dynamic Navigation Bars (experimantal)
// This script is from [[Wikipedia:MediaWiki:Monobook.js]]/[[Wikipedia:MediaWiki:Common.js]].
 
// set up the words in your language
var NavigationBarHide = '[hide]';
var NavigationBarShow = '[show]';
 
// set up max count of Navigation Bars on page,
// if there are more, all will be hidden
// NavigationBarShowDefault = 0; // all bars will be hidden
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
var NavigationBarShowDefault = 1;
 
 
// 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;
    }
 
    // 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';
            }
        }
    NavToggle.firstChild.data = NavigationBarShow;
 
    // if hidden now
    } else if (NavToggle.firstChild.data == NavigationBarShow) {
        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';
            }
        }
    NavToggle.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);
            // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
            for(
              var j=0; 
              j < NavFrame.childNodes.length; 
              j++
            ) {
              if (NavFrame.childNodes[j].className == "NavHead") {
                NavFrame.childNodes[j].appendChild(NavToggle);
              }
            }
            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);
        }
    }
 
}
 
addLoadEvent(createNavigationBarToggleButton);
 
// END Dynamic Navigation Bars
// ============================================================
 
function addLoadEvent(func) 
{
  if (window.addEventListener) 
    window.addEventListener("load", func, false);
  else if (window.attachEvent) 
    window.attachEvent("onload", func);
}

// Inserts user name into <span id="insertusername"></span> (from [[Uncyclopedia:MediaWiki:Uncyclopedia.js]])

 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;
        }
    }
 }

// *****************************************************************
// Ciencia Al Poder's patch against 
// toolbar duplication on 1.12a wikis
// *****************************************************************
// Deshabilitamos toolbar de wikibits. Está repetido
//if(window.mwSetupToolbar){
//  if(window.removeEventListener) window.removeEventListener('load',mwSetupToolbar,false);
//  else if(window.detachEvent) window.detachEvent('onload',mwSetupToolbar);
//}
// En caso de que el duplicado esté solucionado, no habrá toolbar. Si es así, lo restauramos.
//function setuptoolbardelayed(){
//  var toolbar = document.getElementById('toolbar');
//  if (toolbar.getElementsByTagName('img').length < 5 && window.mwSetupToolbar) mwSetupToolbar();
//}
//addOnloadHook(function(){
//  var toolbar = document.getElementById('toolbar');
//  if (toolbar) window.setTimeout(setuptoolbardelayed,2000);
//});
// Deshabilitamos Miniupload. Falla.
//addOnloadHook(function(){
//  window.mwWikiaUploadButton = function(){};
//});

// Custom JS toolbar buttons

 if (mwCustomEditButtons) {
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://images.wikia.com/inheritance/images/c/c8/Button_redirect.png",
     "speedTip": "Redirect",
     "tagOpen": "#REDIRECT [[",
     "tagClose": "]]",
     "sampleText": "Insert text"};
 }

// </nowiki></pre>


// '''Individual JS reskinner:'''

// <pre style="overflow:scroll"><nowiki>

if(wgPageName=='User:GHe/Logout') {
function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

function Delete_Cookie( name, path, domain ) {
if ( Get_Cookie( name ) ) document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

Delete_Cookie('wikicitiesToken', '/', '.wikia.com');
Delete_Cookie('wikicities_session', '/', '.wikia.com');
alert('You are now logged out.\n\nYou can continue to use Inheriwiki anonymously, or you can log in again as the same or as a different user. Note that some pages may continue to be displayed as if you were still logged in, until you clear your browser cache.');
history.back();
}

if(wgPageName=='Main_page' || wgPageName=='Bad_title' || wgPageName=='Index.php' || wgPageName=='%s' || wgPageName=='User:MediaWiki_default' || wgPageName=='User_talk:MediaWiki_default') {
window.location='http://inheritance.wikia.com';
}

if(wgPageName=='User:GHe') {
window.location='http://inheritance.wikia.com/wiki/User:GHe';
}

//if(wgCanonicalNamespace=='Forum_talk') {
//window.location='http://inheritance.wikia.com/wiki/Forum:' + wgTitle;
//}

// </nowiki></pre>

/* MediaWiki:Monaco.js */
