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

/* MediaWiki:Common.js */
// Tools: [http://uncyclopedia.org/index.php?title=-&action=raw&smaxage=0&gen=js reload cache]

 /* tooltips and access keys */
 ta = new Object();
 ta['pt-userpage'] = new Array('.','My user page');
 ta['pt-anonuserpage'] = new Array('.','The user page for the ip you\'re editing as');
 ta['pt-mytalk'] = new Array('n','My talk page');
 ta['pt-anontalk'] = new Array('n','Discussion about edits from this ip address');
 ta['pt-preferences'] = new Array('','My preferences');
 ta['pt-watchlist'] = new Array('l','The list of pages you\'re monitoring for changes.');
 ta['pt-mycontris'] = new Array('y','List of my contributions');
 ta['pt-login'] = new Array('o','You are encouraged to log in, it is not mandatory however.');
 ta['pt-anonlogin'] = new Array('o','You are encouraged to log in, it is not mandatory however.');
 ta['pt-logout'] = new Array('o','Log out');
 ta['ca-talk'] = new Array('t','Discussion about the content page');
 ta['ca-edit'] = new Array('e','You can edit this page. Please use the preview button before  saving.');
 ta['ca-addsection'] = new Array('+','Add a comment to this discussion.');
 ta['ca-viewsource'] = new Array('e','This page is protected. You can view its source.');
 ta['ca-history'] = new Array('h','Past versions of this page.');
 ta['ca-protect'] = new Array('=','Protect this page');
 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','Add this page to your watchlist');
 ta['ca-unwatch'] = new Array('w','Remove this page from your watchlist');
 ta['search'] = new Array('f','Search this wiki');
 ta['p-logo'] = new Array('','Main Page');
 ta['n-mainpage'] = new Array('z','Visit the Main Page');
 ta['n-portal'] = new Array('','About the project, what you can do, where to find things');
 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.');
 ta['n-irc'] = new Array('i','Live help, advice, and complaints');
 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 linked from 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('a','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');
 ta['ca-nstab-wilde'] = new Array('c','View the made up quote');
 ta['ca-nstab-unnews'] = new Array('c','View the fake news page');
 ta['ca-nstab-undictionary'] = new Array('c','View the crappy page');
 ta['ca-nstab-game'] = new Array('c','View the fun page');
 ta['ca-nstab-babel'] = new Array('c','View the confusing page');
 ta['ca-nstab-forum'] = new Array('c','View the other discussion page');
 ta['n-Babel'] = new Array('','Qua?');
 ta['n-Things-to-do'] = new Array('','Prevents you from touching yourself');
 ta['n-pump'] = new Array('','Join the CABAL (if there is one (which there isn\'t))');
 ta['listfrom'] = new Array('','Show the changes since you loaded this page');
 ta['n-Pee-Review'] = new Array('','Free urine sample evaluations');
 ta['n-Featured-content'] = new Array('','The very best of Uncyclopedia');

 /** Import module *************************************************************
  *
  *  Description: Includes a raw wiki page as javascript or CSS, 
  *               used for including user made modules.
  *  Maintainers: [[wikipedia:User:AzaToth]]
  */
 importedScripts = {}; // object keeping track of included scripts, so a script ain't included twice
 function importScript( page ) {
     if( importedScripts[page] ) {
         return;
     }
     importedScripts[page] = true;
     var url = wgScriptPath
             + '/index.php?title='
             + encodeURIComponent( page.replace( / /g, '_' ) )
             + '&action=raw&ctype=text/javascript';
     var scriptElem = document.createElement( 'script' );
     scriptElem.setAttribute( 'src' , url );
     scriptElem.setAttribute( 'type' , 'text/javascript' );
     document.getElementsByTagName( 'head' )[0].appendChild( scriptElem );
 }
 
 function importStylesheet( page ) {
     var sheet = '@import "'
               + wgScriptPath
               + '/index.php?title='
               + encodeURIComponent( page.replace( / /g, '_' ) )
               + '&action=raw&ctype=text/css";'
     var styleElem = document.createElement( 'style' );
     styleElem.setAttribute( 'type' , 'text/css' );
     styleElem.appendChild( document.createTextNode( sheet ) );
     document.getElementsByTagName( 'head' )[0].appendChild( styleElem );
 }

 /** Reskin parser ***********************************************************
 * Instructions:
 * 1) Add the page title and namespace exactly ("Name_space:Page_name") as new skin, use 
 *    UNDERSCORES *NOT* SPACES: ("Main_Page": "", should be first line). The next parameter 
 *    is optionally an existing "MediaWiki:Skin/"-prefixed file (in which case you can skip 
 *    step 2).
 * 2) Create MediaWiki:Skin/Name_Space:Page_Name.css and place reskin CSS content there.
 */
 
 reskin = {
    "Main_Page": "",
    "UnNews:Main_Page": "Main Page.css",
    "Tlh:": "",
    "Tx:": "",
    "Vd:": "",
    "EBay": "",
    "EBay:": "EBay.css",
    "Em:": "",
    "Loneliness": "Em:.css",
    "Talk:Loneliness": "Em:.css",
    "User:Codeine/Em:": "Em:.css",
    "Memento": "",
    "Sdrawkcab": "",
    ")": "Sdrawkcab.css",
    "Babel:Aa": "Aaaa.css",
    "AAAAAAAAA!": "Aaaa.css",
    "Nihilism": "",
    "Babel:Gbs": "",
    "Babel:96": "",
    "Rp:": "",
    "Babel:APPL": "Fullscreen.css",
    "Babel:Ap": "Fullscreen.css",
    "Yahoo!": "Fullscreen.css",
    "User:Spintherism/Penmanship": "",
    "Babel:Hi": "",
    "Babel:666": "",
    "Wikipedia": "",
    "Babel:CaD": "",
    "An:": "",
    "Kenny_McCormick": "",
    "ROT13": "",
    "Namespace:Main_Page": "",
    "Babel:W2": "Fullscreen.css",
    "Benson:": "",
    "Upside_Down": "",
    "User:02barryc/UnNews/Site2": "",
    "User:Bradaphraser/SupperBowl": "",
    "Slime_Cube": "",
    "Time_Cubicle": "Slime Cube.css",
    "Babel:F@H": "",
    "The_Consumerist": "",
    "Cart": "Fullscreen.css",
    "Movie_Trailer_Announcer_Guy": "",
    "Ea:": "Fullscreen.css",
    "Babel:Vogon": "Vg:.css",
    "Babel:Communpedia": "Communpedia.css",
    "User:Mhaille/UnTube": "UnTube.css",
    "Socratic_method": "Smethod.css",
    "Babel:Newspeak": "",
    "User:Severian/Germ_Warfare": "Germ_Warfare.css",
    "User:Algorithm": "Nocategories.css",
    "Babel:Pumpkin": "Fullscreen.css",
    "MS_Paint": "",
    "Drawing": "Drawing.css"
 //Make sure all lines in this list except the last one have a comma after!
 }
 var skinName;
 
 if (reskin[wgPageName] != undefined && wgIsArticle == true) {
     skinName = (reskin[wgPageName].length > 0) ? reskin[wgPageName] : wgPageName + '.css';
     document.write('<style type="text/css">/*<![CDATA[*/ @import "/index.php?title=MediaWiki:Skin/' + skinName + '&action=raw&ctype=text/css"; /*]]>*/</style>');
 }


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


 /** 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://uncyclopedia.org/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 = 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);


 /** Dynamic navigation bars ************************************************
  * Allows navigations templates to expand and collapse their content to save space
  * Documentation on wikipedia at [[wikipedia:Wikipedia:NavFrame|Wikipedia:NavFrame]]
  */
 
 // 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);
        }
    }
 
 }
 
 addOnloadHook(createNavigationBarToggleButton, false);


 /** Archive edit tab disabling *************************************
  * Disables the edit tab on old forum topic pages to stop noobs bumping old topics.
  * Page can still be edited by going via the edit tab on the history etc, or by 
  * typing the edit address manually.
  * By [[User:Spang|Spang]]
  */
 
 function disableOldForumEdit () {
   if(typeof(enableOldForumEdit) != 'undefined' && enableOldForumEdit) return;
   if (!document.getElementById('ca-edit') || !document.getElementById('old-forum-warning')) return;
   editLink = document.getElementById('ca-edit').firstChild;
   editLink.removeAttribute('href', 0);
   editLink.style.color = 'gray';
   editLink.innerHTML = 'no editing';
 }
 addOnloadHook(disableOldForumEdit);

 //<pre>
 /** Embed flash movies **************************************************
  * Allows embedding of flash files in a page. Only enabled in userspace currently. 
  * See [[Template:Flash]]
  * By [[User:Olipro|Olipro]]
  */
 var flashOk;
 function embedFlashMovie(flashOk) {
     mainbody = document.getElementById('bodyContent');
     mainbody.innerHTML = contentTempHolder;
     spancheck = document.getElementsByTagName('span');
     for(i = 0; i < spancheck.length; i ++) {
         if(spancheck[i].getAttribute('id') != 'embedFlashDoc')
             continue;
         obj = spancheck[i].innerHTML.split('@');
         flwidth = obj[0];
         flheight = obj[1];
         flfile = obj[2].replace('fullurl://', 'http://');
         showFlash = ' ';
         if(flashOk) {
             showFlash = '<object width="'+ flwidth +'" height="' + flheight + '"';
             showFlash += 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
             showFlash += 'codebase="http://fpdownload.macromedia.com/pub/';
             showFlash += 'shockwave/cabs/flash/swflash.cab#version=8,0,0,0">';
             showFlash += '<param name="movie" value="'+ flfile +'" />';
             showFlash += '<embed src="'+ flfile +'" width="'+ flwidth +'" height=';
             showFlash += '"'+ flheight +'" type="application/x-shockwave-flash" ';
             showFlash += 'pluginspage="http://www.macromedia.com/go/getflashplayer" />';
             showFlash += '</object>';
         } else {
             showFlash = '<a class="plainlinks" href="javascript:embedFlashMovie(true)" onClick="embedFlashMovie(true)">'+flfile+'</a> (Click to Show)';
         }
         spancheck[i].innerHTML = showFlash;
         spancheck[i].style.display = 'inline';
     }
 }
 var contentTempHolder;
 function embedFlashCheck() {
     if(!document.getElementById('embedFlashDoc'))
         return;
     mainbody = document.getElementById('bodyContent');
     contentTempHolder = mainbody.innerHTML;
     if(typeof displayFlashOverride != 'undefined') {
         embedFlashMovie(displayFlashOverride);
         return;
     }
     askmessage = '<div align="center" id="askflash">This page contains ';
     askmessage += '<a href="/wiki/Flash_Gordon" class="plainlinks">Flash</a>; would you ';
     askmessage += 'like to see it? <b><a href="javascript:embedFlashMovie(true)" ';
     askmessage += 'onClick="embedFlashMovie(true)">Yes</a> | <a ';
     askmessage += 'href="javascript:embedFlashMovie(false)" ';
     askmessage += 'onClick="embedFlashMovie(false)">No</a> | <a ';
     askmessage += 'href="/index.php?title=User:'+wgUserName+'/'+skin+'.js&';
     askmessage += 'action=edit&section=new&preload=Template:Flash/disable">';
     askmessage += 'Don\'t show this again</a></b></div>';
     mainbody.innerHTML = askmessage;
 }
 addOnloadHook(embedFlashCheck);
 //</pre>



 //
 /** Sortable table fixes **************************************************
  * Fixes some problems the default sortable table script has.
  * From http://meta.wikimedia.org/wiki/MediaWiki:Common.js
  */
 
 function ts_parseFloat(num) {
 	if (!num) return 0;
      num = removeSpaces(num);
 	num = parseFloat(num.replace(/,/g, ""));
 	return (isNaN(num) ? 0 : num);
 }
  
 //Keep spaces in "currency" mode, to sort a range "70 to 80" at 70, not 7080
 function ts_parseFloat_ks(num) {
 	if (!num) return 0;
 	num = parseFloat(num.replace(/,/g, ""));
 	return (isNaN(num) ? 0 : num);
 }
  
 //Auxiliary function for function ts_resortTable(lnk)
 function removeSpaces(string) {
         var tstring = "";
         string = '' + string;
         splitstring = string.split(" ");
         for(i = 0; i < splitstring.length; i++)
         tstring += splitstring[i];
         return tstring;
 }
  
 //Overrides the function with the same name in http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/skins/common/wikibits.js
 //Changes the criteria for various sorting modes, see [[Help:Sorting]].
 //For easy maintenance the difference with wikibits.js is kept limited to a few lines.
 function ts_resortTable(lnk) {
 	// get the span
 	var span = lnk.getElementsByTagName('span')[0];
  
 	var td = lnk.parentNode;
 	var tr = td.parentNode;
 	var column = td.cellIndex;
  
 	var table = tr.parentNode;
 	while (table && !(table.tagName && table.tagName.toLowerCase() == 'table'))
 		table = table.parentNode;
 	if (!table) return;
  
 	// Work out a type for the column
 	if (table.rows.length <= 1) return;
  
 	// Skip the first row if that's where the headings are
 	var rowStart = (table.tHead && table.tHead.rows.length > 0 ? 0 : 1);
  
 	var itm = "";
 	for (var i = rowStart; i < table.rows.length; i++) {
 		if (table.rows[i].cells.length > column) {
 			itm = ts_getInnerText(table.rows[i].cells[column]);
 			itm = itm.replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, "");
 			if (itm != "") break;
 		}
 	}
  
 	sortfn = ts_sort_caseinsensitive;
      itmns = removeSpaces(itm);
      if (itmns.match(/^[\d\.\,\-\+]+\%?$/)) sortfn = ts_sort_numeric;
      if (itmns.match(/^[\d\.\,\-\+]+[eE][\d\-\+]+\%?$/)) sortfn = ts_sort_numeric;
      if (itmns.match(/^[\d\.\,\-\+]+e[\d\-\+]+\u00d710[\d\-\+]+\%?$/)) sortfn = ts_sort_numeric;
 	if (itm.match(/^\d\d[\/. -][a-zA-Z]{3}[\/. -]\d\d\d\d$/))
 		sortfn = ts_sort_date;
 	if (itm.match(/^\d\d[\/.-]\d\d[\/.-]\d\d\d\d$/))
 		sortfn = ts_sort_date;
 	if (itm.match(/^\d\d[\/.-]\d\d[\/.-]\d\d$/))
 		sortfn = ts_sort_date;
 	if (itm.match(/^[\u00a3$\u20ac\u00a5]/)) // pound dollar euro yen
 		sortfn = ts_sort_currency;
      if (itm.match(/sm=c$/)) sortfn = ts_sort_currency;
      if (itm.match(/sm=d$/)) sortfn = ts_sort_date;
      if (itm.match(/sm=n$/)) sortfn = ts_sort_numeric;
  
 	var reverse = (span.getAttribute("sortdir") == 'down');
  
 	 var newRows = new Array();
 	 for (var j = rowStart; j < table.rows.length; j++) {
 	 	var row = table.rows[j];
 	 	var keyText = ts_getInnerText(row.cells[column]);
 		 var oldIndex = (reverse ? -j : j);
 
 		newRows[newRows.length] = new Array(row, keyText, oldIndex);
 	}
  
 	newRows.sort(sortfn);
  
 	var arrowHTML;
 	if (reverse) {
 			arrowHTML = '<img src="'+ ts_image_path + ts_image_down + '" alt="&darr;"/>';
 			newRows.reverse();
 			span.setAttribute('sortdir','up');
 	} else {
 			arrowHTML = '<img src="'+ ts_image_path + ts_image_up + '" alt="&uarr;"/>';
 			span.setAttribute('sortdir','down');
 	}
  
 	// We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
 	// don't do sortbottom rows
 	for (var i = 0; i < newRows.length; i++) {
 		if ((" "+newRows[i][0].className+" ").indexOf(" sortbottom ") == -1)
 			table.tBodies[0].appendChild(newRows[i][0]);
 	}
 	// do sortbottom rows only
 	for (var i = 0; i < newRows.length; i++) {
 		if ((" "+newRows[i][0].className+" ").indexOf(" sortbottom ") != -1)
 			table.tBodies[0].appendChild(newRows[i][0]);
 	}
  
 	// Delete any other arrows there may be showing
 	var spans = getElementsByClassName(tr, "span", "sortarrow");
 	for (var i = 0; i < spans.length; i++) {
 		spans[i].innerHTML = '<img src="'+ ts_image_path + ts_image_none + '" alt="&darr;"/>';
 	}
 	span.innerHTML = arrowHTML;
  
 	ts_alternate(table);		
 }


 /** IP template for ban patrol ******
  * Others can be added for other or all pages.
  */
 if (mwCustomEditButtons && wgPageName == 'Uncyclopedia:Ban_Patrol') {
  mwCustomEditButtons[mwCustomEditButtons.length] = {
    "imageFile": "http://images1.wikia.com/uncyclopedia/images/d/d7/IP_button.png",
    "speedTip": "IP template",
    "tagOpen": "{" + "{" + "IP|",
    "tagClose": "}" + "}",
    "sampleText": "127.0.0.1"};
 }


 /** Fastdelete *******************************
  * By Splarka
  * The page that uses this is http://wikia.50webs.com/massdelete/uncyclopedia/index.htm .
  * There is also this thing: http://wikia-inc.com/wiki/Batch_delete_gen
  */
 function appendScript(url) {
   var scriptElem = document.createElement('script');
   scriptElem.setAttribute('src',url);
   scriptElem.setAttribute('type','text/javascript');
   document.getElementsByTagName('head')[0].appendChild(scriptElem);
 }
 
 appendScript('http://www.wikia.com/index.php?title=User:Splarka/fastdelete.js&action=raw&ctype=text/javascript&dontcountme=s');


 /** Fix XML bugs *******************************
  * By [[User:Spang|Spang]]
  * Eliminates bugs caused by invalid XHTML
  * The first parameter is the text of the page. Default is to return the XML, set the second parameter to false to return as text.
  */
 
 //<nowiki>
 function fixXML(text, parsetext) {
    var bug1a = text.indexOf('<head>');
    var bug1b = text.indexOf('<!-- start content -->');
    if (bug1a != -1 || bug1b != -1 ) var text = text.substring(0, bug1a) + '<body><div id="bodyContent">' + text.substring(bug1b);
 
    var bug2 = text.indexOf('<!-- end content -->');
    if (bug2 != -1)
       var text = text.substring(0, bug2) + '</div></body></html>';
    else
       return null;
 
    if (parsetext == false) return text; 
 
    var parser = new DOMParser();
    var fixedXML = parser.parseFromString(text, 'text/xml');
    return fixedXML;
 }
 //</nowiki>

/* MediaWiki:Monobook.js */
/* أي جافاسكريبت هنا سيتم تحميلها للمستخدمين الذين يستعملون واجهة مونوبوك */