/* generated javascript */
var skin = 'monobook';
var stylepath = '/skins';

/* MediaWiki:Common.js */
/* <pre><nowiki> */

/* Размещённый здесь код JavaScript будет загружен всем пользователям при обращении к какой-либо странице */

/* 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-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-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'); 
*/

// ============================================================
// BEGIN Dynamic Navigation Bars (experimantal)
// This is used in Template:Showhide and similar.
// Taken from http://en.wikipedia.org/wiki/MediaWiki:Monobook.js
 function addLoadEvent(func) 
{
  if (window.addEventListener) 
    window.addEventListener("load", func, false);
  else if (window.attachEvent) 
    window.attachEvent("onload", func);
}

// 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 = 0;


// 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
// ============================================================

// ============================================================
// This code should make the header on the Main Page go away.
// Taken from Wikipedia

var mpTitle = "Main Page";
var isMainPage = (/(title=|\/wiki\/)([Tt]alk:|)[Mm]ain[ _][Pp]age/.test(document.location));
var isMainPageFront = (document.title.substr(0, document.title.lastIndexOf(" - ")) == mpTitle);
var isDiff = (document.location.search && (document.location.search.indexOf("diff=") != -1 || document.location.search.indexOf("oldid=") != -1));

if (isMainPage) 
{

if (isMainPageFront && !isDiff)
{
document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, #contentSub, h1.firstHeading { display: none !important; } /*]]>*/</style>');
}

var mpSmallEnabled;
var mpMinWidth = 700;

function mainPageTransform()
{
       if (isMainPage && document.getElementById('ca-nstab-main')) 
         {document.getElementById('ca-nstab-main').firstChild.innerHTML = 'Main Page';}
       if (((isMainPageFront && !isDiff) || /[\/=:]Main_Page/.test(document.location)) && document.getElementById('ca-nstab-main'))
        var mpContentEl = document.getElementById("bodyContent");
        var mpBrowseEl = document.getElementById("EnWpMpBrowse");
        var mpContainEl = document.getElementById("EnWpMpBrowseContainer");
        var mpMarginEl = document.getElementById("EnWpMpMargin");
        var mpEl = document.getElementById("EnWpMainPage");

        if (!mpContentEl || !mpBrowseEl || !mpContainEl || !mpMarginEl || !mpEl)
                return;

        if (!mpSmallEnabled && mpContentEl.offsetWidth < mpMinWidth)
        {
                mpContainEl.insertBefore(mpBrowseEl, mpContainEl.firstChild);
                mpBrowseEl.className = "EnWpMpBrowseBottom";
                mpMarginEl.style.marginRight = 0;
                mpSmallEnabled = true;
        }
        else if (mpSmallEnabled && mpContentEl.offsetWidth > mpMinWidth)
        {
                mpEl.insertBefore(mpBrowseEl, mpEl.firstChild);
                mpBrowseEl.className = "EnWpMpBrowseRight";
                mpMarginEl.style.marginRight = "13.8em";
                mpSmallEnabled = false;
        }
}

var onloadFuncts = [ mainPageTransform ];

if (window.addEventListener) 
  window.addEventListener("resize", mainPageTransform, false);
else if (window.attachEvent) 
  window.attachEvent("onresize", mainPageTransform);

}

// ============================================================

/* Customized versions of several routines used by the sortable table feature
   These functions (ts_*) will override the default versions found in wikibits.js
   Feature include:
   - sorting of tables with rowspan or colspan
   - descending order allowed as column default
   - specify format of column data
*/

function ts_makeSortable(table) {
	ts_setMultiRows(table);
	var headRow = new Array();
	if (table.rows && table.rows.length > 0) {
		if (table.tHead && table.tHead.rows.length > 0) {
			headRow = table.tHead.rows;
		} else {
			for (var j=0; j<table.rows.length; j++) {
				if (table.rows[j].baserow+j>0)
					break;
				headRow.push (table.rows[j]);
			}
		}
	}
	if (!headRow.length) return;
	table.rowStart = headRow.length;

	// We have a first row: assume it's the header, and make its contents clickable links
        for (var j=0; j<headRow.length; j++) {
		for (var i=0; i<headRow[j].sortrowd.length; i++) {
			jcell = headRow[j].sortrowd[i]+j;
			icell = headRow[j].sortcol[i];
			var cell = headRow[jcell].cells[icell];
	                var spans = getElementsByClassName(cell, "span", "sortarrow");
			if (cell.colSpan == 1 &&
                            (" "+cell.className+" ").indexOf(" unsortable ") == -1 &&
                            spans.length==0) {
				cell.basecol = i;
                                if (cell.innerHTML.search(/<\s*br\s*\/?>\s*$/)<0) {
                                    cell.innerHTML += '<br>';
                                }
				cell.innerHTML += '<a href="#" class="sortheader" onclick="ts_resortTable(this);return false;"><span class="sortarrow"><img src="' + ts_image_path + ts_image_none + '" alt=&darr;"/></span></a>';
			}
		}
	}

	for (var j=0; j<table.rows.length; j++) {
		table.rows[j].setAttribute('origindex', j);
	}

	if (ts_alternate_row_colors)
		ts_alternate(table);
}

/* New function: determine layout of tables with rowspans or colspans */
function ts_setMultiRows (table) {
	var ieff = 0;
	var imax = 0;
	var jbase = 0;
	var jmax = 0;
	var src_i = new Array();
	var src_j = new Array();
	for (var j=0; j<table.rows.length; j++) {
		jmax = Math.max(jmax, j);
		if (!src_j[j]) {
			src_j[j] = new Array();
			src_i[j] = new Array();
		}

		for (var i = ieff = 0; i<table.rows[j].cells.length; ieff++, i++) {
			while (!isNaN(src_j[j][ieff]))
				ieff++;
			var cell = table.rows[j].cells[i];
			imax = Math.max(imax, ieff+cell.colSpan);
			jmax = Math.min(Math.max(jmax, j+cell.rowSpan-1),table.rows.length-1);
			for (var jd=0; jd<cell.rowSpan; jd++) {
				if (!src_j[j+jd]) {
					src_j[j+jd] = new Array();
					src_i[j+jd] = new Array();
				}
				for (id=0; id<cell.colSpan; id++) {
					src_i[j+jd][ieff+id] = i;
					src_j[j+jd][ieff+id] = j;
				}
			}
		}
		if (jmax == j) {
			var full;
			if (jbase==j && imax>1 && table.rows[j].cells.length==1 && table.rows[j].cells[0].colspan==imax) {
				full = true;
			}
			else {
				full = false;
			}
			var sortrow = -1;
			for (var ja=jbase; ja<=jmax; ja++) {
				table.rows[ja].fullcolspan = full;
				table.rows[ja].baserow = jbase-ja;
				table.rows[ja].sortrowd = new Array();
				table.rows[ja].sortcol = new Array();
				if ((" "+table.rows[ja].className+" ").indexOf(" sort_keyrow ") != -1) {
					sortrow = ja;
				}
			}
			for (var i=0; i<imax; i++) {
				var csortrow = -1;
				if (sortrow>=0 &&
                                    !isNaN(src_j[sortrow][i]) &&
                                    table.rows[src_j[sortrow][i]].cells[src_i[sortrow][i]].colSpan==1) {
					csortrow = sortrow;
				}
				for (var ja=jbase; ja<=jmax; ja++) {
					if (csortrow>=0) break;
					if (!isNaN(src_j[ja][i]) &&
                                            table.rows[src_j[ja][i]].cells[src_i[ja][i]].colSpan==1) {
						csortrow = j;
					}
				}
				for (var ja=jbase; ja<=jmax; ja++) {
					if (csortrow>=0) {
						table.rows[ja].sortrowd[i] = src_j[csortrow][i]-ja;
						table.rows[ja].sortcol[i] = src_i[csortrow][i];
					}
					else {
						table.rows[ja].sortrowd[i] = 0;
						table.rows[ja].sortcol[i] = 0;
					}
				}
			}	
			jbase = j+1;
		}
	}
}

