
/*
This is used for tracking download links
*/

function track_link() {
        trackFile(this, this.getAttribute('file'));
}

function link_init() {
        var el = document.getElementsByTagName("a");
        for(var i = 0; i < el.length; i++) {
                if(el[i].getAttribute('file')) {
                        el[i].onclick = track_link;
                }
        }
}

if(typeof window.addEventListener != 'undefined') {
        window.addEventListener('load', link_init, false);
}
else if(typeof document.addEventListener != 'undefined') {
        //.. opera 7
        document.addEventListener('load', link_init, false);
}
else if(typeof window.attachEvent != 'undefined') {
        //.. win/ie
        window.attachEvent('onload', link_init);
}
//** remove this condition to degrade older browsers
else {
        //.. mac/ie5 and anything else that gets this far
        //if there's an existing onload function
        if(typeof window.onload == 'function') {
                //store it
                var existing = onload;

                //add new onload handler
                window.onload = function() {
                        //call existing onload function
                        existing();

                        //call link_init onload function
                        link_init();
                };
        }
        else {
                //setup onload function
                window.onload = link_init;
        }
}