﻿
/**********************************************
 * disable_links_to_current_page.js
 * Javascript functions that convert any links
 * on the current page to the current page into
 * their childnode equivalents.
 * Almost completely based on the original work
 * designated by the header below.
 **********************************************/


/**********************************************
 * CLCP v2.1 Clear Links to Current Page
 * Jonathan Snook
 * This code is offered unto the public domain
 * http://www.snook.ca/jonathan/
 **********************************************/


window.onload = disableLinksToCurrentPage;


function disableLinksToCurrentPage()
{
  var a = document.getElementsByTagName("a");

  for(var i=0; i<a.length; i++)
  {
    if(a[i].href == window.location.href.split("#")[0])
    {
      removeNode(a[i]);
      i--;
    }
  }
}


function removeNode(n)
{
  if (n.hasChildNodes())
  {
    for(var i=0; i<n.childNodes.length; i++)
    {
      n.parentNode.insertBefore(n.childNodes[i].cloneNode(true), n);
    }
  }

  n.parentNode.removeChild(n);
}