function ts_resortTable(lnk) {
	// get the span
	var span = lnk.getElementsByTagName('span')[0];

	var td = lnk.parentNode;
	var tr = td.parentNode;
	var column = td.basecol;

	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.rowStart;

	sortfn = ts_sort_caseinsensitive;
	if ((" "+td.className+" ").indexOf(" sort_num ") != -1) {
		sortfn = ts_sort_numeric;
	}
	else if ((" "+td.className+" ").indexOf(" sort_date ") != -1) {
		sortfn = ts_sort_date;
	}
	else if ((" "+td.className+" ").indexOf(" sort_str ") == -1) {
		var itm = "";
		for (var j = rowStart; j < table.rows.length; j++) {
			if (table.rows[j].cells.length > column) {
				var sortrow = table.rows[j].sortrowd[column] + j;
				var sortcol = table.rows[j].sortcol[column];
				itm = ts_getInnerText(table.rows[sortrow].cells[sortcol]);
				itm = itm.replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, "");
				if (itm != "") break;
			}
		}

		itm = ts_firstWord(itm);
		if (itm.match(/^\d\d[\/\.\-][a-zA-z]{3}[\/\.\-]\d{2,4}$/))
			sortfn = ts_sort_date;
		else if (itm.match(/^\d\d[\/\.\-]\d\d[\/\.\-]\d{2,4}$/))
			sortfn = ts_sort_date;
		else if (itm.match(/^[\u00a3$\u20ac\u00a5]/)) // pound dollar euro yen
			sortfn = ts_sort_numeric;
		else if (itm.match(/^[\-\+]?[\d\.\,]+([eE][\-\+]?\d+)?\%?$/))
			sortfn = ts_sort_numeric;
	}

	var sortdir = 'down';
	var reverse = 0;
	if ((" "+td.className+" ").indexOf(" sort_desc ") != -1) {
		// order for default=descending is 'down', then 'up', then 'none'
		if (span.getAttribute("sortdir") == 'down') {
			sortdir = 'up';
		}
		else if (span.getAttribute("sortdir") == 'up')
			sortdir = 'none';
		else
			sortdir = 'down';
	}
	else {
		//standard order is 'up', then 'down', then 'none'
		if (span.getAttribute("sortdir") == 'down')
			sortdir = 'none';
		else if (span.getAttribute("sortdir") == 'up') {
			sortdir = 'down';
		}
		else
			sortdir = 'up';
	}

	var newRows = new Array();

	if (sortdir == 'none')
		sortfn = ts_sort_numeric;
		
	for (var j=rowStart ; j < table.rows.length; j++) {
		var row = table.rows[j];
		if (sortdir == 'none')
			var keyText = row.getAttribute('origindex');
		else {
			var sortrow = table.rows[j].sortrowd[column] + j;
			var sortcol = table.rows[j].sortcol[column];
			var keyText = ts_getInnerText(table.rows[sortrow].cells[sortcol]);
		}
		var oldIndex = ((sortdir == 'down') ? -j : j);

		newRows[newRows.length] = new Array(row, keyText, oldIndex);
	}
	newRows.sort(sortfn);
        if (sortdir == 'down')
		newRows.reverse();

	var arrowHTML;
	if (sortdir == 'down')
		arrowHTML = '<img src="'+ ts_image_path + ts_image_down + '" alt="&darr;"/>';
	else if (sortdir == 'up')
		arrowHTML = '<img src="'+ ts_image_path + ts_image_up + '" alt="&uarr;"/>';
	else
		arrowHTML = '<img src="'+ ts_image_path + ts_image_none + '" alt="&darr;"/>';

	// 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 (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 that may be showing
	var spans = getElementsByClassName(table, "span", "sortarrow");
	for (var i=0; i<spans.length; i++) {
		spans[i].innerHTML = '<img src="'+ ts_image_path + ts_image_none + '" alt="&darr;"/>';
		spans[i].setAttribute('sortdir',"none");
	}
	span.innerHTML = arrowHTML;
	span.setAttribute('sortdir',sortdir);
	ts_alternate(table);
}

function ts_dateToSortKey(date) {
	if (date.match(/^\d\d[\/\.-][a-zA-z][a-zA-Z][a-zA-Z][\/\.-]\d{2,4}/)) {
		switch (date.substr(3,3).toLowerCase()) {
			case "jan": var month = "01"; break;
			case "feb": var month = "02"; break;
			case "mar": var month = "03"; break;
			case "apr": var month = "04"; break;
			case "may": var month = "05"; break;
			case "jun": var month = "06"; break;
			case "jul": var month = "07"; break;
			case "aug": var month = "08"; break;
			case "sep": var month = "09"; break;
			case "oct": var month = "10"; break;
			case "nov": var month = "11"; break;
			case "dec": var month = "12"; break;
			// default: var month = "00";
		}
		year = ts_yearToY2K(date.substr(7,4));		
		return year+month+date.substr(0,2);
	} else if (date.match(/^\d\d[\/\.-]\d\d[\/\.-]\d{2,4}/)) {
		year = ts_yearToY2K(date.substr(6,4));
		if (europeandate == false)
			return year+date.substr(0,2)+date.substr(3,2);
		else
			return year+date.substr(3,2)+date.substr(0,2);
	}
	return "00000000";
}

function ts_firstWord(string) {
	string = ''+string;
	var splitstring = string.split(" ");
	return splitstring[0];
}

function ts_parseFloat(num) {
	if (!num) return 0;
        var matches=num.match(/[\-\+]?\.?\d+[^\s]*/);
	if (!matches) return 0;
	num = matches[0];
	num = parseFloat(num.replace(/,/g, ""));
	return (isNaN(num) ? 0 : num);
}

function ts_alternate(table) {
	// Take object table and get all it's tbodies.
	var tableBodies = table.getElementsByTagName("tbody");
	// Loop through these tbodies
	for (var i = 0; i < tableBodies.length; i++) {
		// Take the tbody, and get all it's rows
		var tableRows = tableBodies[i].getElementsByTagName("tr");
		// Loop through these rows
		// Start at 1 because we want to leave the heading row untouched
		for (var j = 0, jv = -1; j < tableRows.length; j++) {
			// Only increment for visible rows and rows that are not grouped
			if (tableRows[j].style.display != 'none' && (isNaN(tableRows[j].baserow) || tableRows[j].baserow == 0))
				jv++;
			var oldClasses = tableRows[j].className.split(" ");
			var newClassName = "";
			for (var k = 0; k<oldClasses.length; k++) {
				if (oldClasses[k] != "" && oldClasses[k] != "even" && oldClasses[k] != "odd")
					newClassName += oldClasses[k] + " ";
			}
			// Check if j is even, and apply classes for both possible results
			tableRows[j].className = newClassName + (jv%2 == 0 ? "even" : "odd");
		}
	}
}

/*
####################################################################################
####################################################################################
###########                                                            #############
###########        MediaWiki:Common.js from  WikiMedia Commons         #############
###########                                                            #############
####################################################################################
####################################################################################
*/

//<source lang="javascript">

/** onload handlers ************
 *  Simple fix such that crashes in one handler don't prevent later handlers from running.
 *
 *  Maintainer: [[User:Lupo]]
 */

