//=====================================================================||
//               NOP Design JavaScript Shopping Cart                   ||
//                                                                     ||
// For more information on SmartSystems, or how NOPDesign can help you ||
// Please visit us on the WWW at http://www.nopdesign.com              ||
//                                                                     ||
// Javascript portions of this shopping cart software are available as ||
// freeware from NOP Design.  You must keep this comment unchanged in  ||
// your code.  For more information contact FreeCart@NopDesign.com.    ||
//                                                                     ||
// JavaScript Shop Module, V.4.4.0                                     ||
//=====================================================================||

//---------------------------------------------------------------------||
//                       Global Options                                ||
//                      ----------------                               ||
// Shopping Cart Options, you can modify these options to change the   ||
// the way the cart functions.                                         ||
//                                                                     ||
// Language Packs                                                      ||
// ==============                                                      ||
// You may include any language pack before nopcart.js in your HTML    ||
// pages to change the language.  Simply include a language pack with  ||
// a script src BEFORE the <SCRIPT SRC="nopcart.js">... line.          ||
//  For example: <SCRIPT SRC="language-en.js"></SCRIPT>                ||
//                                                                     ||
// Options For Everyone:                                               ||
// =====================                                               ||
// * MonetarySymbol: string, the symbol which represents dollars/euro, ||
//   in your locale.                                                   ||
// * DisplayNotice: true/false, controls whether the user is provided  ||
//   with a popup letting them know their product is added to the cart ||
// * DisplayShippingColumn: true/false, controls whether the managecart||
//   and checkout pages display shipping cost column.                  ||
// * DisplayShippingRow: true/false, controls whether the managecart   ||
//   and checkout pages display shipping cost total row.               ||
// * DisplayTaxRow: true/false, controls whether the managecart        ||
//   and checkout pages display tax cost total row.                    ||
// * TaxRate: number, your area's current tax rate, ie: if your tax    ||
//   rate was 7.5%, you would set TaxRate = 0.075                      ||
// * TaxByRegion: true/false, when set to true, the user is prompted   ||
//   with TaxablePrompt to determine if they should be charged tax.    ||
//   In the USA, this is useful to charge tax to those people who live ||
//   in a particular state, but no one else.                           ||
// * TaxPrompt: string, popup message if user has not selected either  ||
//   taxable or nontaxable when TaxByRegion is set to true.            ||
// * TaxablePrompt: string, the message the user is prompted with to   ||
//   select if they are taxable.  If TaxByRegion is set to false, this ||
//   has no effect. Example: 'Arizona Residents'                       ||
// * NonTaxablePrompt: string, same as above, but the choice for non-  ||
//   taxable people.  Example: 'Other States'                          ||
// * MinimumOrder: number, the minium dollar amount that must be       ||
//   purchased before a user is allowed to checkout.  Set to 0.00      ||
//   to disable.                                                       ||
// * MinimumOrderPrompt: string, Message to prompt users with when     ||
//   they have not met the minimum order amount.                       ||
//                                                                     ||
// Payment Processor Options:                                          ||
// ==========================                                          ||
// * PaymentProcessor: string, the two digit payment processor code    ||
//   for support payment processor gateways.  Setting this field to    ||
//   anything other than an empty string will override your OutputItem ||
//   settings -- so please be careful when receiving any form data.    ||
//   Support payment processor gateways are:                           ||
//    * Authorize.net (an)                                             ||
//    * Worldpay      (wp)                                             ||
//    * LinkPoint     (lp)
//                                                                     ||
// Options For Programmers:                                            ||
// ========================                                            ||
// * OutputItem<..>: string, the name of the pair value passed at      ||
//   checkouttime.  Change these only if you are connecting to a CGI   ||
//   script and need other field names, or are using a secure service  ||
//   that requires specific field names.                               ||
// * AppendItemNumToOutput: true/false, if set to true, the number of  ||
//   each ordered item will be appended to the output string.  For     ||
//   example if OutputItemId is 'ID_' and this is set to true, the     ||
//   output field name will be 'ID_1', 'ID_2' ... for each item.       ||
// * HiddenFieldsToCheckout: true/false, if set to true, hidden fields ||
//   for the cart items will be passed TO the checkout page, from the  ||
//   ManageCart page.  This is set to true for CGI/PHP/Script based    ||
//   checkout pages, but should be left false if you are using an      ||
//   HTML/Javascript Checkout Page. Hidden fields will ALWAYS be       ||
//   passed FROM the checkout page to the Checkout CGI/PHP/ASP/Script  ||
//---------------------------------------------------------------------||

//Options for Everyone:
MonetarySymbol        = '$';
DisplayNotice         = true;
DisplayShippingColumn = false;
DisplayShippingRow    = true;
DisplayTaxRow         = true;
TaxRate               = 0.0625;
TaxByRegion           = true;
TaxPrompt             = 'Massachusetts residents must add sales tax.';
TaxablePrompt         = 'Massachusetts Resident';
NonTaxablePrompt      = 'Other';
ShippablePrompt       = '48 Contiguous United States';
NonShippablePrompt    = 'Other';
MinimumOrder          = 1.00;
MinimumOrderPrompt    = 'Your order is below our minimum!';
MaxOrderPrompt        = 'Sorry. Your book bag is limited to 10 titles and 50 books. If you would like to order more, please place a second order.';



//Payment Processor Options:
PaymentProcessor      = '';

//Options for Programmers:
OutputItemId          = 'ID_';
OutputItemQuantity    = 'QUANTITY_';
OutputItemPrice       = 'PRICE_';
OutputItemXtend       = 'XTEND_'; // ***** Added 7-17-2003
OutputItemName        = 'NAME_';
OutputItemShipping    = 'SHIPPING_';
OutputItemAddtlInfo   = 'ADDTLINFO_';  // ***** take out?
OutputOrderSubtotal   = 'SUBTOTAL';
OutputOrderDiscount   = 'DISCOUNT';
OutputOrderShipping   = 'SHIPPING';
OutputOrderTax        = 'TAX';
OutputOrderTotal      = 'TOTAL';
AppendItemNumToOutput = true;
HiddenFieldsToCheckout = true;


