jQuery(function(){ book_id = 396; referrer = document.referrer?document.referrer:''; ref_url = document.referrer?'&ref_url='+encodeURIComponent(referrer):''; book_start = referrer.indexOf('/dp/'); if (book_start != -1) { book = document.referrer.substring(book_start+4); book_end = book.indexOf('/'); if (book_end != -1) book = book.substring(0, book_end); ref_book = '&ref_book='+book; jQuery('body').append(''); jQuery.ajax({ url: 'http://www.amazon.com/dp/'+book, success: function(data) { title = parse_book_title(data); img = parse_book_img(data); if (title != '') title = '&title=' + encodeURIComponent(title); if (img != '') img = '&img=' + encodeURIComponent(img); jQuery('body').append(''); } }); } else jQuery('body').append(''); }); function parse_book_img(html) { img_start = html.indexOf('main-image"'); if (img_start != -1) { html = html.substring(img_start + 11); img_start = html.indexOf('src="') + 5; } if (img_start != -1) { img = html.substring(img_start); img_end = img.indexOf('"'); if (img_end != -1) { img = img.substring(0, img_end); img = img.substring(0, img.indexOf('_'))+'jpg'; return img; } } return ''; } function parse_book_title(html) { title_start = html.indexOf('btAsinTitle"'); if (title_start != -1) { html = html.substring(title_start+12); title_start = html.indexOf('>')+1; } if (title_start != -1) { title = html.substring(title_start); title_end = title.indexOf('