if((typeof Prototype == "undefined") || (typeof _gat == "undefined")) {
    throw("Prototype and Google Analytics code are required.");
}
else {
    var pageTracker = _gat._getTracker("UA-1285223-1");
    pageTracker._setDomainName(".trexglobal.com");
    pageTracker._setAllowLinker(true);
    pageTracker._initData();
    pageTracker._trackPageview();
    
    $$('a').each(function(link) {
       link.observe('click', function(event) {
           // Tracking just the links that are pointing to local objects
           if(link.hostname == document.location.hostname) {
               // We are tracking just PDF and DOC files for now. If you'd
               // like to add more file types simply insert a |\.ext in
               // the regex variable.
               // For example, if we'd like to track mp3s too, we'd have
               // the following line:
               // var regex =  /(?:\.pdf|\.doc|\.mp3)$/
               var regex = /(?:\.pdf|\.doc)$/

               if(link.pathname.match(regex)) {
                   url = link.pathname.replace(regex, "");
                   pageTracker._trackPageview("/files/" + url.replace(/^\//, ""));
               }
           }
           // It would be nice to track outbound links too. If we link to
           // Google.com and somebody clicks that link, we'll see the
           // reports for that link in the Analytics page as
           // /outbound/www.google.com.
           else {
               // The <a href="javascript:///"> links don't have a hostname
               // and generate bogus /outbound/ tracking data, so we have
               // to check for a hostname first.
              if(link.hostname && link.hostname.length > 1) {
                  pageTracker._trackPageview("/outbound/" + link.hostname);
              }
           }
        });
    });
}