// Usage: <script>new buyitnow(title,code,price);</script>

var form = "";

function buyitnow(title,code,price,id) {
  this.formurl = "http://www.securecart.com/Rothstein/cart/basket.mv?add";
  this.imageurl = "/images/cat_add.gif";
  this.qty = 1;
  if( id ) {
    this.id = id;
//    form = "<form name='" + this.id + "' action='" + this.formurl + "' method='POST' %calc_discount%>\n";
    this.target = "securecart";
    form = "<form name='" + this.id + "' target='" + this.target + "' action='" + this.formurl + "' method='POST' %calc_discount%>\n";
  } else {
    this.id = code + "_" + Math.floor( Math.random() * 10001 );
    this.target = "securecart";
    form = "<form name='" + this.id + "' target='" + this.target + "' action='" + this.formurl + "' method='POST' %calc_discount%>\n";
  }
  form += "<input type='hidden' name='Return_Link' value='" + location.href + "' />\n";
  form += "<input type='hidden' name='Product_Sku' value='" + code + "' />\n";
  form += "<input type='hidden' name='Product_Name' value='" + title + "' />\n";
  form += "<input type='hidden' name='Product_Price' value='" + price + "' />\n";
  form += "<input type='hidden' name='qty' value='" + this.qty + "' />\n";
  if( id == null ) {
    form += "<input class='inline' type='image' alt='[Add To Cart]' src='" + this.imageurl + "' />\n";
  }
  form += "</form>\n";
  //alert( form );
  document.write( form );
}

// <form action="http://www.securecart.com/Rothstein/cart/basket.mv?add" method=post %calc_discount%>
// <input type="hidden" name="Return_Link" value="http://www.rothstein.com/new/nr388.htm">
// <input type="hidden" name="Product_Sku" value="NR388">
// <input type="hidden" name="Product_Name" value="Root Cause Analysis Handbook (ABS Group)">
// <input type="hidden" name="Product_Price" value="129.00">
// <input type="hidden" name="Product_ShipCost" value="0.00">
// <input type="hidden" name="Thumbnail_Image" value="http://www.rothstein.com/new/tn010002.jpg">
// <input type="hidden" name="Thumbnail_Width" value="175">
// <input type="hidden" name="Thumbnail_Height" value="226">
// <input type="text" size="5" name="qty" value="1">
// <input type="image" src="cat_add.gif" alt="[Add To Cart]" border=0 align="absmiddle">
// </form>