if (typeof (onloadFuncts) != 'undefined') {

  // Enhanced version of jsMsg from wikibits.js. jsMsg can display only one message, subsequent
  // calls overwrite any previous message. This version appends new messages after already
  // existing ones.
  function jsMsgAppend (msg, className)
  {
    var msg_div = document.getElementById ('mw-js-message');
    var msg_log = document.getElementById ('mw-js-exception-log');
    if (!msg_log) {
      msg_log = document.createElement ('ul');
      msg_log.id = 'mw-js-exception-log';
      if (msg_div && msg_div.firstChild) {
        // Copy contents of msg_div into first li of msg_log
        var wrapper = msg_div.cloneNode (true);
        wrapper.id = "";
        wrapper.className = "";
        var old_stuff = document.createElement ('li');
        old_stuff.appendChild (wrapper);
        msg_log.appendChild (old_stuff);
      }
    }
    var new_item = document.createElement ('li');
    new_item.appendChild (msg);
    msg_log.appendChild (new_item);
    jsMsg (msg_log, className);
  }

  var Logger = {

    // Log an exception. If present, try to use a JS console (e.g., Firebug's). If no console is
    // present, or the user is a sysop, also put the error message onto the page itself.
    logException : function (ex) {
      try {
        var name = ex.name || "";
        var msg  = ex.message || "";
        var file = ex.fileName || ex.sourceURL || null; // Gecko, Webkit, others
        var line = ex.lineNumber || ex.line || null;    // Gecko, Webkit, others
        var logged = false;
        if (typeof (console) != 'undefined' && typeof (console.log) != 'undefined') {
          // Firebug, Firebug Lite, or browser-native or other JS console present. At the very
          // least, these will allow us to print a simple string.
          var txt = name + ': ' + msg;
          if (file) {
            txt = txt + '; ' + file;
            if (line) txt = txt + ' (' + line + ')';
          }
          if (typeof (console.error) != 'undefined') {
            if (   console.firebug
                || (   console.provider && console.provider.indexOf
                    && console.provider.indexOf ('Firebug') >= 0)
               )
            {
              console.error (txt + " %o", ex); // Use Firebug's object dump to write the exception
            } else {
              console.error (txt);
            }
          } else
            console.log (txt);
          logged = true;
        } 
        if (!logged || wgUserGroups.join (' ').indexOf ('sysop') >= 0) {
          if (name.length == 0 && msg.length == 0 && !file) return; // Don't log if there's no info
          if (name.length == 0) name = 'Unknown error';
          // Also put it onto the page for sysops.
          var log  = document.createElement ('span');
          if (msg.indexOf ('\n') >= 0) {
            var tmp = document.createElement ('span');
            msg = msg.split ('\n');
            for (var i = 0; i < msg.length; i++) {
              tmp.appendChild (document.createTextNode (msg[i]));
              if (i+1 < msg.length) tmp.appendChild (document.createElement ('br'));
            }
            log.appendChild (document.createTextNode (name + ': '));
            log.appendChild (tmp);
          } else {
            log.appendChild (document.createTextNode (name + ': ' + msg));
          }
          if (file) {
            log.appendChild (document.createElement ('br'));
            var a = document.createElement ('a');
            a.href = file;
            a.appendChild (document.createTextNode (file));
            log.appendChild (a);
            if (line) log.appendChild (document.createTextNode (' (' + line + ')'));
          }
          jsMsgAppend (log, 'error');        
        }
      } catch (anything) {
        // Swallow
      }
    }
  } // end Logger

  // Wrap a function with an exception handler and exception logging.
  function makeSafe (f) {
    return function () {
             try {
               return f.apply (this, arguments);
             } catch (ex) {
               Logger.logException (ex);
               return null;
             }
           };
  }

  // Wrap the already registered onload hooks
  for (var i = 0; i < onloadFuncts.length; i++)
    onloadFuncts[i] = makeSafe (onloadFuncts[i]);

  // Redefine addOnloadHook to catch future additions
  function addOnloadHook (hookFunct) {
    // Allows add-on scripts to add onload functions
    if (!doneOnloadHook) {
      onloadFuncts[onloadFuncts.length] = makeSafe (hookFunct);
    } else {
      makeSafe (hookFunct)();  // bug in MSIE script loading
    }
  }
} // end onload hook improvements

/** JSconfig ************
 * Global configuration options to enable/disable and configure
 * specific script features from [[MediaWiki:Common.js]] and
 * [[MediaWiki:Monobook.js]]
 * This framework adds config options (saved as cookies) to [[Special:Preferences]]
 * For a more permanent change you can override the default settings in your 
 * [[Special:Mypage/monobook.js]]
 * for Example: JSconfig.keys[loadAutoInformationTemplate] = false;
 *
 *  Maintainer: [[User:Dschwen]]
 */

var JSconfig =
{
 prefix : 'jsconfig_',
 keys : {},
 meta : {},

 //
 // Register a new configuration item
 //  * name          : String, internal name
 //  * default_value : String or Boolean (type determines configuration widget)
 //  * description   : String, text appearing next to the widget in the preferences, or an hash-object
 //                    containing translations of the description indexed by the language code
 //  * prefpage      : Integer (optional), section in the preferences to insert the widget:
 //                     0 : User profile         User profile
 //                     1 : Skin                 Appearance
 //                     2 : Math                 Date and Time
 //                     3 : Files                Editing
 //                     4 : Date and time        Recent Changes
 //                     5 : Editing              Watchlist
 //                     6 : Recent changes       Search Options
 //                     7 : Watchlist            Misc
 //                     8 : Search               Gadgets
 //                     9 : Misc
 //
 // Access keys through JSconfig.keys[name]
 //
 registerKey : function( name, default_value, description, prefpage )
 {
  if( typeof JSconfig.keys[name] == 'undefined' ) 
   JSconfig.keys[name] = default_value;
  else {
   // all cookies are read as strings, 
   // convert to the type of the default value
   switch( typeof default_value )
   {
    case 'boolean' : JSconfig.keys[name] = ( JSconfig.keys[name] == 'true' ); break;
    case 'number'  : JSconfig.keys[name] = JSconfig.keys[name]/1; break;
   }
  }

  JSconfig.meta[name] = { 
   'description' : 
    description[wgUserLanguage] || description.en || 
    ( typeof(description) == "string" && description ) || 
    "<i>en</i> translation missing", 
   'page' : prefpage || 0, 'default_value' : default_value };

  // if called after setUpForm(), we'll have to add an extra input field
  if( JSconfig.prefsTabs ) JSconfig.addPrefsInput( name );
 },

 readCookies : function()
 {
  var cookies = document.cookie.split("; ");
  var p =JSconfig.prefix.length;
  var i;

  for( var key in cookies )
  {
   if( cookies[key].substring(0,p) == JSconfig.prefix )
   {
    i = cookies[key].indexOf('=');
    //alert( cookies[key] + ',' + key + ',' + cookies[key].substring(p,i) );
    JSconfig.keys[cookies[key].substring(p,i)] = cookies[key].substring(i+1);
   }
  }
 },

 writeCookies : function()
 {
  var expdate = new Date();
  expdate.setTime(expdate.getTime()+1000*60*60*24*3650);  // expires in 3560 days
  for( var key in JSconfig.keys )
   document.cookie = JSconfig.prefix + key + '=' + JSconfig.keys[key] + '; path=/; expires=' + expdate.toUTCString();
 },

 evaluateForm : function()
 {
  var w_ctrl,wt;
  //alert('about to save JSconfig');
  for( var key in JSconfig.meta ) {
   w_ctrl = document.getElementById( JSconfig.prefix + key )
   if( w_ctrl ) 
   {
    wt = typeof JSconfig.meta[key].default_value;
    switch( wt ) {
     case 'boolean' : JSconfig.keys[key] = w_ctrl.checked; break;
     case 'string' : JSconfig.keys[key] = w_ctrl.value; break;
    }
   }
  }

  JSconfig.writeCookies();
  return true;
 },

 prefsTabs : false,

 setUpForm : function()
 { 
  var prefChild = document.getElementById('preferences');
  if( !prefChild ) return;
  prefChild = prefChild.childNodes;

  //
  // make a list of all preferences sections
  //
  var tabs = new Array;
  var len = prefChild.length;
  for( var key = 0; key < len; key++ ) {
   if( prefChild[key].tagName &&
       prefChild[key].tagName.toLowerCase() == 'fieldset' ) 
    tabs.push(prefChild[key]);
  }
  JSconfig.prefsTabs = tabs;

  //
  // Create Widgets for all registered config keys
  //
  for( var key in JSconfig.meta ) JSconfig.addPrefsInput(key);

  addEvent(document.getElementById('preferences').parentNode, 'submit', JSconfig.evaluateForm );
 },

 addPrefsInput : function( key ) {
  var w_div = document.createElement( 'DIV' );

  var w_label = document.createElement( 'LABEL' );
  var wt = typeof JSconfig.meta[key].default_value;
  switch ( wt ) {
   case 'boolean':
    JSconfig.meta[key].description = " " + JSconfig.meta[key].description;
    break;
   case 'string': default:
    JSconfig.meta[key].description += ": ";
    break;
  }
  w_label.appendChild( document.createTextNode( JSconfig.meta[key].description ) );
  w_label.htmlFor = JSconfig.prefix + key;

  var w_ctrl = document.createElement( 'INPUT' );
  w_ctrl.id = JSconfig.prefix + key;

  // before insertion into the DOM tree
  switch( wt ) {
   case 'boolean':
    w_ctrl.type = 'checkbox';
    w_div.appendChild( w_ctrl );
    w_div.appendChild( w_label );
    break;
   case 'string': default:
    w_ctrl.type = 'text';
    w_div.appendChild( w_label );
    w_div.appendChild( w_ctrl );
    break;
  }

  JSconfig.prefsTabs[JSconfig.meta[key].page].appendChild( w_div );
  
  // after insertion into the DOM tree
  switch( wt ) {
   case 'boolean' : w_ctrl.defaultChecked = w_ctrl.checked = JSconfig.keys[key]; break;
   case 'string' : w_ctrl.defaultValue = w_ctrl.value = JSconfig.keys[key]; break;
  }
 }
};

