function amazon_encode(elm){    
  $ = jQuery;
  var href = $(elm).attr('href');
  if(!href.match(/.*amazon.com.*/)){
    return;
  }
  if(href.match(/.*phandroid-20.*/)){
      return;
  }
  href = href.replace("tag=","oldtag=");

  new_href = "http://www.amazon.com/gp/redirect.html?ie=UTF8&tag=phandroid-20&location=" + encodeURI(href);
  $(elm).attr('href',new_href);
  $(elm).attr('target','_blank');
}

function encode_all(){
  $ = jQuery;
  jQuery("a").each(function(ii,elm){
    if(!$(elm).attr('href')){
      return;
    }
    amazon_encode(elm);
  });

}
encode_all();

jQuery("a").live("hover",function(){
  if(!$(this).attr('href')){
    return;
  }
  amazon_encode($(this));
});



jQuery(document).ready(function(){
  encode_all();
});



