/**  Google Analytics */
var ga = {
  
  trackers: [],
  
  initGaTracking: function(){
    
    $$("a").each(function(el){
      var fullPath = el.pathname;
      var path = fullPath.include("?")? fullPath.split("?")[0] : fullPath;
      var types = [];
      
      if(path.match(/\.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3)($|\&|\?)/)){    
        types.push('download');
      }
      
      if(location.hostname!=el.hostname && !el.href.include("javascript:") && !el.href.include("mailto:"))types.push('external');
      
      if(types.length>0) el.observe("click", ga.track.bindAsEventListener(ga,types))
      
    })
  },
  
  track: function(ev){
    var url = ev.findElement("a").href;
    var types = $A(arguments)[1];
    var type = "/";
    if(typeof pageTracker=="object"){
      types.each(function(t){
        type += t + "-" ;
      }.bind(this))
      type = type.substr(0,type.length-1);
      type+= "/"+url;
      pageTracker._trackPageview(type);
    }
  }
  
}

document.observe("dom:loaded", ga.initGaTracking);