JSconfig.readCookies();
if( wgNamespaceNumber == -1 && wgCanonicalSpecialPageName == "Preferences" )
 addOnloadHook(JSconfig.setUpForm);
/** extract a URL parameter from the current URL **********
 * From [[en:User:Lupin/autoedit.js]]
 *
 * paramName  : the name of the parameter to extract
 * url        : optional URL to extract the parameter from, document.location.href if not given.
 *
 * Local Maintainer: [[User:Dschwen]], [[User:Lupo]]
 */

function getParamValue( paramName, url) 
{
 if (typeof (url) == 'undefined' || url === null) url = document.location.href;
 var cmdRe=RegExp( '[&?]' + paramName + '=([^&#]*)' ); // Stop at hash
 var m=cmdRe.exec(url);
 if (m && m.length > 1) return decodeURIComponent(m[1]);
 return null;
}

/** &withJS= URL parameter *******
 * Allow to try custom scripts on the MediaWiki namespace without
 * editing [[Special:Mypage/monobook.js]]
 *
 * Maintainer: [[User:Platonides]], [[User:Lupo]]
 */
var extraJS = getParamValue("withJS"); // Leave here for backwards compatibility
(function (extraJS) {
 if (!extraJS) return;
 if (extraJS.match("^MediaWiki:[^&<>=%#]*\\.js$")) // Disallow some characters in file name
  importScript (extraJS);
 else {
  // Dont use alert but the jsMsg system. Run jsMsg only once the DOM is ready.
  addOnloadHook (function () {
   jsMsgAppend (document.createTextNode (extraJS + " javascript not allowed to be loaded."),'error');
  });
 }
})(extraJS);
/** Attach (or remove) an Event to a specific object **********
 * Cross-browser event attachment (John Resig)
 * http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
 *
 * obj  : DOM tree object to attach the event to
 * type : String, event type ("click", "mouseover", "submit", etc.)
 * fn   : Function to be called when the event is triggered (the ''this''
 *        keyword points to ''obj'' inside ''fn'' when the event is triggered)
 *
 * Local Maintainer: [[User:Dschwen]]
 */
function addEvent( obj, type, fn )
{
 if (obj.addEventListener)
  obj.addEventListener( type, fn, false );
 else if (obj.attachEvent)
 {
  obj["e"+type+fn] = fn;
  obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
  obj.attachEvent( "on"+type, obj[type+fn] );
 }
}
function removeEvent( obj, type, fn )
{
 if (obj.removeEventListener)
  obj.removeEventListener( type, fn, false );
 else if (obj.detachEvent)
 {
  obj.detachEvent( "on"+type, obj[type+fn] );
  obj[type+fn] = null;
  obj["e"+type+fn] = null;
 }
}
/** Extra toolbar options ***********
 * Append custom buttons to the edit mode toolbar. 
 * This is a modified copy of a script by User:MarkS for extra features added by User:Voice of All.
 * This is based on the original code on Wikipedia:Tools/Editing tools
 * To disable this script, add <code>mwCustomEditButtons = [];<code> to [[Special:Mypage/monobook.js]]
 *  
 *  Maintainers: [[User:MarkS]]?, [[User:Voice of All]], [[User:R. Koot]]
 */
if (mwCustomEditButtons) {
  mwCustomEditButtons.push({
    "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png",
    "speedTip": "Redirect",
    "tagOpen": "#REDIRECT [[",
    "tagClose": "]]",
    "sampleText": "Insert text"
  });
}

/***** Edittools ********
 * Formatting buttons for special characters below the edit field
 * Also enables these buttons on any textarea or input field on
 * the page. Moved here from Monobook.js on 2009-09-09.
 *
 * Maintainers: [[User:Lupo]]
 */
var load_edittools = true; // Legacy...
importScript('MediaWiki:Edittools.js');

//
// Collapsible tables
//
importScript('MediaWiki:CollapsibleTables.js');
importScript('MediaWiki:CollapsibleTemplates.js');

/**** ImageAnnotator ******
 * Globally enabled per
 * http://commons.wikimedia.org/w/index.php?title=Commons:Village_pump&oldid=26818359#New_interface_feature
 *
 * Maintainer: [[User:Lupo]]
 ****/

if (wgNamespaceNumber != -1 && wgAction && (wgAction == 'view' || wgAction == 'purge')) {
  // Not on Special pages, and only if viewing the page
  if (typeof (ImageAnnotator_disable) == 'undefined' || !ImageAnnotator_disable) {
    // Don't even import it if it's disabled.
    importScript ('MediaWiki:Gadget-ImageAnnotator.js');
  }
}

/**** Special:Upload enhancements ******
 * moved to [[MediaWiki:Upload.js]]
 * 
 *  Maintainer: [[User:Lupo]]
 ****/
JSconfig.registerKey('UploadForm_loadform', true, 
 {
  'bg': 'Използване на логиката на новия формуляр за качвания',
  'en': 'Use new upload form logic', // default
  'mk': 'Искористете ја логиката на новиот образец за подигнување',
  'ru': 'Использовать новую логику формы загрузки'
 }, 3);
JSconfig.registerKey('UploadForm_newlayout', true, 
 {
  'bg': 'Използване на облика на новия формуляр за качвания',
  'en': 'Use new upload form layout', // default
  'mk': 'Искористете го рувото на новиот образец за подигнување',
  'ru': 'Использовать новый интерфейс формы загрузки'
 }, 3);

function enableNewUploadForm ()
{
  var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/);
  if (match) {
    var webKitVersion = parseInt(match[1]);
    if (webKitVersion < 420) return; // Safari 2 crashes hard with the new upload form...
  }

  // honor JSConfig user settings
  if( !JSconfig.keys['UploadForm_loadform'] ) return;

  importScript( 'MediaWiki:UploadForm.js' );
}

