/* Frames Bursting */
if(top.location != self.location){top.location=self.location;}

/* Fragment Highlight version 0.2 */        
(function () {
/* Indicates area that has been linked to if fragment identifiers have
 * been used. Especially useful in situations where a short fragment
 * is near the end of a page. */

    var fragHLed = '';
    var fragExclude = ('header');

    Array.prototype.search = function(myVariable) {
        for (x in this) {
            if (x == myVariable) {
                return true;
            }
        }
        return false;
    };

    /* Highlight link target if the visitor arrives at the page with a # */
    function fragHLload() {
        fragHL(location.hash.substring(1));
    }

    /* Highlight link target from an onclick event after unhighlighting the old one */
    function fragHL(frag) {
        if (fragHLed.length > 0) {
            var old_el = document.getElementById(fragHLed);
            if (old_el) {
                YAHOO.util.Dom.removeClass(old_el, 'fragment');
            }
        }
        if (frag.length > 0) {
            var new_el = document.getElementById(frag);
            if (new_el) {
                fragHLed = frag;
                YAHOO.util.Dom.addClass(new_el, 'fragment');
            }
        }
    }
    
	function fragHLLinkEventFactor (f){
		return function(){
			fragHL(f)
		};
	}

    /* Add onclick events to all <a> with hrefs that include a "#"  */

    function fragHLlink() {
        if (document.getElementsByTagName) {
            var an = document.getElementsByTagName('a');
            for (var i = an.length - 1; i != -1; i--) { 
	    		var link = an[i];
                if (link.href.indexOf('#') >= 0) {
                    var fragment = link.href.substring(link.href.indexOf('#') + 1);
                    if (fragExclude.search(fragment)) {
						YAHOO.util.Event.addListener(link, "click", fragHLLinkEventFactor(fragment));
                    }
                }
            }
        }
    }

    /* Init the script */
    YAHOO.util.Event.onDOMReady(fragHLload);
    YAHOO.util.Event.onDOMReady(fragHLlink);
}());
