/**
 * Target attribute.
 * Version: 1.0
 *
 * Description:
 * This program simulates the behavior of the "target" attribute for
 * anchor tags, so that XHTML strict documents can validate successfully.
 *
 * The use of this script is strictly forbidden without prior written
 * consent. You must obtain permission before copying, modifying, 
 * redistributing, deriving or selling any part of this program.
 *
 * Copyright (c) 2006 HYPERZOID
 * All Rights Reserved
 */

function target() {
    // Browser doesn't support DOM 2.
    if (!document.getElementsByTagName) {
        return;
    }

    // Retrieve all <a> elements.
    var anchors = document.getElementsByTagName("a");

    // Add "target" attribute to each <a> element.
    for (var i = 0; i < anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute("href")) {
            switch (anchor.getAttribute("rel")) {
                case "blank":
                    anchor.target = "_blank";
                    break;
                case "parent":
                    anchor.target = "_parent";
                    break;
                case "self":
                    anchor.target = "_self";
                    break;
                case "top":
                    anchor.target = "_top";
                    break;
            }
        }
    }
}