if (wgPageName == 'Special:Upload') 
{
 importScript( 'MediaWiki:Upload.js' );
 // Uncomment the following line (the call to enableNewUploadForm) to globally enable the
 // new upload form. Leave the line *above* (the include of MediaWiki:Upload.js) untouched;
 // that script provides useful default behavior if the new upload form is disabled or
 // redirects to the old form in case an error occurs.
 enableNewUploadForm ();
}

// We may be running MediaWiki:UploadForm.js on this site. The following script changes the
// "reupload" links on image pages to go to the basic form.
if (wgNamespaceNumber == 6) importScript ('MediaWiki:UploadFormLinkFixer.js');
/**** QICSigs ******
 * Fix for the broken signatures in gallery tags
 * needed for [[COM:QIC]]
 *
 *  Maintainers: [[User:Dschwen]]
 ****/
if( wgPageName == "Commons:Quality_images_candidates/candidate_list" && wgAction == "edit" )
{
 importScript( 'MediaWiki:QICSigs.js' );
}

/**** VICValidate ******
 * Some basic form validation for creating new Valued image nominations
 * needed for [[COM:VIC]]
 *
 *  Maintainers: [[User:Dschwen]]
 ****/
if( wgPageName == "Commons:Valued_image_candidates" && wgAction == "view" )
{
 importScript( 'MediaWiki:VICValidate.js' );
}
/***** subPagesLink ********
 * Adds a link to subpages of current page
 *
 *  Maintainers: [[:he:משתמש:ערן]], [[User:Dschwen]]
 *
 *  JSconfig items: bool JSconfig.subPagesLink
 *                       (true=enabled (default), false=disabled)
 ****/
var subPagesLink =
{ 
 //
 // Translations of the menu item
 //
 i18n :
 {
  'bg': 'Подстраници',
  'ca': 'Subpàgines',
  'cs': 'Podstránky',
  'de': 'Unterseiten',
  'en': 'Subpages',    // default
  'et': 'Alamlehed',
  'eo': 'Subpaĝoj',
  'eu': 'Azpiorrialdeak',
  'es': 'Subpáginas',
  'fi': 'Alasivut',
  'fr': 'Sous-pages',
  'gl': 'Subpáxinas',
  'he': 'דפי משנה',
  'hr': 'Podstranice',
  'it': 'Sottopagine',
  'is': 'Undirsíður',
  'ko': '하위 문서 목록',
  'mk': 'Потстраници',
  'nl': "Subpagina's",
  'no': 'Undersider',
  'pl': 'Podstrony',
  'ru': 'Подстраницы'
 },

 install: function()
 {
  // honor user configuration
  if( !JSconfig.keys['subPagesLink'] ) return;

  if ( document.getElementById("t-whatlinkshere") 
       &&  wgNamespaceNumber != -2   // Media: (upcoming)
       &&  wgNamespaceNumber != -1   // Special:
       && wgNamespaceNumber != 6     // Image:
       &&  wgNamespaceNumber != 14   // Category:
     )
  {
   var subpagesText = subPagesLink.i18n[wgUserLanguage] || subPagesLink.i18n['en'];
   var subpagesLink = wgArticlePath.replace('$1','Special:Prefixindex/' + wgPageName +'/');

   addPortletLink( 'p-tb', subpagesLink, subpagesText, 't-subpages' );
  }
 }
}
JSconfig.registerKey('subPagesLink', true, 
 {
  'bg': 'Показване на връзката Подстраници в менюто с инструменти',
  'cs': 'Zobrazovat v panelu nástrojů odkaz Podstránky',
  'en': 'Show a Subpages link in the toolbox', // default
  'mk': 'Покажи врска до потстраниците во алатникот',
  'pl': 'Pokaż w panelu bocznym link do podstron',
  'ru': 'Показывать ссылку на подстраницы в меню инструментов'
 }, 7);
addOnloadHook(subPagesLink.install);
/***** new os_createContainer ********
 * make the width of the search suggest window customizable
 *
 *  Maintainers: [[User:Dschwen]]
 ****/

// Translations of the message in the user preferences
if( typeof os_createContainer != 'undefined' ) {
  JSconfig.registerKey('os_suggest_width', "", 
   {
    'bg': 'Ширина на падащото меню с AJAX предположения',
    'cs': 'Šířka AJAXového napovídače',
    'en': 'Custom AJAX suggestion box width', // default
    'mk': 'Широчина на кутијата со предлози со AJAX',
    'ru': 'Ширина выпадающей AJAX-подсказки'
   }, 6);
  var old_os_createContainer = os_createContainer;
  os_createContainer = function( r) 
  {
   var c = old_os_createContainer( r );
   var w = JSconfig.keys['os_suggest_width'];
   if( w != "" ) c.style.width = w + "px";
   return c;
  }
}
/***** gallery_dshuf_prepare ********
 * prepare galleries which are surrounded by <div class="dshuf"></div>
 * for shuffling with dshuf (see below).
 *
 *  Maintainers: [[User:Dschwen]]
 ****/
function gallery_dshuf_prepare()
{
 var tables = document.getElementsByTagName("table");
 var divsorig, divs, newdiv, parent, j, i;

 for ( i = 0; i < tables.length; i++)
  if ( tables[i].className == 'gallery' && 
       tables[i].parentNode.className == 'dshuf' )
  {
   divsorig = tables[i].getElementsByTagName( 'div' );
   divs = [];
   for ( j = 0; j < divsorig.length; j++) divs.push(divsorig[j]);
   for ( j = 0; j < divs.length; j++)
    if ( divs[j].className == 'gallerybox' )
    {
     newdiv = document.createElement( 'DIV' );
     newdiv.className = 'dshuf dshufset' + i;
     while( divs[j].childNodes.length > 0 )
      newdiv.appendChild( divs[j].removeChild(divs[j].firstChild) );
     divs[j].appendChild( newdiv );
    }
  }
}
addOnloadHook(gallery_dshuf_prepare);
/***** dshuf ********
 * shuffles div elements with the class dshuf and 
 * common class dshufsetX (X being an integer)
 * taken from http://commons.wikimedia.org/w/index.php?title=MediaWiki:Common.js&oldid=7380543
 *
 *  Maintainers: [[User:Gmaxwell]], [[User:Dschwen]]
 ****/
function dshuf(){
 var shufsets = {};
 var rx = new RegExp('dshuf'+'\\s+(dshufset\\d+)', 'i');
 var divs = document.getElementsByTagName("div");
 var i = divs.length;
 while( i-- )
 {
  if( rx.test(divs[i].className) )
  {
   if ( typeof shufsets[RegExp.$1] == "undefined" )
   { 
    shufsets[RegExp.$1] = {};
    shufsets[RegExp.$1].inner = [];
    shufsets[RegExp.$1].member = [];
   }
   shufsets[RegExp.$1].inner.push( { key:Math.random(), html:divs[i].innerHTML } );
   shufsets[RegExp.$1].member.push(divs[i]);
  }
 }

 for( shufset in shufsets )
 {
  shufsets[shufset].inner.sort( function(a,b) { return a.key - b.key; } );
  i = shufsets[shufset].member.length;
  while( i-- )
  {
   shufsets[shufset].member[i].innerHTML = shufsets[shufset].inner[i].html;
   shufsets[shufset].member[i].style.display = "block";
  }
 }
}
addOnloadHook(dshuf);
//Adds a dismissable notice to Special:Watchlist
//Useful to use instead of the sitenotice for messages only
//relevant to registered users.
if( wgCanonicalSpecialPageName == "Watchlist" ) importScript( 'MediaWiki:Common.js/WatchlistNotice.js' );

/***** localizeSignature ********
 * localizes the signature on Commons with the string in the user's preferred language
 *
 * Maintainer: [[User:Slomox]]
 ****/
