    function Book (author, title, desc, price){
      this.author=author;
      this.title=title;
      this.desc=desc;
      this.price=price;
    }

    new Book ();

    Book.prototype.toString = function () {
      if (!this.author) 
	return "<i>" + this.title + ".</i> " + this.desc + ". <b>$" + 
	  this.price + "</b>";

      return this.author + ", <i>" + this.title + "</i> "
	     + this.desc + ". <b>$" + this.price+"</b>";
    }

    var BookArray = new Array();

    BookArray[0] = new Book ("Alison D. Anderson", "Admiral Steven Van " + 
      "Der Haghen's Voyage to the East Indies",
      "(Minneapolis: Associates of the James Ford Bell Library, 1997)", 
      "20.00");

    BookArray[1] = new Book ("Carla Rahn Phillips",
      "The short life of an unlucky Spanish galleon: Los Tres Reyes, " + 
      "1628-1634", "(Minneapolis: University of Minnesota Press, 1990)",
      "20.00");

    BookArray[2] = new Book ("John Parker and Carol A. Johnson",
      "Sir Walter Raleigh's speech from the scaffold: a translation " + 
      "of the 1619 Dutch edition, and comparison with Engish texts", 
      "(Minneapolis: Associates of the James Ford Bell Library, 1995). " +
      "<b>See our separate page for this publication, including " +
      "a reproduction of the <a href='raleigh/ral_form.html'><font " +
      "color='blue'>1619 Dutch edition</font></a></b>",
      "20.00");

    BookArray[3] = new Book ("Mark Graubard, trans.", "Tidings out of "+
      "Brazil", "(Minneapolis: University of Minnesota Press, 1957)",
      "15.00");

    BookArray[4] = new Book ("", "Mission in the Marianas: an account of " +
      "Father Diego Luis de Sanvitores and his companions, 1669-1670, " +
      "translated, with commentary by Ward Barrett", "(Minneapolis: " +
      "University of Minnesota Press, 1975)", "15.00");

    BookArray[5] = new Book ("John Parker and Carol Urness, eds.",
      "The American Revolution: a heritage of change, The James Ford " +
      "Bell Library Bicentennial Conference, University of Minnesota ",
      "(Minneapolis: Associates of the James Ford Bell Library, 1975)",
      "5.00");

    BookArray[6] = new Book ("John Parker", "The world for a marketplace",
      "(Minneapolis: Associates of the James Ford Bell Library, 1978)",
      "5.00");

    BookArray[7] = new Book ("Stuart B. Schwartz, ed., and Ruth E. " +
      "Jones, trans.", "A governor and his image in baroque Brazil: " +
      "the funereal eulogy of Afonso Furtado de Castro do Rio de " +
      "Mendonca by Juan Lopes Sierra", "(Minneapolis: University of " +
      "Minnesota Press, 1979)", "20.00");

    BookArray[8] = new Book ("James D. Tracy, ed., and trans.",
      "True ocean found: Paludanus's letters on Dutch voyages to " +
      "the Kara Sea, 1595-1596", "(Minneapolis: University of " +
      "Minnesota Press, 1980)", "20.00");

    BookArray[9] = new Book ("", "A book for Jack: words to, by and " +
      "about John Parker, curator of the James Ford Bell Library, " +
      "University of Minnesota", "(Minneapolis: Associates of the " +
      "James Ford Bell Library, 1991)", "5.00");

    BookArray[10] = new Book ("", "James Ford Bell and his books: the " +
      "nucleus of a library", "(Minneapolis: Associates of the James " +
      "Ford Bell Library, 1993)", "10.00");

    BookArray[11] = new Book ("Sara Shannon", "&#147;The horrible " +
      "combats&#148;: a document on the Revolution in Saint-Domingue, " +
      "1790", "(Minneapolis: Associates of the James Ford Bell Library, " +
      "1992)", "5.00");

    BookArray[12] = new Book ("Donald J. Harreld", "The case of the " + 
      "de Virlade: an investigation into eighteenth century marine " +
      "insurance practices", "(Minneapolis: Associates of the James " +
      "Ford Bell Library, 1995)", "5.00");

    BookArray[13] = new Book ("Cynthia A. Gladden", "The Incanto di " +
      "Quatro Galere: An Auction of Four Galleys", "(Minneapolis: " +
      "Associates of the James Ford Bell Library, 1997)", "5.00");



  function ConvertMoney (number){
    if (number%2 == 0 || (number+1)%2 == 0)
      return number+".00";
    else{

      var tstr = number.toString();
      var tlen = tstr.length;
      
      if (tstr.charAt(tlen-2) == '.')
	return number+"0";

      for (var i=tlen-1; i>=0; i--){
	if (tstr.charAt(i) == '.')
	  break;
      }

      var cents = tstr.substring(i+1,tlen);
      var dollars = tstr.substring(0,i);

      if (cents.length == 2)
	return number;
      else if (cents.length >= 3){
	var tcents = cents.substring(0,2);
	if (cents.charAt(2) >= 5){
	  if (tcents == 99){
	    dollars++;
	    return dollars+".00";
	  }
	  else{
	    tcents++;
	    return dollars + "." + tcents;
	  }
        }
	else{
	  return dollars + "." + tcents;
	}
      }
    }
  }

  function PrintForm (){
    var Customer = document.Customer;
    var d;
    var total = 0;
    var TotalQuantity = 0;
    for (var i=0; i<BookArray.length; i++){
      if (document.forms[i].Quantity.value > 0)
	break;
    }

    if (i == BookArray.length){
      alert ("You haven't selected anything to order");
      return;
    }

    if (Customer.name.value == ""){
      alert ("You must fill in your name");
      return;
    }

    if (Customer.street.value == ""){
      alert ("You must fill in the street address");
      return;
    }

    if (Customer.City.value == ""){
      alert ("You must fill in the city");
      return;
    }

    if (Customer.country.value == "USA" && Customer.state.value == ""){
      alert ("You must fill in the state");
      return;
    }

    if (Customer.country.value == "USA" && Customer.zip.value == ""){
      alert ("you must fill in the zipcode");
      return;
    }

    var w = window.open("", "OrderWin", 
      "resizable,status,scrollbars=yes,menubar=yes,width=625, height=400");
      
    d = w.document;


    d.write ("<TABLE align='center' width ='700' cellpadding='0'");
    d.write ("cellspacing='0' border='0'>");
    d.write ("<TR>");
    d.write ("<TD WIDTH='150' background='Lec37/background.gif'");
    d.write ("ALIGN='center' VALIGN='top'>");
    d.write ("&nbsp;");
    d.write ("<p>");
    d.write ("<a href='index.html'><img src='home.gif' width='127'");
    d.write ("height='194' border=0></a>");
    d.write ("<p>");
    d.write ("<FORM>");
    d.write ("<INPUT TYPE='button' VALUE='print' onClick='print()'>");
    d.write ("</FORM>");
    d.write ("</TD>");
    d.write ("<TD>");
    d.write ("<table width='450' align='center'><tr><td>");
    d.write ("<H1>Book Order Form</H1>");
    d.write ("<H2>Please send me the following books</H2>");

    for (var i=0; i<BookArray.length; i++){
      if (document.forms[i].Quantity.value > 0 ) {
        var tempQ = document.forms[i].Quantity.value;
	TotalQuantity = ((TotalQuantity*1)+(tempQ*1)); 
	total += (tempQ*BookArray[i].price);
	var subt = ConvertMoney (tempQ*BookArray[i].price);
        d.write (BookArray[i]);
        d.write ("<P align='right'>");
        d.write ("Quantity: "+tempQ+", Subtotal: $"+subt);
        d.write ("</P>");
      }
    }
    d.write ("<P align='right'>");
    Customer.state.value = Customer.state.value.toUpperCase();

    d.write ("SubTotal: $"+ConvertMoney(total)+"<br>");

    if (Customer.state.value == "MN"){
      var tax = total * .075;
      d.write ("Minnesota Sales Tax: $"+ConvertMoney(tax)+"<br>");
    }
    else
      var tax = 0;

    var shipping = ConvertMoney(TotalQuantity*1.75);
    d.write ("Shipping and Handling (US only): $"+shipping+"<br>");
    total = ConvertMoney (total*1+tax*1+shipping*1);
    d.write ("<font size=+1>Total: $"+ConvertMoney(total)+"</font>");
    d.write ("</P>");
    d.write ("<hr size=2>");
    d.write ("<CENTER>");
    d.write ("<font size=+1><b>");
	d.write ("<font color='blue'>For international shipping charges, contact the Library at jfbell@umn.edu ");
    d.write ("<font color='red'>Please make check payable to the ");
    d.write ("<font color='blue'>James ");
    d.write ("Ford Bell Library </font>");
    d.write ("in the amount of <font color='blue'>$");
    d.write (ConvertMoney(total)+"</font> and send to:</font>");
    d.write ("<p><CENTER>&nbsp;");
    d.write ("The James Ford Bell Library<br>");
    d.write ("University of Minnesota<br>");
    d.write ("472 Wilson Library<br>");
    d.write ("309 19th Avenue South<br>");
    d.write ("Minneapolis, Minnesota 55455");
    d.write ("</b></font></CENTER>");
    d.write ("&nbsp;<h3><font color='blue'>Send the books to</font></h3>");
    d.write ("<TABLE WIDTH='300' BORDER='2'>");
    d.write ("<TR>");
    d.write ("<TD><font size=+1>");
    d.write (Customer.name.value+"<br>");
    d.write (Customer.street.value+"<br>");
    d.write (Customer.City.value+ " "+Customer.state.value+" ");
    d.write (Customer.zip.value+"<br>");
    d.write ("</font></TD></TR></TABLE></CENTER>");
    d.write ("</td>");
    d.write ("</tr>");
    d.write ("</table>");
    d.write ("</td>");
    d.write ("</tr>");
    d.write ("</table>");
    d.close();
  }
