MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. Some other stuff is located at mediawiki:monobook.js */ /* DO NOT EDIT THIS PAGE UNLESS YOU KNOW WHAT YOU ARE DOING */ // Adding functions to import external scripts importedScripts = {}; // object keeping track of included scripts, so a script ain't included twice function importScript( page ) { page = encodeURIComponent(page.replace(/ /g, '_' )); if (importedScripts[page]) return; else importedScripts[page] = true; var scriptElem = document.createElement( 'script' ); scriptElem.setAttribute( 'type', 'text/javascript' ); scriptElem.setAttribute( 'src', wgScript + '?title=' + page + '&action=raw&ctype=text/javascript'); document.getElementsByTagName( 'head' )[0].appendChild( scriptElem ); } function importStylesheet( page ) { page = encodeURIComponent(page.replace(/ /g, '_' )); if (importedScripts[page]) return; else importedScripts[page] = true; if (document.createStyleSheet) { document.createStyleSheet(wgScript + '?title=' + page + "&action=raw&ctype=text/css"); } else { var styleElem = document.createElement('style'); styleElem.setAttribute('type', 'text/css'); styleElem.appendChild(document.createTextNode('@import "' + wgScript + '?title=' + page + '&action=raw&ctype=text/css";')); document.getElementsByTagName('head')[0].appendChild(styleElem); } }

// for backwards compatibility var addLoadEvent = addOnloadHook; // Provides an easy way to disable load dependent features function delLoadEvent(func) { for (var i = 0; i < onloadFuncts.length; i++) { if (onloadFuncts[i] == func) onloadFuncts.splice(i, 1); } } // hasClass // Description: Uses regular expressions and caching for better performance. // Maintainers: w:User:Mike Dillon, w:User:R. Koot, w:User:SG var hasClass = (function {    var reCache = {};    return function (element, className) {      return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);   }; });

// name of project var wgProject = wgServer.replace("http://", ""); /*

RSS Feed insert. Only latest news and category. Should we add others?
*/ document.write('');

//Zach's Awesome category thingy takes a cat (?cat=foo) and intersects it with published to make an rss feed. Also can take ?lang=bar for other lang if (wgNamespaceNumber === 14) { document.write(''); } /*