function localizeSignature() {
 var talkTextLocalization = { ca: 'Discussió', cs: 'diskuse', de: 'Diskussion', fr: 'd', nds: 'Diskuschoon' };
 var talkText = talkTextLocalization[wgUserLanguage];
 if (!talkText) return;
 var spans=document.getElementsByTagName("span");
 for (var i = 0; i < spans.length; i++) {
  if ( spans[i].className == 'signature-talk' ) {
   spans[i].innerHTML = talkText;
  }
 }
}
addOnloadHook(localizeSignature);

// Load POTY gallery enhancements
function POTYenhancements() {
    var g = document.getElementById('poty-voting')
    if (g && wgUserName) {
        uri = wgScript + '?title=User:Kalan/poty.js&action=raw&ctype=text/javascript&go=' + g.className.match(/version-\d+/)[0]
        importScriptURI(uri)
    }
}

/*addOnloadHook(POTYenhancements)*/

//
// Add "Nominate for Deletion" to toolbar ([[MediaWiki talk:Quick-delete-code.js]])
//
importScript('MediaWiki:Quick-delete-code.js');

//
// Import usergroup-specific stylesheet, only for admins atm
//
for( var key in wgUserGroups )
{
   if (wgUserGroups[key] =="sysop")
   {
       importStylesheet("MediaWiki:Admin.css");
   } 
   else if (wgUserGroups[key] =="filemover")
   {
       importStylesheet("MediaWiki:Filemover.css");
   }
}

// Ajax Translation of /lang links, see [[MediaWiki:AjaxTranslation.js]]
// Maintainer: [[User:ערן]]
importScript('MediaWiki:AjaxTranslation.js');

// SVG images: adds links to rendered PNG images in different resolutions
function SVGThumbs() {
	var file = document.getElementById("file"); // might fail if MediaWiki can't render the SVG
	if (file && wgIsArticle && wgTitle.match(/\.svg$/i)) {
		var thumbu = file.getElementsByTagName('IMG')[0].src;
		if(!thumbu) return;
 
		function svgAltSize( w, title) {
			var path = thumbu.replace(/\/\d+(px-[^\/]+$)/, "/" + w + "$1");
			var a = document.createElement("A");
			a.setAttribute("href", path);
			a.appendChild(document.createTextNode(title));
			return a;
		}
 
		var p = document.createElement("p");
		p.className = "SVGThumbs";
		p.appendChild(document.createTextNode("This image rendered as PNG in other sizes"+": "));
		var l = [200, 500, 1000, 2000];
                for( var i = 0; i < l.length; i++ ) {
			p.appendChild(svgAltSize( l[i], l[i] + "px"));
			if( i < l.length-1 ) p.appendChild(document.createTextNode(", "));
                }
		p.appendChild(document.createTextNode("."));
		var info = getElementsByClassName( file.parentNode, 'div', 'fullMedia' )[0];
		if( info ) info.appendChild(p);
	}
};
addOnloadHook( SVGThumbs );

//Language & skin specific JavaScript and CSS.
//may be useful for renaming tab in main page in every language.
importScript('MediaWiki:Common.js/' + wgUserLanguage);
importStylesheet('MediaWiki:' + skin + '.css/' + wgUserLanguage);

/* Quick-adding a command CommonsDelinker's command line */
/* Local maintainer: [[User:Kwj2772]] */
importScript('MediaWiki:CommonsDelinker.js');

/*Automatic language selection using javascript*/
importScript('MediaWiki:Multilingual description.js/public')

/*External click logging see http://lists.wikimedia.org/pipermail/commons-l/2009-November/005202.html for details*/
// deactivated as it carelessly overwrites the click handlers. needs fixing.
//importScript('User:Magnus Manske/log external link clicks.js');

// per talkpage It will be useful to normalize date used by script (e.g. Flickrreview script)
function getISODate() { // UTC
    var date = new Date();
    var dd = date.getUTCDate();
    if (dd < 10) { dd = "0"+ dd.toString(); }
    var mm = date.getUTCMonth()+1;
    if (mm < 10) { mm = "0"+ mm.toString(); }
    var YYYY = date.getUTCFullYear();
    ISOdate = YYYY + '-' + mm + '-' + dd
    return (ISOdate);
}

// Sitenotice translation for all skins, not dependent on jQuery
addOnloadHook (function () {
  var siteNotice = document.getElementById ('siteNotice');
  if (!siteNotice) return;
  var firstPara = siteNotice.getElementsByTagName ('p');
  if (!firstPara || firstPara.length == 0) return;
  firstPara = firstPara[0];
  var toReplace = firstPara.parentNode;
  if (!toReplace) return; // Paranoia.
  var s = document.createElement ('script');
  s.src = wgServer + wgScriptPath
        + '/api.php?action=parse&pst&text={{MediaWiki:Sitenotice-translation}}&uselang=' + wgUserLanguage
        + '&format=json&callback=window.translateSitenotice&maxage=3600&smaxage=3600';
  s.type = 'text/javascript';
  var head = document.getElementsByTagName('head')[0];

  function doTranslation (json) {
    if (json && json.parse && json.parse.text) {
      while (toReplace.firstChild) toReplace.removeChild (toReplace.firstChild);
      toReplace.innerHTML = json.parse.text['*'];
    }
    head.removeChild (s);
  }

  window.translateSitenotice = function (json) { doTranslation (json); };
  head.appendChild (s);
});

// Hide title on all main pages and change the "Gallery" tab text to "Main page" (or equivalent
// in user's language) on all main pages and their talk pages
if (wgNamespaceNumber == 0 || wgNamespaceNumber == 1) {
    importScript('MediaWiki:MainPages.js');
}

//
// Change target of add-section links
// See Template:ChangeSectionLink
//
addOnloadHook(function () 
{
 var changeAddSection = document.getElementById('jsChangeAddSection')
 if (changeAddSection)
 {
  var addSection = document.getElementById('ca-addsection');
  if (addSection)
  {
   addSection.firstChild.setAttribute('href', wgScript + 
    '?action=edit&section=new&title=' + encodeURIComponent(
    changeAddSection.getAttribute('title')));
  }
 }
});


/**
 * Add links to GlobalUsage and the CommonsDelinker log to file deletion log entries.
 *
 * Maintainer(s): [[User:Ilmari Karonen]]
 */
addOnloadHook(function () {
    // guard against multiple inclusion
    if (window.commonsDelinkerLogLinksAdded) return;
    window.commonsDelinkerLogLinksAdded = true;

    var content = document.getElementById("bodyContent") ||       // monobook & vector skins
                  document.getElementById("mw_contentholder") ||  // modern skin
                  document.getElementById("article");             // classic skins
    if (!content) return;

    var deletions = getElementsByClassName(content, "li", "mw-logline-delete");
    if (!deletions || !deletions.length) return;

    // create the links in advance so we can cloneNode() them quickly in the loop
    var guLink = document.createElement("a");
    guLink.className = "delinker-log-globalusage";
    guLink.appendChild(document.createTextNode("global usage"));

    var cdLink = document.createElement("a");
    cdLink.className = "delinker-log-link extiw";
    cdLink.appendChild(document.createTextNode("delinker log"));
            
    var span = document.createElement("span");
    span.className = "delinker-log-links";
    span.appendChild(document.createTextNode(" ("));
    span.appendChild(guLink);
    span.appendChild(document.createTextNode("; "));
    span.appendChild(cdLink);
    span.appendChild(document.createTextNode(")"));

    for (var i = 0; i < deletions.length; i++) {
        var match = null;
        for (var elem = deletions[i].firstChild; elem; elem = elem.nextSibling) {
            if (!elem.tagName || elem.tagName.toLowerCase() != 'a') continue;
            if (/mw-userlink/.test(elem.className)) continue;
            match = /^File:(.*)/.exec(getInnerText(elem));
            if (match) break;
        }
        if (match) {
            var filename = encodeURIComponent(match[1].replace(/ /g, "_"));
            guLink.href = wgScript + "?title=Special:GlobalUsage&target=" + filename;
            guLink.title = "Current usage of " + match[1] + " on all Wikimedia projects";
            cdLink.href = "http://toolserver.org/~delinker/index.php?image=" + filename;
            cdLink.title = "CommonsDelinker log for " + match[1];
            deletions[i].appendChild(span.cloneNode(true));
        }
    }
});