//---------------------------------------------------------------------||
//                      Language Strings                               ||
//                     ------------------                              ||
// These strings will not be used unless you have not included a       ||
// language pack already.  You should NOT modify these, but instead    ||
// modify the strings in language-**.js where ** is the language pack  ||
// you are using.                                                      ||
//---------------------------------------------------------------------||
if ( !bLanguageDefined ) {
   strSorry  = "I'm Sorry, your book bag is full! Please proceed to checkout.";
   strAdded  = " added to your book bag.";
   strRemove = "Click 'Ok' to remove this product from your book bag.";
   strILabel = "Product Id";
   strDLabel = "Product Name/Description";
   strQLabel = "Quantity";
   strPLabel = "Price";
   strSLabel = "Shipping";
   strRLabel = " ";
   strRButton= "Remove";
   strSUB    = "SUBTOTAL";
   strDIS    = "DISCOUNT";
   strSHIP   = "SHIPPING";
   strTAX    = "TAX";
   strTOT    = "TOTAL";
   strErrQty = "Invalid Quantity.";
   strNewQty = 'Please enter new quantity:';
   bLanguageDefined = true;
}


//---------------------------------------------------------------------||
// FUNCTION:    CKquantity                                             ||
// PARAMETERS:  Quantity to                                            ||
// RETURNS:     Quantity as a number, and possible alert               ||
// PURPOSE:     Make sure quantity is represented as a number          ||
//---------------------------------------------------------------------||
function CKquantity(checkString) {
   var strNewQuantity = "";

   for ( i = 0; i < checkString.length; i++ ) {
      ch = checkString.substring(i, i+1);
      if ( (ch >= "0" && ch <= "9") || (ch == '.') )
         strNewQuantity += ch;
   }

   if ( strNewQuantity.length < 1 )
      strNewQuantity = "1";

   return(strNewQuantity);
}


//---------------------------------------------------------------------||
// FUNCTION:    AddToCart                                              ||
// PARAMETERS:  Form Object                                            ||
// RETURNS:     Cookie to user's browser, with prompt                  ||
// PURPOSE:     Adds a product to the user's shopping cart             ||
//---------------------------------------------------------------------||
function AddToCart(thisForm) {
   var iNumberOrdered = 0;
   var bAlreadyInCart = false;
   var notice = "";
   iNumberOrdered = GetCookie("NumberOrdered");

   if ( iNumberOrdered == null )
      iNumberOrdered = 0;

   if ( thisForm.ID_NUM == null )
      strID_NUM    = "";
   else
      strID_NUM    = thisForm.ID_NUM.value;

   if ( thisForm.QUANTITY == null )
      strQUANTITY  = "1";
   else
      strQUANTITY  = thisForm.QUANTITY.value;

   if ( thisForm.PRICE == null )
      strPRICE     = "0.00";
   else
      strPRICE     = thisForm.PRICE.value;

   if ( thisForm.NAME == null )
      strNAME      = "";
   else
      strNAME      = thisForm.NAME.value;

   if ( thisForm.SHIPPING == null )
      strSHIPPING  = "0.00";
   else
      strSHIPPING  = thisForm.SHIPPING.value;

   if ( thisForm.XTEND == null ) 
      strXTEND = "0.00";
   else 
      strXTEND = thisForm.XTEND.value; // *****

   //Is this product already in the cart?  If so, increment quantity instead of adding another.
   for ( i = 1; i <= iNumberOrdered; i++ ) {
      NewOrder = "Order." + i;
      database = "";
      database = GetCookie(NewOrder);

      Token0 = database.indexOf("|", 0);
      Token1 = database.indexOf("|", Token0+1);
      Token2 = database.indexOf("|", Token1+1);
      Token3 = database.indexOf("|", Token2+1);
      Token4 = database.indexOf("|", Token3+1);

      fields = new Array;
      fields[0] = database.substring( 0, Token0 );
      fields[1] = database.substring( Token0+1, Token1 );
      fields[2] = database.substring( Token1+1, Token2 );
      fields[3] = database.substring( Token2+1, Token3 );
      fields[4] = database.substring( Token3+1, Token4 );
      fields[5] = database.substring( Token4+1, database.length );

      if ( fields[0] == strID_NUM &&
           fields[2] == strPRICE  &&
           fields[3] == strNAME
         ) {
         bAlreadyInCart = true;
         dbUpdatedOrder = strID_NUM    + "|" +
                          (parseInt(strQUANTITY)+parseInt(fields[1]))  + "|" +
                          strPRICE     + "|" +
                          strNAME      + "|" +
                          strSHIPPING  + "|" +
                          strXTEND;                       // *****
         strNewOrder = "Order." + i;
         DeleteCookie(strNewOrder, "/");
         SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
         notice = strQUANTITY + " " + strNAME + strAdded;
         break;
      }
   }

   if ( !bAlreadyInCart ) {
      iNumberOrdered++;

      if ( iNumberOrdered > 10 )
         alert( strSorry );
      else {
         dbUpdatedOrder = strID_NUM    + "|" + 
                          strQUANTITY  + "|" +
                          strPRICE     + "|" +
                          strNAME      + "|" +
                          strSHIPPING  + "|" +
                          strXTEND;   // *****

         strNewOrder = "Order." + iNumberOrdered;
         SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
         SetCookie("NumberOrdered", iNumberOrdered, null, "/");
         notice = strQUANTITY + " " + strNAME + strAdded;
      }
   }

   if ( DisplayNotice )
      alert(notice);
}


//---------------------------------------------------------------------||
// FUNCTION:    getCookieVal                                           ||
// PARAMETERS:  offset                                                 ||
// RETURNS:     URL unescaped Cookie Value                             ||
// PURPOSE:     Get a specific value from a cookie                     ||
//---------------------------------------------------------------------||
function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);

   if ( endstr == -1 )
      endstr = document.cookie.length;
   return(unescape(document.cookie.substring(offset, endstr)));
}


