/* ================================================================================

 * USEFUL STUFF
 * Source: en:User:Raylu/monobook.js
 */

function addlilink(tabs, url, name, id, title, key) {
  var na = document.createElement('a');
  na.href = url;
  na.appendChild(document.createTextNode(name));
  var li = document.createElement('li');
  if(id) li.id = id;
  li.appendChild(na);
  tabs.appendChild(li);
  na.accesskey = key;
  var pref = 'alt-';
  if(((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1))
      || navigator.userAgent.toLowerCase().indexOf( 'mac' ) != -1 ) pref = 'control-';
  if(clientPC.indexOf('opera')!=-1) pref = 'shift-esc-';
  if(key && title) na.title = title + ' [' + pref + key + ']';
  else if(title) na.title = title;
  else if(key) na.title = '[' + pref + key + ']';
  return li;
}

function addTab(url, name, id, title, key) {
  var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
  addlilink(tabs, url, name, id, title, key);
}
/* ================================================================================
 * WIKIFY
 * Based on: Wikipedia:WikiProject User scripts/Tutorial
 */

function qwikifyIt() {
  document.editform.wpTextbox1.value = "{"+"{wikify}}\n\n" + document.editform.wpTextbox1.value;
  document.editform.wpSummary.value = "Added wikification template";
  document.editform.submit();
}

function addQwikify() {
  if (document.title.match("Editing ")
      && !document.title.match(" (section) - Wikipedia")
      && !document.title.match("Editing User talk:")) {
    addTab("javascript:qwikifyIt()", "wikify", "ca-wikify", "Mark for wikification", "");
  }
}
if (window.addEventListener) window.addEventListener("load", addQwikify, false); 
else if (window.attachEvent) window.attachEvent("onload", addQwikify);
/* ================================================================================
 * POPUPS
 * Source: Wikipedia:Tools/Navigation popups
 */

document.write('<script type="text/javascript" src="'
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

popupSubpopups = false;
popupRedlinkRemoval = true;
/* ================================================================================
 * ATLAS
 * Source: en:User:Dschwen/WikiMiniAtlas
 */
document.write('<script type="text/javascript" src="'
             + 'http://en.wikipedia.org/w/index.php?title=User:Dschwen/wikiminiatlas2.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
/* ================================================================================
 * ANTI-VANDAL TOOLBOX
 * Source: en:User:Kbh3rd/Vandal warning toolbox
 * Slightly edited version here: edited
 */
document.write('<script type="text/javascript" src="'
             + 'http://en.wikipedia.org/w/index.php?title=User:Inkuh/kbh3rd-whackamole.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
/* ================================================================================
 * EDIT COUNTER
 * Source: Wikipedia:Kate's Tool
 */

gsKateInsertBefore = 'pt-mycontris'; // leave blank to append after "logout"

function KateLink() {
  var user = document.getElementById('pt-userpage').firstChild.firstChild.data;
  
  var li = document.createElement('li');
  li.id = 'pt-kate';
  
  var a = document.createElement('a');
  a.appendChild(document.createTextNode('Edit count'));
  a.href = 'http://tools.wikimedia.de/~kate/cgi-bin/count_edits?dbname=enwiki&user=' + user;
  
  li.appendChild( a );
  
  if (! gsKateInsertBefore) { // append to end (right) of list
    document.getElementById('pt-logout').parentNode.appendChild(li);
  }
  else {
    var before = document.getElementById(gsKateInsertBefore);
    before.appendChild(li, before);
  }
}

if (window.addEventListener) window.addEventListener('load', KateLink, false);
else if (window.attachEvent) window.attachEvent ('onload', KateLink);