//</source>

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

/* MediaWiki:Monobook.js */
/* <pre><nowiki> */

/* Устарело. Используйте [[MediaWiki:common.js]] */

/* 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-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-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');
*/

// ============================================================
// BEGIN Dynamic Navigation Bars (experimantal)
// This is used in Template:Showhide and similar.
// Taken from http://en.wikipedia.org/wiki/MediaWiki:Monobook.js
 function addLoadEvent(func) 
{
  if (window.addEventListener) 
    window.addEventListener("load", func, false);
  else if (window.attachEvent) 
    window.attachEvent("onload", func);
}

// 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 = 0;


// 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
// ============================================================

// ============================================================
// This code should make the header on the Main Page go away.
// Taken from Wikipedia

var mpTitle = "Main Page";
var isMainPage = (/(title=|\/wiki\/)([Tt]alk:|)[Mm]ain[ _][Pp]age/.test(document.location));
var isMainPageFront = (document.title.substr(0, document.title.lastIndexOf(" - ")) == mpTitle);
var isDiff = (document.location.search && (document.location.search.indexOf("diff=") != -1 || document.location.search.indexOf("oldid=") != -1));

if (isMainPage) 
{

if (isMainPageFront && !isDiff)
{
document.write('<style type="text/css">/*<![CDATA[*/ #lastmod, #siteSub, #contentSub, h1.firstHeading { display: none !important; } /*]]>*/</style>');
}

var mpSmallEnabled;
var mpMinWidth = 700;

function mainPageTransform()
{
       if (isMainPage && document.getElementById('ca-nstab-main')) 
         {document.getElementById('ca-nstab-main').firstChild.innerHTML = 'Main Page';}
       if (((isMainPageFront && !isDiff) || /[\/=:]Main_Page/.test(document.location)) && document.getElementById('ca-nstab-main'))
        var mpContentEl = document.getElementById("bodyContent");
        var mpBrowseEl = document.getElementById("EnWpMpBrowse");
        var mpContainEl = document.getElementById("EnWpMpBrowseContainer");
        var mpMarginEl = document.getElementById("EnWpMpMargin");
        var mpEl = document.getElementById("EnWpMainPage");

        if (!mpContentEl || !mpBrowseEl || !mpContainEl || !mpMarginEl || !mpEl)
                return;

        if (!mpSmallEnabled && mpContentEl.offsetWidth < mpMinWidth)
        {
                mpContainEl.insertBefore(mpBrowseEl, mpContainEl.firstChild);
                mpBrowseEl.className = "EnWpMpBrowseBottom";
                mpMarginEl.style.marginRight = 0;
                mpSmallEnabled = true;
        }
        else if (mpSmallEnabled && mpContentEl.offsetWidth > mpMinWidth)
        {
                mpEl.insertBefore(mpBrowseEl, mpEl.firstChild);
                mpBrowseEl.className = "EnWpMpBrowseRight";
                mpMarginEl.style.marginRight = "13.8em";
                mpSmallEnabled = false;
        }
}

var onloadFuncts = [ mainPageTransform ];

if (window.addEventListener) 
  window.addEventListener("resize", mainPageTransform, false);
else if (window.attachEvent) 
  window.attachEvent("onresize", mainPageTransform);

}

// ============================================================

/* Customized versions of several routines used by the sortable table feature
   These functions (ts_*) will override the default versions found in wikibits.js
   Feature include:
   - sorting of tables with rowspan or colspan
   - descending order allowed as column default
   - specify format of column data
*/

function ts_makeSortable(table) {
	ts_setMultiRows(table);
	var headRow = new Array();
	if (table.rows && table.rows.length > 0) {
		if (table.tHead && table.tHead.rows.length > 0) {
			headRow = table.tHead.rows;
		} else {
			for (var j=0; j<table.rows.length; j++) {
				if (table.rows[j].baserow+j>0)
					break;
				headRow.push (table.rows[j]);
			}
		}
	}
	if (!headRow.length) return;
	table.rowStart = headRow.length;

	// We have a first row: assume it's the header, and make its contents clickable links
        for (var j=0; j<headRow.length; j++) {
		for (var i=0; i<headRow[j].sortrowd.length; i++) {
			jcell = headRow[j].sortrowd[i]+j;
			icell = headRow[j].sortcol[i];
			var cell = headRow[jcell].cells[icell];
	                var spans = getElementsByClassName(cell, "span", "sortarrow");
			if (cell.colSpan == 1 &&
                            (" "+cell.className+" ").indexOf(" unsortable ") == -1 &&
                            spans.length==0) {
				cell.basecol = i;
                                if (cell.innerHTML.search(/<\s*br\s*\/?>\s*$/)<0) {
                                    cell.innerHTML += '<br>';
                                }
				cell.innerHTML += '<a href="#" class="sortheader" onclick="ts_resortTable(this);return false;"><span class="sortarrow"><img src="' + ts_image_path + ts_image_none + '" alt=&darr;"/></span></a>';
			}
		}
	}

	for (var j=0; j<table.rows.length; j++) {
		table.rows[j].setAttribute('origindex', j);
	}

	if (ts_alternate_row_colors)
		ts_alternate(table);
}

/* New function: determine layout of tables with rowspans or colspans */
function ts_setMultiRows (table) {
	var ieff = 0;
	var imax = 0;
	var jbase = 0;
	var jmax = 0;
	var src_i = new Array();
	var src_j = new Array();
	for (var j=0; j<table.rows.length; j++) {
		jmax = Math.max(jmax, j);
		if (!src_j[j]) {
			src_j[j] = new Array();
			src_i[j] = new Array();
		}

		for (var i = ieff = 0; i<table.rows[j].cells.length; ieff++, i++) {
			while (!isNaN(src_j[j][ieff]))
				ieff++;
			var cell = table.rows[j].cells[i];
			imax = Math.max(imax, ieff+cell.colSpan);
			jmax = Math.min(Math.max(jmax, j+cell.rowSpan-1),table.rows.length-1);
			for (var jd=0; jd<cell.rowSpan; jd++) {
				if (!src_j[j+jd]) {
					src_j[j+jd] = new Array();
					src_i[j+jd] = new Array();
				}
				for (id=0; id<cell.colSpan; id++) {
					src_i[j+jd][ieff+id] = i;
					src_j[j+jd][ieff+id] = j;
				}
			}
		}
		if (jmax == j) {
			var full;
			if (jbase==j && imax>1 && table.rows[j].cells.length==1 && table.rows[j].cells[0].colspan==imax) {
				full = true;
			}
			else {
				full = false;
			}
			var sortrow = -1;
			for (var ja=jbase; ja<=jmax; ja++) {
				table.rows[ja].fullcolspan = full;
				table.rows[ja].baserow = jbase-ja;
				table.rows[ja].sortrowd = new Array();
				table.rows[ja].sortcol = new Array();
				if ((" "+table.rows[ja].className+" ").indexOf(" sort_keyrow ") != -1) {
					sortrow = ja;
				}
			}
			for (var i=0; i<imax; i++) {
				var csortrow = -1;
				if (sortrow>=0 &&
                                    !isNaN(src_j[sortrow][i]) &&
                                    table.rows[src_j[sortrow][i]].cells[src_i[sortrow][i]].colSpan==1) {
					csortrow = sortrow;
				}
				for (var ja=jbase; ja<=jmax; ja++) {
					if (csortrow>=0) break;
					if (!isNaN(src_j[ja][i]) &&
                                            table.rows[src_j[ja][i]].cells[src_i[ja][i]].colSpan==1) {
						csortrow = j;
					}
				}
				for (var ja=jbase; ja<=jmax; ja++) {
					if (csortrow>=0) {
						table.rows[ja].sortrowd[i] = src_j[csortrow][i]-ja;
						table.rows[ja].sortcol[i] = src_i[csortrow][i];
					}
					else {
						table.rows[ja].sortrowd[i] = 0;
						table.rows[ja].sortcol[i] = 0;
					}
				}
			}	
			jbase = j+1;
		}
	}
}