Dynamic Navigation
*/ // Makes some dynamic nav boxes auto-close. See user:Bawolff/onebox-select.js & Template:Dynamic navigation noncentered // *Tested in MSIE 6, Opera 9.01, and firefox (1.5.0.11 and 2.0.0.something(I think its a 2 at the end) // *Adapted from the dynamic nav box script which is from somewhere on wikipedia // set up the words in your language var NavigationBarHide = '[ - ]'; var NavigationBarShow = '[ + ]'; var ONCE_NavigationBarHide = '[ ↑ ]'; var ONCE_NavigationBarShow = '[ ↓ ]'; // 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; var ONCE_NavigationBarShowDefault = 1; // shows and hides content and picture (if available) of navigation bars // Parameters: //    indexNavigationBar: the index of navigation bar to be toggled function ONCE_toggleNavigationBar(ONCE_indexNavigationBar) {   var ONCE_NavToggle = document.getElementById("NavToggleOnce" + ONCE_indexNavigationBar); var ONCE_NavFrame = document.getElementById("NavFrameOnce" + ONCE_indexNavigationBar); if (!ONCE_NavFrame || !ONCE_NavToggle) { return false; }  // if shown now if (ONCE_NavToggle.firstChild.data == ONCE_NavigationBarHide) { for (var ONCE_NavChild = ONCE_NavFrame.firstChild; ONCE_NavChild != null; ONCE_NavChild = ONCE_NavChild.nextSibling) { if (hasClass(ONCE_NavChild, 'NavPic') || hasClass(ONCE_NavChild, 'NavContent')) { ONCE_NavChild.style.display = 'none'; }    }     ONCE_NavToggle.firstChild.data = ONCE_NavigationBarShow; // if hidden now } else if (ONCE_NavToggle.firstChild.data == ONCE_NavigationBarShow) { //Start hiding all open boxes. things with f is loops to close everything for (f = 1; f < 50; f++) { //prevent indef loop var ONCE_f_NavToggle = document.getElementById("NavToggleOnce" + f); var ONCE_f_NavFrame = document.getElementById("NavFrameOnce" + f); if (!ONCE_f_NavFrame || !ONCE_f_NavToggle) { break; }      for (var ONCE_f_NavChild = ONCE_f_NavFrame.firstChild; ONCE_f_NavChild != null; ONCE_f_NavChild = ONCE_f_NavChild.nextSibling) { if (hasClass(ONCE_f_NavChild, 'NavPic') || hasClass(ONCE_f_NavChild, 'NavContent')) { ONCE_f_NavChild.style.display = 'none'; }      }       ONCE_f_NavToggle.firstChild.data = ONCE_NavigationBarShow; }    // open selected one for (var ONCE_NavChild = ONCE_NavFrame.firstChild; ONCE_NavChild != null; ONCE_NavChild = ONCE_NavChild.nextSibling) { if (hasClass(ONCE_NavChild, 'NavPic') || hasClass(ONCE_NavChild, 'NavContent')) { ONCE_NavChild.style.display = 'block'; }    }     ONCE_NavToggle.firstChild.data = ONCE_NavigationBarHide; } } // 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 (NavToggle.firstChild.data == NavigationBarHide) { // if shown now for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) { if (hasClass(NavChild, 'NavPic') || hasClass(NavChild, 'NavContent')) { NavChild.style.display = 'none'; }     }      NavToggle.firstChild.data = NavigationBarShow; } else if (NavToggle.firstChild.data == NavigationBarShow) { // if hidden now for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) { if (hasClass(NavChild, 'NavPic') || hasClass(NavChild, 'NavContent')) { NavChild.style.display = 'block'; }    }     NavToggle.firstChild.data = NavigationBarHide; } } // adds show/hide-button to navigation bars function createNavigationBarToggleButton {  var indexNavigationBar = 0, ONCE_indexNavigationBar = 0; var NavFrames = document.getElementsByTagName("div"); // iterate over all -elements for (var i=0; NavFrame = NavFrames[i]; i++) { // if found a once navigation bar if (hasClass(NavFrame, 'NavFrame') && hasClass(NavFrame, 'NavOnce')) { ONCE_indexNavigationBar++; var ONCE_NavToggle = document.createElement("a"); ONCE_NavToggle.className = 'NavToggle'; ONCE_NavToggle.setAttribute('id', 'NavToggleOnce' + ONCE_indexNavigationBar); ONCE_NavToggle.setAttribute('href', 'javascript:ONCE_toggleNavigationBar(' + ONCE_indexNavigationBar + ');'); var ONCE_NavToggleText = document.createTextNode(ONCE_NavigationBarHide); ONCE_NavToggle.appendChild(ONCE_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 (hasClass(NavFrame.childNodes[j], "NavHead")) { NavFrame.childNodes[j].appendChild(ONCE_NavToggle); }      }       NavFrame.setAttribute('id', 'NavFrameOnce' + ONCE_indexNavigationBar); } else if (hasClass(NavFrame, "NavFrame")) { // if found a navigation bar 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 (hasClass(NavFrame.childNodes[j], "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); }  }   if (ONCE_NavigationBarShowDefault < ONCE_indexNavigationBar) { for (var i=1; i<=ONCE_indexNavigationBar; i++) { ONCE_toggleNavigationBar(i); }  } } addLoadEvent(createNavigationBarToggleButton); // END Dynamic Navigation Bars // ============================================================ /*

custom edit buttons
*/ if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/7f/Button_link_to_Wikipedia.png", "speedTip": "wikipedia link", "tagOpen": "w:",    "tagClose": "", "sampleText": "article title" };  mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/47/Button_redir.png", "speedTip": "Redirect", "tagOpen": "#REDIRECT",    "tagClose": "", "sampleText": "Redirected to" }; } /*

Comment tabs
*/ importScript("MediaWiki:Comments.js"); /*

Stats
*/ /** pageview counter *********************************************************** * *  Description: Please talk to de:User:LeonWeber before changing anything or   *               if there are any issues with that. * Maintainers: de:User:LeonWeber? */ importScript("MediaWiki:Stats.js"); /*

CGI:IRC login form
*/ // See mediawiki:Irc.js. If this does something stupid, blame user:Bawolff //load irc login box if on page addLoadEvent(function {   if (document.getElementById("cgiircbox")) {     var url = "http://en.wikinews.org/w/index.php?title=Mediawiki:Irc.js&action=raw&ctype=text/javascript&dontcountme=s";     var scriptElem = document.createElement( 'script' );     scriptElem.setAttribute( 'src', url );     scriptElem.setAttribute( 'type' , 'text/javascript' );     document.getElementsByTagName( 'head' )[0].appendChild( scriptElem );   } }); /*