//---------------------------------------------------------------------||
// FUNCTION:    FixCookieDate                                          ||
// PARAMETERS:  date                                                   ||
// RETURNS:     date                                                   ||
// PURPOSE:     Fixes cookie date, stores back in date                 ||
//---------------------------------------------------------------------||
function FixCookieDate (date) {
   var base = new Date(0);
   var skew = base.getTime();

   date.setTime (date.getTime() - skew);
}


//---------------------------------------------------------------------||
// FUNCTION:    GetCookie                                              ||
// PARAMETERS:  Name                                                   ||
// RETURNS:     Value in Cookie                                        ||
// PURPOSE:     Retrieves cookie from users browser                    ||
//---------------------------------------------------------------------||
function GetCookie (name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;

   while ( i < clen ) {
      var j = i + alen;
      if ( document.cookie.substring(i, j) == arg ) return(getCookieVal (j));
      i = document.cookie.indexOf(" ", i) + 1;
      if ( i == 0 ) break;
   }

   return(null);
}


//---------------------------------------------------------------------||
// FUNCTION:    SetCookie                                              ||
// PARAMETERS:  name, value, expiration date, path, domain, security   ||
// RETURNS:     Null                                                   ||
// PURPOSE:     Stores a cookie in the users browser                   ||
//---------------------------------------------------------------------||
function SetCookie (name,value,expires,path,domain,secure) {
   document.cookie = name + "=" + escape (value) +
                     ((expires) ? "; expires=" + expires.toGMTString() : "") +
                     ((path) ? "; path=" + path : "") +
                     ((domain) ? "; domain=" + domain : "") +
                     ((secure) ? "; secure" : "");
}


//---------------------------------------------------------------------||
// FUNCTION:    DeleteCookie                                           ||
// PARAMETERS:  Cookie name, path, domain                              ||
// RETURNS:     null                                                   ||
// PURPOSE:     Removes a cookie from users browser.                   ||
//---------------------------------------------------------------------||
function DeleteCookie (name,path,domain) {
   if ( GetCookie(name) ) {
      document.cookie = name + "=" +
                        ((path) ? "; path=" + path : "") +
                        ((domain) ? "; domain=" + domain : "") +
                        "; expires=Thu, 01-Jan-70 00:00:01 GMT";
   }
}


//---------------------------------------------------------------------||
// FUNCTION:    MoneyFormat                                            ||
// PARAMETERS:  Number to be formatted                                 ||
// RETURNS:     Formatted Number                                       ||
// PURPOSE:     Reformats Dollar Amount to #.## format                 ||
//---------------------------------------------------------------------||
function moneyFormat(input) {
   var dollars = Math.floor(input);
   var tmp = new String(input);

   for ( var decimalAt = 0; decimalAt < tmp.length; decimalAt++ ) {
      if ( tmp.charAt(decimalAt)=="." )
         break;
   }

   var cents  = "" + Math.round(input * 100);
   cents = cents.substring(cents.length-2, cents.length)
           dollars += ((tmp.charAt(decimalAt+2)=="9")&&(cents=="00"))? 1 : 0;

   if ( cents == "0" )
      cents = "00";

   return(dollars + "." + cents);
}


//---------------------------------------------------------------------||
// FUNCTION:    RemoveFromCart                                         ||
// PARAMETERS:  Order Number to Remove                                 ||
// RETURNS:     Null                                                   ||
// PURPOSE:     Removes an item from a users shopping cart             ||
//---------------------------------------------------------------------||
function RemoveFromCart(RemOrder) {
   if ( confirm( strRemove ) ) {
      NumberOrdered = GetCookie("NumberOrdered");
      for ( i=RemOrder; i < NumberOrdered; i++ ) {
         NewOrder1 = "Order." + (i+1);
         NewOrder2 = "Order." + (i);
         database = GetCookie(NewOrder1);
         SetCookie (NewOrder2, database, null, "/");
      }
      NewOrder = "Order." + NumberOrdered;
      SetCookie ("NumberOrdered", NumberOrdered-1, null, "/");
      DeleteCookie(NewOrder, "/");
      location.href=location.href;
   }
}


//---------------------------------------------------------------------||
// FUNCTION:    ChangeQuantity                                         ||
// PARAMETERS:  Order Number to Change Quantity                        ||
// RETURNS:     Null                                                   ||
// PURPOSE:     Changes quantity of an item in the shopping cart       ||
//---------------------------------------------------------------------||
function ChangeQuantity(OrderItem,NewQuantity) {
   if ( isNaN(NewQuantity) ) {
      alert( strErrQty );
   } else {
      NewOrder = "Order." + OrderItem;
      database = "";
      database = GetCookie(NewOrder);

      Token0 = database.indexOf("|", 0);
      Token1 = database.indexOf("|", Token0+1);
      Token2 = database.indexOf("|", Token1+1);
      Token3 = database.indexOf("|", Token2+1);
      Token4 = database.indexOf("|", Token3+1);

      fields = new Array;
      fields[0] = database.substring( 0, Token0 );
      fields[1] = database.substring( Token0+1, Token1 );
      fields[2] = database.substring( Token1+1, Token2 );
      fields[3] = database.substring( Token2+1, Token3 );
      fields[4] = database.substring( Token3+1, Token4 );
      fields[5] = database.substring( Token4+1, database.length );

      dbUpdatedOrder = fields[0] + "|" +
                       NewQuantity + "|" +
                       fields[2] + "|" +
                       fields[3] + "|" +
                       fields[4] + "|" +
                       fields[5];
      strNewOrder = "Order." + OrderItem;
      DeleteCookie(strNewOrder, "/");
      SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
      location.href=location.href;      
   }
}

