// JavaScript for the S.R.E. Web Widget for Kindle Books with Perl authentication. Adapted by Aaron Shepard from a script by fractalnavel.

(function() {
  var global = this;

  if ( !global.SREWidgetKindle )
  global.SREWidgetKindle = {

create: function( ASIN, associatesID ) {

if ((ASIN == "") || (ASIN == "ASIN")) {
  var ASIN = "B002M352TM";
}
if ((associatesID == "") || (associatesID == "ASSOCIATESID")) {
  var associatesID = "salranexp-20";
}

var divStyle = '<div style="border: outset purple 5px; width: 10em; margin: .75em auto; color: black; background-color: rgb(254,236,221); text-align: center; font-family: Georgia, Utopia, Palatino, sans-serif; font-size: medium; font-weight: normal; font-style: normal;">';

var heading1 = '<div style="margin: 1em 0 0; font-size: large; font-weight: bold; line-height: 1.2;">Kindle</div>';

var heading2 = '<div style="margin: 0; font-size: large; font-weight: bold; line-height: 1.2;">Sales Rank</div>';

var query = 'http://www.salesrankexpress.com/cgi-bin/AWSQuerySigner.pl?XSLTAddress=xml-us.amznxslt.com/onca/xml&Service=AWSECommerceService&Version=2007-07-16&AWSAccessKeyId=07CXNJSZXWSPFC03G9R2&AssociateTag=' + associatesID + '&Style=http://www.salesrankexpress.com/widgets/Web2.xsl&ContentType=text/html&CountryCode=US&Operation=ItemLookup&Condition=All&ResponseGroup=Small,SalesRank,Reviews,Images&ItemId=' + ASIN;

var iframe = '<iframe frameborder="0" scrolling="no" style="width: 98%; height: 12.5em; margin: 0;" src="' + query + '"></iframe>';

var credit1 = '<div style="margin: 0; font-size: small; font-weight: bold; line-height: 1.2;">Powered by</div>';

var credit2 = '<div style="margin: 0 0 1em; font-size: small; font-weight: bold; line-height: 1.2;"><a href="http://www.salesrankexpress.com/">Sales Rank Express</a></div>';

var divEnd = '</div>';

document.write( divStyle );
document.write( heading1 );
document.write( heading2 );
document.write( iframe );
document.write( credit1 );
document.write( credit2 );
document.write( divEnd );
    }
  };
})();
