// magicvox-1.0.0.js
jQuery(document).ready(function () {
  /******** Track archive downloading ********/
  $('a').each(function() {
    if( this.hostname.match( /\.magicvox\.net$/ )
        && this.pathname.match( /^\/archive\/src\/.+/ ))
      this.onclick = function() {
        pageTracker._trackPageview( this.pathname );
      };
  });

  /******** Track Amazon associate links ********/
  $('a').each(function() {
    if( this.hostname.match( /\.amazon\.co\.jp$/ )) {
      var asin = null;
      if( this.pathname.match( /\/ASIN\/[0-9A-Z]+\// ))
        asin = this.pathname.replace( /.*\/ASIN\/([0-9A-Z]+)\/.*/, '$1' );
      else if( this.pathname.match( /\/gp\/product\/[0-9A-Z]+/ ))
        asin = this.pathname.replace( /.*\/gp\/product\/([0-9A-Z]+).*/, '$1' );
      else if( this.pathname.match( /\/dp\/[0-9A-Z]+/ ))
        asin = this.pathname.replace( /.*\/dp\/([0-9A-Z]+).*/, '$1' );
      if( asin )
        this.onclick = function() {
          pageTracker._trackPageview( '/_tracking/ASIN/' + asin );
        };
    }
  });
});