// By Alex Howlett.  Based on ChangeQuantity above.
//---------------------------------------------------------------------||
// FUNCTION:    ChangePromoCode                                       ||
// PARAMETERS:  New Discount Promo Code                                ||
// RETURNS:     Null                                                   ||
// PURPOSE:     Changes the discount code applied to the order.        ||
//---------------------------------------------------------------------||
function ChangePromoCode(NewPromoCode) {

   DeleteCookie("PromoCode", "/");
   SetCookie ("PromoCode", NewPromoCode, null, "/");
   location.href = location.href;
}

// By Alex Howlett.  Based on ChangeQuantity above.
//---------------------------------------------------------------------||
// FUNCTION:    ChangeShippingDestination                              ||
// PARAMETERS:  New Shipping Destination                               ||
// RETURNS:     Null                                                   ||
// PURPOSE:     Toggles the shipping destination (US48 or Other)       ||
//---------------------------------------------------------------------||
function ChangeShippingDestination(NewShippingDest) {

   DeleteCookie("ShippingDest", "/");
   SetCookie ("ShippingDest", NewShippingDest, null, "/");
   location.href = location.href;
}

//---------------------------------------------------------------------||
// FUNCTION:    GetFromCart                                            ||
// PARAMETERS:  Null                                                   ||
// RETURNS:     Product Table Written to Document                      ||
// PURPOSE:     Draws current cart product table on HTML page          ||
//              **DEPRECATED FUNCTION, USE ManageCart or Checkout**    ||
//---------------------------------------------------------------------||
function GetFromCart( fShipping ) {
   ManageCart( );
}


//---------------------------------------------------------------------||
// FUNCTION:    RadioChecked                                           ||
// PARAMETERS:  Radio button to check                                  ||
// RETURNS:     True if a radio has been checked                       ||
// PURPOSE:     Form fillin validation                                 ||
//---------------------------------------------------------------------||
function RadioChecked( radiobutton ) {
   var bChecked = false;
   var rlen = radiobutton.length;
   for ( i=0; i < rlen; i++ ) {
      if ( radiobutton[i].checked )
         bChecked = true;
   }    
   return bChecked;
} 


//---------------------------------------------------------------------||
// FUNCTION:    QueryString                                            ||
// PARAMETERS:  Key to read                                            ||
// RETURNS:     value of key                                           ||
// PURPOSE:     Read data passed in via GET mode                       ||
//---------------------------------------------------------------------||
QueryString.keys = new Array();
QueryString.values = new Array();
function QueryString(key) {
   var value = null;
   for (var i=0;i<QueryString.keys.length;i++) {
      if (QueryString.keys[i]==key) {
         value = QueryString.values[i];
         break;
      }
   }
   return value;
} 

//---------------------------------------------------------------------||
// FUNCTION:    QueryString_Parse                                      ||
// PARAMETERS:  (URL string)                                           ||
// RETURNS:     null                                                   ||
// PURPOSE:     Parses query string data, must be called before Q.S.   ||
//---------------------------------------------------------------------||
function QueryString_Parse() {
   var query = window.location.search.substring(1);
   var pairs = query.split("&"); for (var i=0;i<pairs.length;i++) {
      var pos = pairs[i].indexOf('=');
      if (pos >= 0) {
         var argname = pairs[i].substring(0,pos);
         var value = pairs[i].substring(pos+1);
         QueryString.keys[QueryString.keys.length] = argname;
         QueryString.values[QueryString.values.length] = value;
      }
   }
}