Miscellaneous/Other
*/ // install User:TheFearow's ticker script importScript("MediaWiki:Ticker.js"); importScript("MediaWiki:pagecss.js"); // fix for the football portal if (wgPageName == "Portal:Football") { NavigationBarShowDefault = 50; }

var load_extratabs = true;

// edit tools selectbox (see MediaWiki:Edittools and MediaWiki:Edittools.js) var load_edittools = true; importScript("MediaWiki:Edittools.js");

importScript("MediaWiki:Tabber.js"); importScript("MediaWiki:Collapsible.js") importScript("MediaWiki:Calendar.js") function clearMainPage {   if (wgTitle == 'Main Page') {   var h1tags= document.getElementsByTagName( "h1" ); var h = h1tags[0]; var parent = h.parentNode; parent.removeChild(h); }   }    addOnloadHook(clearMainPage);

// ************************************************** // Experimental javascript countdown timer (Splarka) // Version 0.0.3 // ************************************************** // // Usage example: // //  Only January 01 2007 00:00:00 PST until New years. // //  Javascript disabled.

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 = 'T plus '; } else { var tpm = 'T minus '; }

// calcuate the diff var left = (diff%60) + ' seconds'; 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 = 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 // *************************************************

//Bawolff's modified ticker. if all goes well, will switch over shortly addOnloadHook(function {if ((window.disable_ticker2 !== true) && (document.getElementById("singleTickerForPage") || document.getElementById('enableTickers'))) importScript("MediaWiki:Ticker2.js");});

/* Hook that enables collapsing objects. * Added 11/5/2007 by WhiteMystery (misterioblanco@gmail.com) * on Encyclopedia Dramatica, stolen by Zaza * Improved with multiMorph and galleryMorph by MFH * Enhanced with fading effect by Sanjilops * Uses publicly available code in one function, where noted. */

var noMorphSFX = true;

/* Function that toggles collapsing objects. * Added 11/5/2007 by WhiteMystery (misterioblanco@gmail.com) * on Encyclopedia Dramatica, stolen by Zaza * Uses publicly available code in one function, where noted. */

function tableOrNot(objId) { if (document.getElementById(objId).tagName == "TABLE") return "table"; else return "block"; }

var toggleLinkDelay = 700; var toggleLinkInterval = 10;

function toggleCollapse(objToToggle) { var objToToggle = this.parentNode.id.replace(/Link$/, '');

var linkText = ""; var targetObject = returnObjById(objToToggle); if (!targetObject) return; var collapseText = returnObjById(objToToggle + "CollapseText").innerHTML; var expandText = returnObjById(objToToggle + "ExpandText").innerHTML; var slide = !hasClass(returnObjById(objToToggle + "Link"), "no-slide") && !noMorphSFX; var fade = !hasClass(returnObjById(objToToggle + "Link"), 'no-fade') && !noMorphSFX; if ( targetObject.style.display == "none" ) { targetObject.style.display = tableOrNot(objToToggle); linkText = collapseText; if (slide) Slide(targetObject, false); if (fade) { if (!parseInt(targetObject.style.width) && navigator.appName == "Microsoft Internet Explorer") targetObject.style.width = targetObject.offsetWidth + 'px'; targetObject.style.filter = "alpha(opacity=0)"; targetObject.style.opacity = 0; setTimeout(function {Fade(targetObject, toggleLinkDelay, toggleLinkInterval, false, 1);}, 1); }	 }	else { if (slide) { Slide(targetObject, true); setTimeout(function {	targetObject.style.display = "none"; }, toggleLinkDelay + toggleLinkInterval); if (fade) setTimeout(function {Fade(targetObject, toggleLinkDelay, toggleLinkInterval, true, 0.8);}, 1); }		 else { if (fade) { setTimeout(function {Fade(targetObject, toggleLinkDelay, toggleLinkInterval, true, 0.8);}, 1); setTimeout(function {targetObject.style.display = "none"; }, toggleLinkDelay + toggleLinkInterval); }			 else targetObject.style.display = "none"; }		linkText = expandText; }	var toggleLink = returnObjById(objToToggle + "Link-"); toggleLink.innerHTML = linkText; function Slide (element, close) { if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.userAgent[navigator.userAgent.indexOf("MSIE") + 5]) >= 8) return; var start_time = new Date.getTime; var size = element.offsetHeight; var start_value = close? 0: 0 - size; var final_value = close? 0 - size : 0; element.style.marginTop = start_value + 'px'; element.style.width = 'auto'; setTimeout(function { Do; }, toggleLinkInterval); return; function Do { var cur_time = new Date.getTime; var past_time = cur_time - start_time; if (past_time >= NavigationBarSlideDelay) { element.style.marginTop = final_value + 'px'; return; }		 var progress = past_time/toggleLinkDelay; var new_value = close? final_value * progress : start_value * (1 - progress); element.style.marginTop = new_value + 'px'; setTimeout(function { Do; }, toggleLinkInterval); return; } } }

