/*
 * Copyright (C) 2005 Stephen Ostermiller
 * http://ostermiller.org/contact.pl?regarding=Bookmarklets
 *
 * This bookmarklet is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This bookmarklet is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

/**
 * Highlight all the links on the page.  Mark those with a nofollow tag in yellow, and those without as pink.
 *
 * @name Highlight NoFollow
 *
 * @substitute document_links a
 * @substitute link_index b
 * @substitute some_link c
 * @substitute link_attributes d
 * @substitute attribute_index e
 * @substitute link_attribute f
 * @substitute has_nofollow g
 * @substitute has_href h
 * @substitute attribute_name i
 *
 * @compatible Firefox
 * @compatible Internet Explorer
 * @compatible Mozilla
 * @compatible Opera
 *
 * @category Meta
 *
 */
void(
    (function(){
        var document_links,link_index,some_link,link_attributes,attribute_index,link_attribute,has_nofollow,has_href,attribute_name;
        document_links=document.getElementsByTagName("a");
        for(link_index=0;link_index<document_links.length;link_index++){
            some_link=document_links[link_index];
            link_attributes=some_link.attributes;
            has_nofollow=false;
            has_href=false;
            for(attribute_index=0;attribute_index<link_attributes.length;attribute_index++){
                link_attribute=link_attributes[attribute_index];
                attribute_name=link_attribute.name.toLowerCase();
                if(attribute_name=="rel"&&link_attribute.value.toLowerCase().indexOf("nofollow")!=-1){
                    has_nofollow=true;
                }
                if(attribute_name=="href"){
                    has_href=true;
                }
            }
            if(has_href){
                some_link.style.backgroundColor=has_nofollow?"yellow":"pink";
                some_link.style.border="1px solid "+(has_nofollow?"red":"black");
                some_link.style.color="black";
            }
        }
    })()
)