//---------------------------------------------------------------------||
// FUNCTION:    ManageCart                                             ||
// PARAMETERS:  Null                                                   ||
// RETURNS:     Product Table Written to Document                      ||
// PURPOSE:     Draws current cart product table on HTML page          ||
//---------------------------------------------------------------------||
function ManageCart( ) {
  var fQuant         = 0;    //Quantity of items
  var iNumberOrdered = 0;    //Number of products ordered
  var fItemtotal     = 0;
  var fSubtotal      = 0;    
  var fDiscount      = 0;    
  var fTotal         = 0;    //Total cost of order
  var fTax           = 0;    //Tax amount
  var fShipping      = 0;    //Shipping amount
  var strItemtotal   = "";
  var strSubtotal    = "";
  var strDiscount    = "";
  var strTotal       = "";   //Total cost formatted as money
  var strTax         = "";   //Total tax formatted as money
  var strShipping    = "";   //Total shipping formatted as money
  var strPromoCode   = "";   //The current promo code string
  var strOutput      = "";   //String to be written to page
  var bDisplay       = true; //Whether to write string to the page (here for programmers)

  // Qualifying ISBNs for JAN2012 discount
  ISBNS_JAN2012 = set ('978-1-932195-19-4', '978-1-932195-02-6', '978-1-932195-40-8', '978-1-932195-38-5', '978-1-932195-41-5', '978-0-9710310-9-8', '978-1-932195-25-5', '978-1-932195-74-3', '978-1-932195-69-9', '978-1-932195-45-3', '978-1-936797-00-4', '978-1-936797-04-2', '978-1-932195-26-2', '978-1-932195-03-3', '978-1-932195-70-5', '978-1-932195-10-1', '978-1-932195-00-2', '978-1-932195-97-2', '978-1-932195-55-2', '978-1-936797-05-9', '978-1-932195-12-5', '978-0-9710310-4-3', '978-1-932195-06-4', '978-1-932195-48-4', '978-1-932195-29-3', '978-1-932195-46-0', '978-1-932195-85-9', '978-1-932195-21-7', '978-1-932195-52-1', '978-0-9710310-1-2', '978-1-932195-15-6', '978-1-932195-94-1', '978-1-932195-76-7', '978-1-936797-06-6', '978-1-932195-84-2', '978-0-9710310-2-9', '978-1-932195-18-7', '978-0-9710310-5-0', '978-1-932195-61-3', '978-1-932195-96-5', '978-1-932195-62-0', '978-1-932195-72-9', '978-1-932195-09-5', '978-1-932195-42-2', '978-1-932195-11-8', '978-1-932195-58-3', '978-1-932195-93-4', '978-1-932195-57-6', '978-1-932195-17-0', '978-0-9710310-8-1', '978-1-932195-68-2', '978-1-932195-82-8', '978-1-932195-24-8', '978-1-932195-54-5', '978-1-932195-31-6', '978-1-932195-01-9', '978-1-936797-11-0', '978-1-932195-33-0', '978-1-932195-53-8', '978-1-932195-35-4', '978-1-932195-75-0', '978-1-932195-49-1', '978-1-932195-14-9', '978-1-932195-89-7', '978-1-932195-51-4', '978-1-932195-32-3', '978-1-932195-95-8', '978-1-932195-59-0', '978-1-932195-92-7', '978-1-932195-50-7', '978-1-932195-47-7', '978-1-932195-71-2', '978-1-932195-78-1', '978-0-9710310-7-4', '978-1-936797-13-4', '978-1-932195-27-9', '978-1-932195-73-6', '978-1-932195-67-5', '978-1-932195-56-9', '978-1-932195-87-3', '978-0-9710310-3-6', '978-1-932195-88-0', '978-1-932195-36-1', '978-1-932195-07-1', '978-1-932195-20-0', '978-1-932195-81-1', '978-1-932195-22-4', '978-0-9710310-0-5', '978-1-932195-23-1', '978-1-936797-01-1', '978-1-932195-77-4', '978-1-932195-13-2', '978-1-932195-79-8', '978-1-932195-83-5', '978-1-932195-60-6', '978-1-932195-43-9', '978-1-936797-02-8', '978-1-932195-16-3', '978-1-932195-37-8', '978-1-932195-34-7', '978-1-932195-28-6', '978-1-932195-08-8');
  var today = new Date();
  var feb1 = new Date(2012, 1, 1);

  // We now have hacked-in discount promo codes.
  strPromoCode = GetCookie("PromoCode");
  if (!strPromoCode) strPromoCode = "";
  strPromoCode = strPromoCode.toUpperCase();

  strShippingDest = GetCookie ("ShippingDest");
  if (strShippingDest != "USA" && strShippingDest != "INT") {

    strShippingDest = "MA";
    DeleteCookie("ShippingDest", "/");
    SetCookie ("ShippingDest", strShippingDest, null, "/");  
  }

   iNumberOrdered = GetCookie("NumberOrdered");
   if ( iNumberOrdered == null )
      iNumberOrdered = 0;

   if ( bDisplay )
      strOutput = "<TABLE CLASS=\"nopcart\" width=\"100%\"><TR>" +
	              "<TD CLASS=\"nopheader\" ALIGN=RIGHT><B>"+strRLabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\"><B>"+strILabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\"><B>"+strDLabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strQLabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\" ALIGN=RIGHT><B>"+strPLabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\" ALIGN=RIGHT><B>"+strITLabel+"</B></TD></TR>";

   if ( iNumberOrdered == 0 ) {
      strOutput += "<TR><TD COLSPAN=6 CLASS=\"nopentry\"><CENTER><BR><B>Your book bag is empty!</B><BR><BR></CENTER></TD></TR>";
   }

   for ( i = 1; i <= iNumberOrdered; i++ ) {
      NewOrder = "Order." + i;
      database = "";
      database = GetCookie(NewOrder);

      Token0 = database.indexOf("|", 0);
      Token1 = database.indexOf("|", Token0+1);
      Token2 = database.indexOf("|", Token1+1);
      Token3 = database.indexOf("|", Token2+1);
      Token4 = database.indexOf("|", Token3+1);

      fields = new Array;
      fields[0] = database.substring( 0, Token0 );                 // Product ID
      fields[1] = database.substring( Token0+1, Token1 );          // Quantity
      fields[2] = database.substring( Token1+1, Token2 );          // Price
      fields[3] = database.substring( Token2+1, Token3 );          // Product Name/Description
      fields[4] = database.substring( Token3+1, Token4 );          // Shipping Cost
      fields[5] = database.substring( Token4+1, database.length ); // CHANGED TO ITEM COST *****

      item_id 		= fields[0];
      item_quant 	= parseInt (fields[1]);
      item_price 	= parseFloat (fields[2]);
	    
      fSubtotal  += (item_quant * item_price);
      fShipping  += (item_quant * parseFloat(fields[4]) );
      fQuant += (item_quant);
	  
      //Check for TOO MANY BOOKS July 21, 2003 FORREST SNYDER
      if( fQuant > 50 )
        alert( MaxOrderPrompt );

      fItemtotal = item_quant * item_price;
      // For "JAN2012" promo, halve the price
      if (item_id in ISBNS_JAN2012 && today < feb1) {
          fDiscount += fItemtotal * .50;
      }

      strItemtotal = moneyFormat(fItemtotal);

      if ( bDisplay ) {
         strOutput += "<TR><TD CLASS=\"nopentry\" ALIGN=LEFT><input type=button value=\" "+strRButton+" \" onClick=\"RemoveFromCart("+i+")\" class=\"nopbutton\"></TD>";
         strOutput += "<TD CLASS=\"nopentry\">"  + fields[0] + "</TD>";
         strOutput += "<TD CLASS=\"nopentry\">"  + fields[3] + "</TD>"; // +++
         strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER><INPUT TYPE=TEXT NAME=Q SIZE=2 VALUE=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";
         strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea</TD>";
         strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>"+ MonetarySymbol + strItemtotal + "</TD></TR>";

         if ( DisplayShippingColumn ) {
            if ( parseFloat(fields[4]) > 0 )
               strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[4]) + "/ea</TD>";
            else
               strOutput += "<TD CLASS=\"nopentry\">N/A</TD>";
         }
      }

      if ( AppendItemNumToOutput ) {
         strFooter = i;
      } else {
         strFooter = "";
      }
      if ( HiddenFieldsToCheckout ) {
         strOutput += "<input type=hidden name=\"" + OutputItemId        + strFooter + "\" value=\"" + fields[0] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemQuantity  + strFooter + "\" value=\"" + fields[1] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemPrice     + strFooter + "\" value=\"" + fields[2] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemName      + strFooter + "\" value=\"" + fields[3] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemShipping  + strFooter + "\" value=\"" + fields[4] + "\">";
      }
   }
    
   fTotal = fSubtotal - fDiscount;
   strSubtotal = moneyFormat(fSubtotal);
   strDiscount = moneyFormat(fDiscount);
   
   if (strShippingDest == "MA") { 
     fTax = ((fSubtotal - fDiscount) * TaxRate);  
   } else {
     fTax = 0.00
   }
   
   fTotal += fTax;
   
   strTax = moneyFormat(fTax);
   
   // This calculates shipping for non-internatinal orders.
   // It's a flat rate of $3.95 for between 1 and 4 books.
   // Most books have a shipping rate of $3.95 built in
   // so if te shipping rate tops 16.00, that's more than
   // 4 books.
   if (strShippingDest == "INT" || fShipping > 16.00) {
   
     // We're not shipping to USA, or there are 5 ore more books
     // so it's custom shipping rates
     fShipping   = 0.00;
     strShipping = 'TBD';
     strTotal    = 'TBD';
   
   } else {
   
     if (fShipping > 3.95) {
       // There are between 1 and 4 actual books, so the rate is $3.95.
       fShipping   = 3.95;
     }
	 
     fTotal += fShipping;
     strShipping = MonetarySymbol + moneyFormat(fShipping);
     strTotal    = MonetarySymbol + moneyFormat(fTotal);  
   }

   if ( bDisplay ) {
   
      strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=6> </TD></TR>";
         
      strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strSUB+"</B></TD>";
      strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B> " + MonetarySymbol + strSubtotal + "</B></TD>";
      strOutput += "</TR>";
   
      strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strDIS+" PROMO CODE:</B> <input name=\"promo_code\" size=\"20\" value=\"" + strPromoCode + "\" onChange=\"ChangePromoCode(this.value);\" /></TD>";
      strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>- " + MonetarySymbol + strDiscount + "</B></TD>";
      strOutput += "</TR>";
      
      strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=6> </TD></TR>";

      if ( DisplayTaxRow || TaxByRegion ) {
        strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strTAX+"</B></TD>";
        strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strTax + "</B></TD>";
        strOutput += "</TR>";
      }

      strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=6> </TD></TR>";
      
	  if ( DisplayShippingRow ) {
		strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strSHIP+"</B></TD>";
        strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + strShipping + "</B></TD></TR>";
      }
	  
	  strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strTOT+"</B></TD>";
      strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B> " + strTotal + "</B></TD>";
      strOutput += "</TR>";

      strOutput += "</TABLE>";

      if ( HiddenFieldsToCheckout ) {
         strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strSubtotal + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderDiscount+"\" value=\""+ MonetarySymbol + strDiscount + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ strShipping + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTax+"\"      value=\""+ MonetarySymbol + strTax + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\"    value=\""+ strTotal + "\">";
      }
	  
	  strOutput += "<br /><input type=radio name=\""+OutputOrderShipping+"\" value=\"MA\" onChange=\"ChangeShippingDestination(this.value);\" ";
	  if (strShippingDest == "MA") strOutput += "checked";
	  strOutput += " />" + TaxablePrompt;
	  
	  strOutput += "<br /><input type=radio name=\""+OutputOrderShipping+"\" value=\"USA\" onChange=\"ChangeShippingDestination(this.value);\" ";
	  if (strShippingDest == "USA") strOutput += "checked";
	  strOutput += " />" + ShippablePrompt;
	
	  strOutput += "<br /><input type=radio name=\""+OutputOrderShipping+"\" value=\"INT\" onChange=\"ChangeShippingDestination(this.value);\" ";
	  if (strShippingDest == "INT") strOutput += "checked";
	  strOutput += " />" + NonShippablePrompt;
		
	  strOutput += "<br />";
   }
   g_TotalCost = fTotal;

   document.write(strOutput);
   document.close();
}