function createToggleLinks {

var toggleLinkCollection = document.getElementsByClass("toggleLink"); for (var i = 0; i < toggleLinkCollection.length; i++) { var spanID = toggleLinkCollection[i].getAttribute("id"); var targetID = spanID.substr(0, spanID.length - 4); var collapseText = returnObjById(targetID + "CollapseText").innerHTML; var expandText = returnObjById(targetID + "ExpandText").innerHTML; var initialState = returnObjById(targetID + "InitialState").innerHTML; var toggleLink = document.createElement("a"); toggleLinkCollection[i].appendChild(toggleLink); if (initialState == "0") { returnObjById(targetID).style.display = "none"; toggleLink.innerHTML = expandText; }		else { returnObjById(targetID).style.display = tableOrNot(targetID); toggleLink.innerHTML = collapseText; }		toggleLink.onclick = toggleCollapse;

//toggleLink.className = "morphLink"; toggleLink.id = targetID + "Link-"; } }

/* Functions that performs the morph operation. * Added 11/5/2007 by WhiteMystery (misterioblanco@gmail.com) * on Encyclopedia Dramatica, stolen by Zaza * Uses publicly available code in one function, where noted. */

var MorphFadeDelay = 800; var MorphFadeInterval = 50;

function performMorph(targetID, targetNumber) { var counter = 1; while ( returnObjById(targetID + "Content" + counter) ) { if ( counter == targetNumber ) { returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter); if (!hasClass(returnObjById(targetID + "Master"), 'no-fade') && !noMorphSFX) Fade(returnObjById(targetID + "Content" + counter), MorphFadeDelay, MorphFadeInterval, false, 1); }		else returnObjById(targetID + "Content" + counter).style.display = "none"; counter++; }	returnObjById(targetID + "Master").innerHTML = targetNumber; }

function morphForward {

var targetID = this.getAttribute('name').replace(/LinkNext$/, ''); var nextPane = parseInt(returnObjById(targetID + "Master").innerHTML) + 1; if ( returnObjById(targetID + "Content" + nextPane) ) performMorph(targetID, nextPane); else performMorph(targetID, "1"); }

function morphBackward {

var targetID = this.getAttribute('name').replace(/LinkPrev$/, ''); var prevPane = parseInt(returnObjById(targetID + "Master").innerHTML) - 1; if ( prevPane > 0 ) performMorph(targetID, prevPane); else { var maxIndex = 1; while ( returnObjById(targetID + "Content" + maxIndex) ) maxIndex++; performMorph(targetID, maxIndex - 1); } }

/* Special functions for the galleryMorph, * created by MFH */

function performGalleryMorph(targetID, targetNumber) {

var counter = 1; while ( returnObjById(targetID + "Content" + counter) ) { if ( counter == targetNumber ) { returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter); if (!hasClass(returnObjById(targetID + "Master"), 'no-fade') && !noMorphSFX) Fade(returnObjById(targetID + "Content" + counter), MorphFadeDelay, MorphFadeInterval, false, 1); }		else returnObjById(targetID + "Content" + counter).style.display = "none"; counter++; }	if (targetNumber == 1) { returnObjById(targetID + "LinkPrev").style.display = "none"; }	else { returnObjById(targetID + "LinkPrev").style.display = tableOrNot(targetID + "LinkPrev"); }	if (targetNumber == counter - 1) { returnObjById(targetID + "LinkNext").style.display = "none"; }	else { returnObjById(targetID + "LinkNext").style.display = tableOrNot(targetID + "LinkNext"); }	galleryCounter = returnObjById(targetID + "Master").getAttribute("counter"); returnObjById(targetID + "Counter").innerHTML = "(" + targetNumber + "/" + galleryCounter + ")"; returnObjById(targetID + "Master").innerHTML = targetNumber; }

function galleryMorphForward {

var targetID = this.getAttribute('name').replace(/LinkNext$/, ''); var nextPane = parseInt(returnObjById(targetID + "Master").innerHTML) + 1; if ( returnObjById(targetID + "Content" + nextPane) ) performGalleryMorph(targetID, nextPane); else performGalleryMorph(targetID, "1"); }

