
Event.observe(window, 'load', function() { init(); });

function init() {
    target_links();
}

function target_links(target_div) {
    var target = "a";
    
    $$(target).each(function(e) { 
	    
        var destination = e.readAttribute("href");
        if(!destination) return;
        if(e.readAttribute("class") == "lightwindow") return;
        if(destination.startsWith('/') || destination.startsWith('..') || destination.startsWith('http://'+location.host)) {
            if(destination.match(/\.(pdf|mov|wmv|doc|docx|mp3|mp4|m4v|avi|xls|xlsx|ppt|pptx)/)) {
		destination = destination.replace(/^.*\//,'');
                e.setAttribute('onclick',"_gaq.push(['_trackEvent','"+destination+"', 'clicked']);");
       	    }
        }
    });
}