//---------------------------------------------------------------------||
// FUNCTION:    ValidateCart                                           ||
// PARAMETERS:  Form to validate                                       ||
// RETURNS:     true/false                                             ||
// PURPOSE:     Validates the managecart form                          ||
//---------------------------------------------------------------------||
var g_TotalCost = 0;
function ValidateCart( theForm ) {
//   if ( TaxByRegion ) {
//      if ( !RadioChecked(eval("theForm."+OutputOrderTax)) ) {
//         alert( TaxPrompt );
//         return false;
//      }
//   }

   if ( MinimumOrder >= 0.01 ) {
      if ( g_TotalCost < MinimumOrder ) {
         alert( MinimumOrderPrompt );
         return false;
      }
   }

   return true;
}

// Create a set.  Used for grouping ISBNs and testing them.
function set ()
{
    var result = {};

    for (var i = 0; i < arguments.length; i++)
      result[arguments[i]] = true;

    return result;
}


//---------------------------------------------------------------------||
// FUNCTION:    CheckoutCart                                           ||
// PARAMETERS:  Null                                                   ||
// RETURNS:     Product Table Written to Document                      ||
// PURPOSE:     Draws current cart product table on HTML page for      ||
//              checkout.                                              ||
//---------------------------------------------------------------------||
function CheckoutCart( ) {
  var fQuant         = 0;    //Quantity of items
  var iNumberOrdered = 0;    //Number of products ordered
  var fItemtotal     = 0;
  var fSubtotal      = 0;
  var fDiscount      = 0;    
  var fTotal         = 0;    //Total cost of order
  var fTax           = 0;    //Tax amount
  var fShipping      = 0;    //Shipping amount
  var strItemtotal   = "";
  var strSubtotal    = "";
  var strDiscount    = "";
  var strTotal       = "";   //Total cost formatted as money
  var strTax         = "";   //Total tax formatted as money
  var strShipping    = "";   //Total shipping formatted as money
  var strPromoCode   = "";   //The current promo code string
  var strOutput      = "";   //String to be written to page
  var bDisplay       = true; //Whether to write string to the page (here for programmers)
  var strPP          = "";   //Payment Processor Description Field
  var strGrandTotal  = "";   //Grand total of order formatted as money
  var TaxableRegion  = 0;    //If we're in a taxable region

  // Qualifying ISBNs for JAN2012 discount
  ISBNS_JAN2012 = set ('978-1-932195-19-4', '978-1-932195-02-6', '978-1-932195-40-8', '978-1-932195-38-5', '978-1-932195-41-5', '978-0-9710310-9-8', '978-1-932195-25-5', '978-1-932195-74-3', '978-1-932195-69-9', '978-1-932195-45-3', '978-1-936797-00-4', '978-1-936797-04-2', '978-1-932195-26-2', '978-1-932195-03-3', '978-1-932195-70-5', '978-1-932195-10-1', '978-1-932195-00-2', '978-1-932195-97-2', '978-1-932195-55-2', '978-1-936797-05-9', '978-1-932195-12-5', '978-0-9710310-4-3', '978-1-932195-06-4', '978-1-932195-48-4', '978-1-932195-29-3', '978-1-932195-46-0', '978-1-932195-85-9', '978-1-932195-21-7', '978-1-932195-52-1', '978-0-9710310-1-2', '978-1-932195-15-6', '978-1-932195-94-1', '978-1-932195-76-7', '978-1-936797-06-6', '978-1-932195-84-2', '978-0-9710310-2-9', '978-1-932195-18-7', '978-0-9710310-5-0', '978-1-932195-61-3', '978-1-932195-96-5', '978-1-932195-62-0', '978-1-932195-72-9', '978-1-932195-09-5', '978-1-932195-42-2', '978-1-932195-11-8', '978-1-932195-58-3', '978-1-932195-93-4', '978-1-932195-57-6', '978-1-932195-17-0', '978-0-9710310-8-1', '978-1-932195-68-2', '978-1-932195-82-8', '978-1-932195-24-8', '978-1-932195-54-5', '978-1-932195-31-6', '978-1-932195-01-9', '978-1-936797-11-0', '978-1-932195-33-0', '978-1-932195-53-8', '978-1-932195-35-4', '978-1-932195-75-0', '978-1-932195-49-1', '978-1-932195-14-9', '978-1-932195-89-7', '978-1-932195-51-4', '978-1-932195-32-3', '978-1-932195-95-8', '978-1-932195-59-0', '978-1-932195-92-7', '978-1-932195-50-7', '978-1-932195-47-7', '978-1-932195-71-2', '978-1-932195-78-1', '978-0-9710310-7-4', '978-1-936797-13-4', '978-1-932195-27-9', '978-1-932195-73-6', '978-1-932195-67-5', '978-1-932195-56-9', '978-1-932195-87-3', '978-0-9710310-3-6', '978-1-932195-88-0', '978-1-932195-36-1', '978-1-932195-07-1', '978-1-932195-20-0', '978-1-932195-81-1', '978-1-932195-22-4', '978-0-9710310-0-5', '978-1-932195-23-1', '978-1-936797-01-1', '978-1-932195-77-4', '978-1-932195-13-2', '978-1-932195-79-8', '978-1-932195-83-5', '978-1-932195-60-6', '978-1-932195-43-9', '978-1-936797-02-8', '978-1-932195-16-3', '978-1-932195-37-8', '978-1-932195-34-7', '978-1-932195-28-6', '978-1-932195-08-8');
  var today = new Date();
  var feb1 = new Date(2012, 1, 1);

  // We now have hacked-in discount promo codes.
  strPromoCode = GetCookie("PromoCode");
  if (!strPromoCode) strPromoCode = "";
    strPromoCode = strPromoCode.toUpperCase();
   
   strShippingDest = GetCookie ("ShippingDest");
   if (strShippingDest != "USA" && strShippingDest != "INT") {
   
     strShippingDest = "MA";
     DeleteCookie("ShippingDest", "/");
     SetCookie ("ShippingDest", strShippingDest, null, "/");  
   }

   iNumberOrdered = GetCookie("NumberOrdered");
   if ( iNumberOrdered == null )
      iNumberOrdered = 0;

   if ( bDisplay )
      strOutput = "<TABLE CLASS=\"nopcart\" width=\"100%\"><TR>" +
                  "<TD CLASS=\"nopheader\"><B>"+strILabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\"><B>"+strDLabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strQLabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\" ALIGN=RIGHT><B>"+strPLabel+"</B></TD>" +
                  "<TD CLASS=\"nopheader\" ALIGN=RIGHT><B>"+strITLabel+"</B></TD>" +
                  "</TR>";

   for ( i = 1; i <= iNumberOrdered; i++ ) {
      NewOrder = "Order." + i;
      database = "";
      database = GetCookie(NewOrder);

      Token0 = database.indexOf("|", 0);
      Token1 = database.indexOf("|", Token0+1);
      Token2 = database.indexOf("|", Token1+1);
      Token3 = database.indexOf("|", Token2+1);
      Token4 = database.indexOf("|", Token3+1);

      fields = new Array;
      fields[0] = database.substring( 0, Token0 );                 // Product ID
      fields[1] = database.substring( Token0+1, Token1 );          // Quantity
      fields[2] = database.substring( Token1+1, Token2 );          // Price
      fields[3] = database.substring( Token2+1, Token3 );          // Product Name/Description
      fields[4] = database.substring( Token3+1, Token4 );          // Shipping Cost
      fields[5] = database.substring( Token4+1, database.length ); // CHANGED TO ITEM COST *****

      item_id 		= fields[0];
      item_quant 	= parseInt (fields[1]);
      item_price 	= parseFloat (fields[2]);
	    
      fSubtotal  += (item_quant * item_price);
      fShipping  += (item_quant * parseFloat(fields[4]) );
      fQuant += (item_quant);

      fItemtotal = item_quant * item_price;
      // For "JAN2012" promo, halve the price
      if (item_id in ISBNS_JAN2012 && today < feb1) {
          fDiscount += fItemtotal * .50;
      }

      strItemtotal = moneyFormat(fItemtotal);

      if ( bDisplay ) {
         strOutput += "<TR>";
         strOutput += "<TD CLASS=\"nopentry\">"  + fields[0] + "</TD>";
         strOutput += "<TD CLASS=\"nopentry\">"  + fields[3] + "</TD>"; // +++
         strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER>" + fields[1] + "</TD>";
         strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea</TD>";
         strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>"+ MonetarySymbol + strItemtotal + "</TD>";

         if ( DisplayShippingColumn ) {
            if ( parseFloat(fields[4]) > 0 )
               strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[4]) + "/ea</TD>";
            else
               strOutput += "<TD CLASS=\"nopentry\">N/A</TD>";
         }

         strOutput += "</TR>";
      }

      if ( AppendItemNumToOutput ) {
         strFooter = i;
      } else {
         strFooter = "";
      }
      if ( PaymentProcessor != '' ) {
         //Process description field for payment processors instead of hidden values.
         //Format Description of product as:
         // ID, Name, Qty X
         strPP += fields[0] + ", " + fields[3];
         if ( fields[5] != "" )
            strPP += " - " + fields[5];
         strPP += ", Qty. " + fields[1] + "\n";
      } else {
         strOutput += "<input type=hidden name=\"" + OutputItemId        + strFooter + "\" value=\"" + fields[0] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemQuantity  + strFooter + "\" value=\"" + fields[1] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemPrice     + strFooter + "\" value=\"" + MonetarySymbol + moneyFormat(fields[2]) + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemName      + strFooter + "\" value=\"" + fields[3] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemShipping  + strFooter + "\" value=\"" + fields[4] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemXtend     + strFooter + "\" value=\"" + MonetarySymbol + moneyFormat(fields[1] * fields[2]) + "\">";
      }
   }
   	
   strSubtotal = moneyFormat(fSubtotal);
   strDiscount = moneyFormat(fDiscount);
   
   if (strShippingDest == "MA") { 
     fTax = ((fSubtotal - fDiscount) * TaxRate);  
   } else {
     fTax = 0.00
   }
   
   strTax = moneyFormat(fTax);
  
   // This calculates shipping for non-internatinal orders.
   // It's a flat rate of $3.95 for between 1 and 4 books.
   // Most books have a shipping rate of $3.95 built in
   // so if te shipping rate tops 16.00, that's more than
   // 4 books.
   if (strShippingDest == "INT" || fShipping > 16.00) {
   
     // We're not shipping to USA, or there are 5 ore more books
     // so it's custom shipping rates
     fShipping   = 0.00;
     strShipping = 'TBD';
     strTotal    = 'TBD';
   
   } else {
   
     if (fShipping > 3.95) {
       // There are between 1 and 4 actual books, so the rate is $3.95.
       fShipping   = 3.95;
	 }
	 
	 strShipping = MonetarySymbol + moneyFormat(fShipping);
	 fTotal = fSubtotal - fDiscount + fShipping +fTax;
	 strTotal    = MonetarySymbol + moneyFormat(fTotal);  
   }

   if ( bDisplay ) {
   
      strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=6> </TD></TR>";
         
      strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strSUB+"</B></TD>";
      strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B> " + MonetarySymbol + strSubtotal + "</B></TD>";
      strOutput += "</TR>";
      
      strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strDIS+" PROMO CODE: " + strPromoCode + "</B></TD>";
      strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>- " + MonetarySymbol + strDiscount + "</B></TD>";
      strOutput += "</TR>";
      
      strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=6> </TD></TR>";

      if ( DisplayTaxRow || TaxByRegion ) {
         strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strTAX+"</B></TD>";
         strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strTax + "</B></TD>";
         strOutput += "</TR>";
      }

     if ( DisplayShippingRow ) {
         strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strSHIP+"</B></TD>";
         strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + strShipping + "</B></TD></TR>";
      }
      
      strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strTOT+"</B></TD>";
      strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B> " + strTotal + "</B></TD>";
      strOutput += "</TR>";

      strOutput += "</TABLE>";

      
      if ( PaymentProcessor == 'an') {
         //Process this for Authorize.net WebConnect
         strOutput += "<input type=hidden name=\"x_Version\" value=\"3.0\">";
         strOutput += "<input type=hidden name=\"x_Show_Form\" value=\"PAYMENT_FORM\">";
         strOutput += "<input type=hidden name=\"x_Description\" value=\""+ strPP + "\">";
         strOutput += "<input type=hidden name=\"x_Amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
      } else if ( PaymentProcessor == 'wp') {
         //Process this for WorldPay
         strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
         strOutput += "<input type=hidden name=\"amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
      } else if ( PaymentProcessor == 'lp') {
         //Process this for LinkPoint         
         strOutput += "<input type=hidden name=\"mode\" value=\"fullpay\">";
         strOutput += "<input type=hidden name=\"chargetotal\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
         strOutput += "<input type=hidden name=\"tax\" value=\""+ MonetarySymbol + strTax + "\">";
         strOutput += "<input type=hidden name=\"subtotal\" value=\""+ MonetarySymbol + strTotal + "\">";
         strOutput += "<input type=hidden name=\"shipping\" value=\""+ MonetarySymbol + strShipping + "\">";
         strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
      } else {
         strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strSubtotal + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderDiscount+"\" value=\""+ MonetarySymbol + strDiscount + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ strShipping + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTax+"\"      value=\""+ MonetarySymbol + strTax + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\"    value=\""+ strTotal + "\">";
      }
   }

   document.write(strOutput);
   document.close();
}

//=====================================================================||
//               END NOP Design SmartPost Shopping Cart                ||
//=====================================================================||