function galleryMorphBackward { var targetID = this.getAttribute('name').replace(/LinkPrev$/, ''); var prevPane = parseInt(returnObjById(targetID + "Master").innerHTML) - 1; if ( prevPane > 0 ) performGalleryMorph(targetID, prevPane); else { var maxIndex = 1; while ( returnObjById(targetID + "Content" + maxIndex) ) maxIndex++; performGalleryMorph(targetID, maxIndex - 1); } }

/* Function that creates ED's collapsing objects and toggle links. * Added 11/5/2007 by WhiteMystery (misterioblanco@gmail.com) * on Encyclopedia Dramatica, stolen by Zaza * Uses publicly available code in one function, where noted. * * Updated: 1/11/2008 by WhiteMystery to add new Morphing Objects * functionality. * Updated: 23/5/2009 by MFH to add 2 new kinds of morph: * multiMorph and galleryMorph */

function createMorphLinks {

var morphMasterCollection = document.getElementsByClass("morphMaster"); var multiMorphMasterCollection = document.getElementsByClass("multiMorphMaster"); var galleryMorphMasterCollection = document.getElementsByClass("galleryMorphMaster"); for (var i = 0; i < morphMasterCollection.length; i++) { var spanID = morphMasterCollection[i].getAttribute("id"); var targetID = spanID.substr(0, spanID.length - 6); var counter = 1; // Create forward and backward paging if the paging elements exist if ( returnObjById(targetID + "LinkNext") && returnObjById(targetID + "LinkPrev") && returnObjById(targetID + "Content1") ) { // Create the forward link var nextLink = document.createElement("div"); nextLink.innerHTML = returnObjById(targetID + "LinkNext").innerHTML; nextLink.setAttribute('name', targetID + "LinkNext"); nextLink.onclick = morphForward; nextLink.className = "morphLink"; returnObjById(targetID + "LinkNext").innerHTML = ""; returnObjById(targetID + "LinkNext").appendChild(nextLink, 0); // Create the backward link var prevLink = document.createElement("div"); prevLink.innerHTML = returnObjById(targetID + "LinkPrev").innerHTML; prevLink.setAttribute('name', targetID + "LinkPrev"); prevLink.onclick = morphBackward; prevLink.className = "morphLink"; returnObjById(targetID + "LinkPrev").innerHTML = ""; returnObjById(targetID + "LinkPrev").appendChild(prevLink, 0); // Initialize content panes while ( returnObjById(targetID + "Content" + counter) ) { if ( counter == 1 ) returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter); else returnObjById(targetID + "Content" + counter).style.display = "none"; counter++; }			}

counter = 1; // Whether or not there is paging, generate normal links while (returnObjById(targetID + "Link" + counter) && returnObjById(targetID + "Content" + counter)) { var morphLink = document.createElement("div"); morphLink.innerHTML = returnObjById(targetID + "Link" + counter).innerHTML; returnObjById(targetID + "Link" + counter).innerHTML = ""; returnObjById(targetID + "Link" + counter).appendChild(morphLink); morphLink.className = "morphLink"; morphLink.setAttribute('name', targetID + "Link" + counter); morphLink.onclick = function { var targetID = this.getAttribute('name').replace(/Link\d+$/, ''); var targetNumber = this.parentNode.id.replace(/.+Link/, ''); performMorph(targetID, targetNumber); return };			// Initialize content panes if (counter == 1) returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter); else returnObjById(targetID + "Content" + counter).style.display = "none"; counter++; }		morphMasterCollection[i].innerHTML = "1"; morphMasterCollection[i].style.display = "none"; }

for (var i = 0; i < multiMorphMasterCollection.length; i++) { var spanID = multiMorphMasterCollection[i].getAttribute("id"); var targetID = spanID.substr(0, spanID.length - 6); var counter = 1; // Create forward and backward paging if the paging elements exist if (document.getElementsByClass(targetID + "LinkNext") && document.getElementsByClass(targetID + "LinkPrev") && document.getElementsByClass(targetID + "Content1")) { // Create the forward link var nextLinkCollection = document.getElementsByClass(targetID + "LinkNext"); for (j = 0; j < nextLinkCollection.length; j++) { var nextLink = document.createElement("div"); nextLink.innerHTML = nextLinkCollection[j].innerHTML; nextLink.setAttribute('name', targetID + "LinkNext"); nextLink.onclick = morphForward; nextLink.className = "morphLink"; nextLinkCollection[j].innerHTML = ""; nextLinkCollection[j].appendChild(nextLink, 0); }			// Create the backward link var prevLinkCollection = document.getElementsByClass(targetID + "LinkPrev"); for (j = 0; j < prevLinkCollection.length; j++) { var prevLink = document.createElement("div"); prevLink.innerHTML = prevLinkCollection[j].innerHTML; prevLink.setAttribute('name', targetID + "LinkPrev"); prevLink.onclick = morphBackward; prevLink.className = "morphLink"; prevLinkCollection[j].innerHTML = ""; prevLinkCollection[j].appendChild(prevLink, 0); }			// Initialize content panes while (returnObjById(targetID + "Content" + counter)) { if (counter == 1) returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter); else returnObjById(targetID + "Content" + counter).style.display = "none"; counter++; }			}

counter = 1; // Whether or not there is paging, generate normal links while ( document.getElementsByClass(targetID + "Link" + counter) && returnObjById(targetID + "Content" + counter) ) { var morphLinkCollection = document.getElementsByClass(targetID + "Link" + counter); for (j = 0; j < morphLinkCollection.length; j++) { var morphLink = document.createElement("div"); morphLink.innerHTML = morphLinkCollection[j].innerHTML; morphLinkCollection[j].innerHTML = ""; morphLink.setAttribute('name', targetID + "Link" + counter); morphLinkCollection[j].appendChild(morphLink, 0); morphLink.onclick = function { var targetID = this.getAttribute('name').replace(/Link\d+$/, ''); var targetNumber = this.getAttribute('name').replace(/.+Link/, ''); performMorph(targetID, targetNumber); return };				morphLink.className = "morphLink"; }			// Initialize content panes if (counter == 1) returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter); else returnObjById(targetID + "Content" + counter).style.display = "none"; counter++; }		multiMorphMasterCollection[i].innerHTML = "1"; multiMorphMasterCollection[i].style.display = "none"; }	for (var i = 0; i < galleryMorphMasterCollection.length; i++) { var spanID = galleryMorphMasterCollection[i].getAttribute("id"); var targetID = spanID.substr(0, spanID.length - 6); var counter = 1; // Create forward and backward paging if the paging elements exist if ( returnObjById(targetID + "LinkNext") && returnObjById(targetID + "LinkPrev") && returnObjById(targetID + "Content1") ) { // Create the forward link var nextLink = document.createElement("div"); nextLink.innerHTML = returnObjById(targetID + "LinkNext").innerHTML; nextLink.setAttribute('name', targetID + "LinkNext"); nextLink.onclick = galleryMorphForward; nextLink.className = "morphLink"; returnObjById(targetID + "LinkNext").innerHTML = ""; returnObjById(targetID + "LinkNext").appendChild(nextLink, 0); // Create the backward link var prevLink = document.createElement("div"); prevLink.innerHTML = returnObjById(targetID + "LinkPrev").innerHTML; prevLink.setAttribute('name', targetID + "LinkPrev"); prevLink.onclick = galleryMorphBackward; prevLink.className = "morphLink"; returnObjById(targetID + "LinkPrev").innerHTML = ""; returnObjById(targetID + "LinkPrev").appendChild(prevLink, 0); // Initialize content panes while ( returnObjById(targetID + "Content" + counter) ) { if (counter == 1) returnObjById(targetID + "Content" + counter).style.display = tableOrNot(targetID + "Content" + counter); else returnObjById(targetID + "Content" + counter).style.display = "none"; counter++; }			if (counter == 2) { returnObjById(targetID + "LinkNext").style.display = "none"; }			galleryCounter = counter - 1; returnObjById(targetID + "Master").setAttribute("counter", galleryCounter); if (returnObjById(targetID + "Counter")) { returnObjById(targetID + "Counter").innerHTML = "(1/" + galleryCounter + ")"; }		}		galleryMorphMasterCollection[i].innerHTML = "1"; galleryMorphMasterCollection[i].style.display = "none"; } }

/* Function that toggles ED's collapsing objects. * Added 11/5/2007 by WhiteMystery (misterioblanco@gmail.com) * on Encyclopedia Dramatica, stolen by Zaza * Taken from http://www.netlobo.com/javascript_get_element_id.html */

function returnObjById(id) { if (document.getElementById) var returnVar = document.getElementById(id); else if (document.all) var returnVar = document.all[id]; else if (document.layers) var returnVar = document.layers[id]; return returnVar; }