function ts_resortTable(lnk) {
	// get the span
	var span = lnk.getElementsByTagName('span')[0];

	var td = lnk.parentNode;
	var tr = td.parentNode;
	var column = td.basecol;

	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.rowStart;

	sortfn = ts_sort_caseinsensitive;
	if ((" "+td.className+" ").indexOf(" sort_num ") != -1) {
		sortfn = ts_sort_numeric;
	}
	else if ((" "+td.className+" ").indexOf(" sort_date ") != -1) {
		sortfn = ts_sort_date;
	}
	else if ((" "+td.className+" ").indexOf(" sort_str ") == -1) {
		var itm = "";
		for (var j = rowStart; j < table.rows.length; j++) {
			if (table.rows[j].cells.length > column) {
				var sortrow = table.rows[j].sortrowd[column] + j;
				var sortcol = table.rows[j].sortcol[column];
				itm = ts_getInnerText(table.rows[sortrow].cells[sortcol]);
				itm = itm.replace(/^[\s\xa0]+/, "").replace(/[\s\xa0]+$/, "");
				if (itm != "") break;
			}
		}

		itm = ts_firstWord(itm);
		if (itm.match(/^\d\d[\/\.\-][a-zA-z]{3}[\/\.\-]\d{2,4}$/))
			sortfn = ts_sort_date;
		else if (itm.match(/^\d\d[\/\.\-]\d\d[\/\.\-]\d{2,4}$/))
			sortfn = ts_sort_date;
		else if (itm.match(/^[\u00a3$\u20ac\u00a5]/)) // pound dollar euro yen
			sortfn = ts_sort_numeric;
		else if (itm.match(/^[\-\+]?[\d\.\,]+([eE][\-\+]?\d+)?\%?$/))
			sortfn = ts_sort_numeric;
	}

	var sortdir = 'down';
	var reverse = 0;
	if ((" "+td.className+" ").indexOf(" sort_desc ") != -1) {
		// order for default=descending is 'down', then 'up', then 'none'
		if (span.getAttribute("sortdir") == 'down') {
			sortdir = 'up';
		}
		else if (span.getAttribute("sortdir") == 'up')
			sortdir = 'none';
		else
			sortdir = 'down';
	}
	else {
		//standard order is 'up', then 'down', then 'none'
		if (span.getAttribute("sortdir") == 'down')
			sortdir = 'none';
		else if (span.getAttribute("sortdir") == 'up') {
			sortdir = 'down';
		}
		else
			sortdir = 'up';
	}

	var newRows = new Array();

	if (sortdir == 'none')
		sortfn = ts_sort_numeric;
		
	for (var j=rowStart ; j < table.rows.length; j++) {
		var row = table.rows[j];
		if (sortdir == 'none')
			var keyText = row.getAttribute('origindex');
		else {
			var sortrow = table.rows[j].sortrowd[column] + j;
			var sortcol = table.rows[j].sortcol[column];
			var keyText = ts_getInnerText(table.rows[sortrow].cells[sortcol]);
		}
		var oldIndex = ((sortdir == 'down') ? -j : j);

		newRows[newRows.length] = new Array(row, keyText, oldIndex);
	}
	newRows.sort(sortfn);
        if (sortdir == 'down')
		newRows.reverse();

	var arrowHTML;
	if (sortdir == 'down')
		arrowHTML = '<img src="'+ ts_image_path + ts_image_down + '" alt="&darr;"/>';
	else if (sortdir == 'up')
		arrowHTML = '<img src="'+ ts_image_path + ts_image_up + '" alt="&uarr;"/>';
	else
		arrowHTML = '<img src="'+ ts_image_path + ts_image_none + '" alt="&darr;"/>';

	// 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 (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 that may be showing
	var spans = getElementsByClassName(table, "span", "sortarrow");
	for (var i=0; i<spans.length; i++) {
		spans[i].innerHTML = '<img src="'+ ts_image_path + ts_image_none + '" alt="&darr;"/>';
		spans[i].setAttribute('sortdir',"none");
	}
	span.innerHTML = arrowHTML;
	span.setAttribute('sortdir',sortdir);
	ts_alternate(table);
}

function ts_dateToSortKey(date) {
	if (date.match(/^\d\d[\/\.-][a-zA-z][a-zA-Z][a-zA-Z][\/\.-]\d{2,4}/)) {
		switch (date.substr(3,3).toLowerCase()) {
			case "jan": var month = "01"; break;
			case "feb": var month = "02"; break;
			case "mar": var month = "03"; break;
			case "apr": var month = "04"; break;
			case "may": var month = "05"; break;
			case "jun": var month = "06"; break;
			case "jul": var month = "07"; break;
			case "aug": var month = "08"; break;
			case "sep": var month = "09"; break;
			case "oct": var month = "10"; break;
			case "nov": var month = "11"; break;
			case "dec": var month = "12"; break;
			// default: var month = "00";
		}
		year = ts_yearToY2K(date.substr(7,4));		
		return year+month+date.substr(0,2);
	} else if (date.match(/^\d\d[\/\.-]\d\d[\/\.-]\d{2,4}/)) {
		year = ts_yearToY2K(date.substr(6,4));
		if (europeandate == false)
			return year+date.substr(0,2)+date.substr(3,2);
		else
			return year+date.substr(3,2)+date.substr(0,2);
	}
	return "00000000";
}

function ts_firstWord(string) {
	string = ''+string;
	var splitstring = string.split(" ");
	return splitstring[0];
}

function ts_parseFloat(num) {
	if (!num) return 0;
        var matches=num.match(/[\-\+]?\.?\d+[^\s]*/);
	if (!matches) return 0;
	num = matches[0];
	num = parseFloat(num.replace(/,/g, ""));
	return (isNaN(num) ? 0 : num);
}

function ts_alternate(table) {
	// Take object table and get all it's tbodies.
	var tableBodies = table.getElementsByTagName("tbody");
	// Loop through these tbodies
	for (var i = 0; i < tableBodies.length; i++) {
		// Take the tbody, and get all it's rows
		var tableRows = tableBodies[i].getElementsByTagName("tr");
		// Loop through these rows
		// Start at 1 because we want to leave the heading row untouched
		for (var j = 0, jv = -1; j < tableRows.length; j++) {
			// Only increment for visible rows and rows that are not grouped
			if (tableRows[j].style.display != 'none' && (isNaN(tableRows[j].baserow) || tableRows[j].baserow == 0))
				jv++;
			var oldClasses = tableRows[j].className.split(" ");
			var newClassName = "";
			for (var k = 0; k<oldClasses.length; k++) {
				if (oldClasses[k] != "" && oldClasses[k] != "even" && oldClasses[k] != "odd")
					newClassName += oldClasses[k] + " ";
			}
			// Check if j is even, and apply classes for both possible results
			tableRows[j].className = newClassName + (jv%2 == 0 ? "even" : "odd");
		}
	}
}

// importScript("MediaWiki:Multilingual description.js")

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