



/*
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 = clearCurrentLink;

function clearCurrentLink(){
    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]);
}

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);
}

*/

/** 
 * De-obfuscate printed email addresses which are of the type: 
 * 
 * <span class="Obfuscated" title="some title"> 
 * some link text [ someone AT gmail DOT com ] 
 * <span> 
 * 
 * The braces around the address part are hard-wired here. That should 
 * probably be set by a param. Ditto for the "AT" & "DOT". 
 * 
 * @author brian ally, zijn digital 
 **/ 
jQuery.fn.deobfuscate = function() 
{ 
        return this.each(function() 
        { 
                var content = $(this).text(); 
                /* grab the part inside the braces, swap out placeholders, and trim 
                 */ 
                var obfuscated = content.match(/\[(.*)\]/); 
                var address = obfuscated[1] 
                        .replace(' AT ', '@') 
                        .replace(' DOT ', '.') 
                        .replace(/^\s+|\s+$/g, ''); 
                /* get everything before the braces and trim 
                 */ 
                var text = content.match(/.?[^[]+/); 
                text = (text[0] != content) 
                        ? text[0].replace(/^\s+|\s+$/g, '') 
                        : address;      // if there's no text part, use the address 
                var title = $(this).attr('title') || ''; 
                $(this).replaceWith($('<a href="mailto:' + address + '" title="' + 
title + '">' + text + '</a>')); 
        }); 
}; 
