// modified for parkderm.com
//
//=====================================================================||
//               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         = false;
TaxRate               = 0.0825; // check correct tax rate!!!!!
TaxByRegion           = true;
TaxPrompt             = 'For tax purposes, please select if you are a CA resident before continuing';
TaxablePrompt         = 'CA Residents';  // check correct state!!!
NonTaxablePrompt      = 'Other States';
MinimumOrder          = 0.00;
MinimumOrderPrompt    = 'Your order is below our minimum order, please order more before checking out.';
DisplayUPSQuote       = true;
ShippingEstPrompt		 = 'Please enter in you zip code to get the shipping estimate.';
//Payment Processor Options:
PaymentProcessor      = '';
ShippingMethods       = "SHIPPING METHODS";

//Options for Programmers:
OutputItemId          = 'ID_';
OutputItemQuantity    = 'QUANTITY_';
OutputItemPrice       = 'PRICE_';
OutputItemName        = 'NAME_';
OutputItemShipping    = 'SHIPPING_';
OutputItemAddtlInfo   = 'ADDTLINFO_';
OutputItemWeight	  = 'WEIGHT_';
OutputOrderSubtotal   = 'SUBTOTAL';
OutputOrderShipping   = 'SHIPPING';
OutputOrderTax        = 'TAX';
OutputOrderTotal      = 'TOTAL';
AppendItemNumToOutput = true;
HiddenFieldsToCheckout = false;


//=====================================================================||
//---------------------------------------------------------------------||
//    YOU DO NOT NEED TO MAKE ANY MODIFICATIONS BELOW THIS LINE        ||
//---------------------------------------------------------------------||
//=====================================================================||


//---------------------------------------------------------------------||
//                      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 cart is full, please proceed to checkout.";
   strAdded  = " added to your shopping cart.";
   strRemove = "Click 'Ok' to remove this product from your shopping cart.";
   strILabel = "Product Id";
   strDLabel = "Product Name/Description";
   strQLabel = "Quantity";
   strPLabel = "Price";
   strSLabel = "Shipping";
   strRLabel = "Remove From Cart";
   strWLabel = "Weight";
   strRButton= "Remove";
   strSUB    = "SUBTOTAL";
   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.WEIGHT == null )
      strWEIGHT  = "0.00";
   else
      strWEIGHT  = thisForm.WEIGHT.value;

   if ( thisForm.ADDITIONALINFO == null ) {
      strADDTLINFO = "";
   } else {
      strADDTLINFO = thisForm.ADDITIONALINFO[thisForm.ADDITIONALINFO.selectedIndex].value;
   }
   if ( thisForm.ADDITIONALINFO2 != null ) {
      strADDTLINFO += "; " + thisForm.ADDITIONALINFO2[thisForm.ADDITIONALINFO2.selectedIndex].value;
   }
   if ( thisForm.ADDITIONALINFO3 != null ) {
      strADDTLINFO += "; " + thisForm.ADDITIONALINFO3[thisForm.ADDITIONALINFO3.selectedIndex].value;
   }
   if ( thisForm.ADDITIONALINFO4 != null ) {
      strADDTLINFO += "; " + thisForm.ADDITIONALINFO4[thisForm.ADDITIONALINFO4.selectedIndex].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);
      Token5 = database.indexOf("|", Token4+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, Token5 );
      fields[6] = database.substring( Token5+1, database.length );

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


   if ( !bAlreadyInCart ) {
      iNumberOrdered++;

      if ( iNumberOrdered > 12 )
         alert( strSorry );
      else {
         dbUpdatedOrder = strID_NUM    + "|" + 
                          strQUANTITY  + "|" +
                          strPRICE     + "|" +
                          strNAME      + "|" +
                          strSHIPPING  + "|" +
                          strWEIGHT    + "|" +
                          strADDTLINFO;

         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);
      Token5 = database.indexOf("|", Token4+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, Token5 );
      fields[6] = database.substring( Token5+1, database.length );

      dbUpdatedOrder = fields[0] + "|" +
                       NewQuantity + "|" +
                       fields[2] + "|" +
                       fields[3] + "|" +
                       fields[4] + "|" +
                       fields[5] + "|" +
                       fields[6];
      strNewOrder = "Order." + OrderItem;
      DeleteCookie(strNewOrder, "/");
      SetCookie(strNewOrder, dbUpdatedOrder, 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:    change shipping methods                                ||
// coded by ken                                                        ||
//---------------------------------------------------------------------||

function changeShippingMethods(sc,meth){
	//alert("hello");
	//document.getElementById('shippingCostCell').innerHTML = "<b>" + MonetarySymbol + moneyFormat(sc) +"</b>";
	//DeleteCookie("sMethod, "/");
	SetCookie("sMethod", meth, null, "/");	
	location.href=location.href; 
}

//---------------------------------------------------------------------||
// FUNCTION:    keep tax in cookie                               ||
// coded by ken                                                        ||
//---------------------------------------------------------------------||

function keepTax(t,m){
	//alert("hello");
	//document.getElementById('shippingCostCell').innerHTML = "<b>" + MonetarySymbol + moneyFormat(sc) +"</b>";
	//DeleteCookie("sMethod, "/");
	SetCookie("sT", t, null, "/");	
	SetCookie("sM", m, null, "/");
}


//---------------------------------------------------------------------||
// FUNCTION:    ManageCart                                             ||
// PARAMETERS:  Null                                                   ||
// RETURNS:     Product Table Written to Document                      ||
// PURPOSE:     Draws current cart product table on HTML page          ||
//---------------------------------------------------------------------||
function ManageCart( ) {
   var iNumberOrdered = 0;    //Number of products ordered
   var fTotal         = 0;    //Total cost of order
   var fWeight        = 0;    //Total weight of order
   var fTax           = 0;    //Tax amount
   var fShipping      = 0;    //Shipping amount
   var strTotal       = "";   //Total cost formatted as money
   var strTax         = "";   //Total tax formatted as money
   var strShipping    = "";   //Total shipping formatted as money
   var strOutput      = "";   //String to be written to page
   var bDisplay       = true; //Whether to write string to the page (here for programmers)
   var strUPS         = "";   //UPS Cost formatted as money
   var fUPS           = 0;
   var shipping_type  = "";
   var strSnH         = "";//Shipping & Handling";
   var iMethod		  = ""    //shipping method - added by ken   

   iMethod = GetCookie("sMethod");  //added by ken

   if ( iMethod == null ){
	   iMethod = "ups2";
   }  
      

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

 if ( bDisplay )
      strOutput = "<TABLE cellpadding=5 cellspacing=2 border=0 bordercolor='#BC53A8' CLASS=\"nopcart\"><TR>" +
                  "<TD bgcolor='#E6E4DB' CLASS=\"nopentry\"><B>"+strILabel+"<B/></TD>" +
                  "<TD bgcolor='#E6E4DB' CLASS=\"nopentry\"><B>"+strDLabel+"</B></TD>" +
                  "<TD bgcolor='#E6E4DB' CLASS=\"nopentry\"><B>"+strQLabel+"</B></TD>" +
                  "<TD bgcolor='#E6E4DB' CLASS=\"nopentry\"><B>"+strPLabel+"</B></TD>" +
                  (DisplayShippingColumn?"<TD bgcolor='#E6E4DB' CLASS=\"header\"><B>"+strSLabel+"</B></TD>":"") +
                  "<TD bgcolor='#E6E4DB' CLASS=\"nopentry\"><B>"+strRLabel+"</B></TD></TR>";

   if ( iNumberOrdered == 0 ) {
      strOutput += "<TR><TD COLSPAN=6 CLASS=\"nopentry\"><CENTER><BR><B>Your cart 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);
      Token5 = database.indexOf("|", Token4+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, Token5 );          // Weight
      fields[6] = database.substring( Token5+1, database.length ); //Additional Information

      fTotal     += (parseInt(fields[1]) * parseFloat(fields[2]) );
      fWeight     += (parseInt(fields[1]) * parseFloat(fields[5]) );      
//      fShipping  += (parseInt(fields[1]) * parseFloat(fields[4]) );
//-- added 8/6/04  fixed Shipping cost
     // fShipping = 5.00;

      //fTax        = (fTotal * TaxRate);
      strTotal    = moneyFormat(fTotal);
      //strTax      = moneyFormat(fTax);
     // strShipping = moneyFormat(fShipping);

     if ( bDisplay ) {
         strOutput += "<TR><TD bgcolor='#E6E4DB' CLASS=\"bodytext\">"  + fields[0] + "</TD>";

         if ( fields[6] == "" )
            strOutput += "<TD bgcolor='#F5F4F1' CLASS=\"bodytext\">"  + fields[3] + "</TD>";
         else
            strOutput += "<TD bgcolor='#F5F4F1'CLASS=\"bodytext\">"  + fields[3] + " - <I>"+ fields[5] + "</I></TD>";

         strOutput += "<TD bgcolor='#F5F4F1' CLASS=\"bodytext\"><INPUT class='inputTxtquantity' TYPE=TEXT NAME=Q SIZE=2 VALUE=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";
         strOutput += "<TD bgcolor='#F5F4F1'CLASS=\"bodytext\">"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea</TD>";

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

         strOutput += "<TD bgcolor='#F5F4F1' CLASS=\"bodytext\" ALIGN=left><input type=button value=\" "+strRButton+" \" onClick=\"RemoveFromCart("+i+")\" class=\"inputButton\"></TD></TR>";
      }

      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] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemWeight    + strFooter + "\" value=\"" + fields[5] + "\">";
         strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[6] + "\">";
      }

   }

   if ( bDisplay ) {
      strOutput += "<TR><TD bgcolor='#F5F4F1'CLASS=\"nopentry\" COLSPAN=4><B>"+strSUB+"</B></TD>";
      strOutput += "<TD bgcolor='#F5F4F1' CLASS=\"nopentry\" COLSPAN=2><B>" + MonetarySymbol + strTotal + "</B></TD>";
      strOutput += "</TR>";

      if ( DisplayShippingRow ) 
	  {       /// REAL TIME SHIPPING
		      var hasQueryString = document.URL.indexOf('?');
		      if (hasQueryString != -1) 
			  {
			      QueryString_Parse();
			      fUPS = parseFloat( QueryString( "ups" ) );
			      strUPS = moneyFormat(fUPS);
			      fShipping = parseFloat(strUPS);
			      
				  QueryString_Parse();
			      shipping_type = QueryString( "ship_type" );
				  //alert(shipping);
				  //if( fShipping > 0 )
				  //{
				  SetCookie("sCost", fShipping, null, "/");
				  //alert( GetCookie("sCost") );
				 // }
			   }
			
		  /*-------------SHIPPING METHODS------------------- */
		  strOutput += "<TR><TD bgcolor='#F5F4F1' CLASS=\"nopentry\"><B>"+ShippingMethods+"</B></TD>";
		  strOutput += "<TD><input type=\"radio\" name=\"shipping_mtd\" value=\"GND\">Gound Shipping</TD>";
		  strOutput += "<TD COLSPAN=2><input type=\"radio\" name=\"shipping_mtd\" value=\"1DA\">UPS Next Day Air</TD>";
		  strOutput += "<TD><input type=\"radio\" name=\"shipping_mtd\" value=\"2DA\">UPS 2nd Day Air</TD>";
		  strOutput += "<TD><input type=hidden name=\"ship_type\" value=\""+shipping_type+"\"></TD>";
		  strOutput += "</TR>";
		  
		  strOutput += "<TR><TD bgcolor='#F5F4F1' CLASS=\"nopentry\"><B>"+strSnH+"</B></TD>";
      	  strOutput += "<TD COLSPAN=3>";
		  strOutput += "Please enter destination zipcode for the shipping estimate.<br><input class='inputTxtquantity' type=\"text\" name=\"d\" value=\"\"\ maxlength=5 size=5><input type=\"hidden\" name=\"w\" value=\""+fWeight+"\"><input type=\"hidden\" name=\"mstrPage\" value=\"/cart/mycart.htm\"><input type=\"hidden\" name=\"o\" value=\"10065\">&nbsp;<input type=button value=\"Submit\" onClick=\"GetUPSCost();\" class=\"inputButton\"><input type=hidden value=\""+strUPS+"\" name=\"shippinghandling\">";
		  strOutput += "</TD>";
		  strOutput += "<TD><b>"+MonetarySymbol + moneyFormat(fShipping)+"</b></TD>";
		  strOutput += "</TR>";
		  
		/* strOutput += "<TR><TD bgcolor='#F5F4F1' CLASS=\"nopentry\" colspan=3>";
		 strOutput += "Please insert your zip code for the shipping estimate<br><input class='inputTxtquantity' type=\"text\" name=\"d\" value=\"\"\><input type=\"hidden\" name=\"w\" value=\""+fWeight+"\"><input type=\"hidden\" name=\"mstrPage\" value=\"/cart/mycart.htm\"><input type=\"hidden\" name=\"o\" value=\"63139\">&nbsp;<input type=button value=\"Submit\" onClick=\"GetUPSCost();\" class=\"inputButton\"><input type=hidden value=\""+strUPS+"\" name=\"shippinghandling\"></TD></TR>"; */
         //strOutput += "<TR><TD bgcolor='#F5F4F1' CLASS=\"nopentry\"><B>"+strSHIP+"</B></TD>";

		 //check subtotal - show shipping costs - coded by ken		 
// this is where you change the shipping cost **************************************************
		 /* if (parseFloat(fTotal)>0 && parseFloat(fTotal)<=9000){
			strOutput +="<TD bgcolor='#F5F4F1' COLSPAN=3><TABLE>"
			if (iMethod == "usps"){
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" checked  onClick=\"changeShippingMethods(0,'usps');\">UPS Ground Mail</td></tr>";
				fShipping = 0;
				SetCookie("sCost", 0, null, "/");
			}else{
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" onClick=\"changeShippingMethods(0,'usps');\">UPS Ground Mail</td></tr>";
			}
			if (iMethod == "ups1"){
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" checked onClick=\"changeShippingMethods(11.5,'ups1');\">UPS 3 Day </td></tr>";
				fShipping = 11.5;
				SetCookie("sCost", 11.5, null, "/");
			}else{
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" onClick=\"changeShippingMethods(11.5,'ups1');\">UPS 3 Day</td></tr>";
			}
			if (iMethod == "ups2"){
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" checked onClick=\"changeShippingMethods(15.5,'ups2');\">UPS 2nd Day Air</td></tr>";
				fShipping = 15.5;
				SetCookie("sCost", 15.5, null, "/");
			}else{
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" onClick=\"changeShippingMethods(15.5,'ups2');\">UPS 2nd Day Air</td></tr>";
			}
			if (iMethod == "upsn"){
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" checked onClick=\"changeShippingMethods(25.5,'upsn');\">UPS Next Day Air</td></tr>";
				fShipping = 25.5;
				SetCookie("sCost", 25.5, null, "/");
			}else{
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" onClick=\"changeShippingMethods(25.5,'upsn');\">UPS Next Day Air</td></tr>";
			}			
			strOutput +="</TABLE></TD>";
		  }
		  
		  if (parseFloat(fTotal)<=0){
			strOutput +="<TD bgcolor='#F5F4F1' COLSPAN=3><TABLE>"
			if (iMethod == "usps"){
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" checked  onClick=\"changeShippingMethods(0,'usps');\">UPS Ground Mail</td></tr>";
				fShipping = 0;
				SetCookie("sCost", 0, null, "/");
			}else{
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" onClick=\"changeShippingMethods(0,'usps');\">UPS Ground Mail</td></tr>";
			}
			if (iMethod == "usps1"){
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" checked  onClick=\"changeShippingMethods(11.5,'usps1');\">UPS 3 Day</td></tr>";
				fShipping = 11.5;
				SetCookie("sCost", 11.5, null, "/");
			}else{
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" onClick=\"changeShippingMethods(11.5,'usps1');\">UPS 3 Day</td></tr>";
			}
			if (iMethod == "ups2"){
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" checked onClick=\"changeShippingMethods(15.50,'ups2');\">UPS 2nd Day Air</td></tr>";
				fShipping = 0;
				SetCookie("sCost", 0, null, "/");
			}else{
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" onClick=\"changeShippingMethods(15.5,'ups2');\">UPS 2nd Day Air</td></tr>";
			}
			if (iMethod == "upsn"){
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" checked onClick=\"changeShippingMethods(25.5,'upsn');\">UPS Next Day Air</td></tr>";
				fShipping = 0;
				SetCookie("sCost", 0, null, "/");
			}else{
				strOutput += "<tr><td CLASS=\"nopentry\"><input name=\"shippingmethod\" type=\"radio\" onClick=\"changeShippingMethods(25.5,'upsn');\">UPS Next Day Air</td></tr>";
			}
			strOutput +="</TABLE></TD>";
		  }*/
		 
        // strOutput += "<TD id=\"shippingCostCell\" bgcolor='#F5F4F1' CLASS=\"nopentry\"><B>";
		// strOutput += MonetarySymbol + moneyFormat(fShipping);
		 //strOutput += "</B></TD>";
         strOutput += "</TR>";
		 
      }
	  //end

	  // calculate tax
	  fTax        = (fTotal+fShipping) * TaxRate;
      //strTotal    = moneyFormat(fTotal);
      strTax      = moneyFormat(fTax);

	  var iT			  = ""    // if taxable - added by ken
	  iT = GetCookie("sT");  //added by ken

	  if (iT == "1"){			//added by ken
		keepTax("1",strTax);
	  }
	  

      if ( DisplayTaxRow || TaxByRegion ) {
         if ( TaxByRegion ) {
            strOutput += "<TR><TD bgcolor='#F5F4F1'CLASS=\"nopentry\" COLSPAN=4><B>"+strTAX+"</B></TD>";
            strOutput += "<TD bgcolor='#F5F4F1' CLASS=\"nopentry\" COLSPAN=2><B>";
			//following changed by ken
			if (iT == "1")
			{
				strOutput += "<input type=radio name=\""+OutputOrderTax+"\" value=\"" + strTax + "\" onClick=\"keepTax(" + 1 + "," + strTax+");\" checked>";
			} else{
				strOutput += "<input type=radio name=\""+OutputOrderTax+"\" value=\"" + strTax + "\" onClick=\"keepTax(" + 1 + "," + strTax+");\">";
			}            
            strOutput += TaxablePrompt + ": " + MonetarySymbol + strTax;
			if (iT == "0")
			{
				strOutput += "<BR><input type=radio name=\""+OutputOrderTax+"\" value=\"0.00\" onClick=\"keepTax(" + 0 + "," + 0+");\" checked>";
			} else{
				strOutput += "<BR><input type=radio name=\""+OutputOrderTax+"\" value=\"0.00\" onClick=\"keepTax(" + 0 + "," + 0+");\">";
			} 
            // end
            strOutput += NonTaxablePrompt + ": " + MonetarySymbol + "0.00";
            strOutput += "</B></TD>";
            strOutput += "</TR>";
         } else {
            strOutput += "<TR><TD bgcolor='#F4E2F9' CLASS=\"header\" COLSPAN=4><B>"+strTAX+"</B></TD>";
            strOutput += "<TD bgcolor='#F4E2F9' CLASS=\"header\" COLSPAN=2><B>" + MonetarySymbol + strTax + "</B></TD>";
            strOutput += "</TR>";
         }
      }

      if ( !TaxByRegion ) {
         strOutput += "<TR><TD bgcolor='#F4E2F9' CLASS=\"header\" COLSPAN=4><B>"+strTOT+"</B></TD>";
         strOutput += "<TD bgcolor='#F4E2F9' CLASS=\"header\" COLSPAN=2><B>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "</B></TD>";
         strOutput += "</TR>";
      }
      strOutput += "</TABLE>";

	  if ( HiddenFieldsToCheckout ) {
         strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strTotal + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + strShipping + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTax+"\"      value=\""+ MonetarySymbol + strTax + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\"    value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">";
		 //strOutput += "<input type=hidden name=ship_mtd value\""+client_s_type+"\">";
      }
   }
   g_TotalCost = (fTotal + fShipping + fTax);

   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;
      }
   }
  
   if ( DisplayUPSQuote ) {
      if ( document.mycart.shippinghandling.value.length == 0 ) {
         alert( ShippingEstPrompt );
         return false;
      }
   }
   
   if( parseFloat(document.mycart.shippinghandling.value) <= 5.00 )
   {
	   alert("Enter a valid zipcode to compute the shipping estimate.");
	   return false;
   }

   return true;
}

//---------------------------------------------------------------------||
// FUNCTION:    CheckoutCart                                           ||
// PARAMETERS:  Null                                                   ||
// RETURNS:     Product Table Written to Document                      ||
// PURPOSE:     Draws current cart product table on HTML page for      ||
//              checkout.                                              ||
//---------------------------------------------------------------------||
function CheckoutCart( ) {
   var iNumberOrdered = 0;    //Number of products ordered
   var fTotal         = 0;    //Total cost of order
   var fTax           = 0;    //Tax amount
   var fShipping      = 0;    //Shipping amount
   var fWeight		  = 0;    //Weight amount
   var strTotal       = "";   //Total cost formatted as money
   var strTax         = "";   //Total tax formatted as money
   var strShipping    = "";   //Total shipping formatted as money
   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 iM			  = ""    // Tax amount - added by ken
   iM = GetCookie("sM");  //added by ken
   fTax = parseFloat(iM);
   strTax = moneyFormat(fTax);

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

   /*if ( TaxByRegion ) {
      QueryString_Parse();
      fTax = parseFloat( QueryString( OutputOrderTax ) );
      strTax = moneyFormat(fTax);	
   }*/  // commentted out by ken
   
   //alert( GetCookie("ship_type") );

   if ( bDisplay )
      strOutput = "<TABLE cellpadding=8 cellspacing=0 border=1 bordercolor='#FFFFFF' CLASS=\"nopcart\"><TR>" +
                  "<TD bgcolor='#E6E4DB' CLASS=\"nopheader\"><B>"+strILabel+"</B></TD>" +
                  "<TD bgcolor='#E6E4DB' CLASS=\"nopheader\"><B>"+strDLabel+"</B></TD>" +
                  "<TD bgcolor='#E6E4DB' CLASS=\"nopheader\"><B>"+strQLabel+"</B></TD>" +
                  "<TD bgcolor='#E6E4DB' CLASS=\"nopheader\"><B>"+strPLabel+"</B></TD>" +
                  (DisplayShippingColumn?"<TD CLASS=\"nopheader\"><B>"+strSLabel+"</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);
      Token5 = database.indexOf("|", Token4+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, Token5 );		   // Weight
      fields[5] = database.substring( Token5+1, database.length ); // Additional Information

      fTotal     += (parseInt(fields[1]) * parseFloat(fields[2]) );
	  fWeight     += (parseInt(fields[1]) * parseFloat(fields[5]) );  	  
      //fShipping  += (parseInt(fields[1]) * parseFloat(fields[4]) ); // commented out by ken
      //if ( !TaxByRegion ) fTax = (fTotal * TaxRate);// commented out by ken
	  
      //if ( !TaxByRegion ) strTax = moneyFormat(fTax);//commented out by ken
      QueryString_Parse();
	  fShipping = parseFloat( QueryString( "shippinghandling" ) );
	  
	  QueryString_Parse();
	  shipping_type = QueryString( "ship_type" );
	  shipping_type = resolve_shipping_method(shipping_type);
	  
	  //fShipping = parseFloat(GetCookie("sCost"));
	  //alert(fShipping);
	  //alert( fShipping );

      if ( bDisplay ) {
         strOutput += "<TR><TD bgcolor='#E6E4DB' CLASS=\"nopentry\">"  + fields[0] + "</TD>";

         if ( fields[6] == "" )
            strOutput += "<TD bgcolor='#F5F4F1' CLASS=\"nopentry\">"  + fields[3] + "</TD>";
         else
            strOutput += "<TD bgcolor='#F5F4F1' CLASS=\"nopentry\">"  + fields[3] + " - <I>"+ fields[5] + "</I></TD>";

         strOutput += "<TD bgcolor='#F5F4F1' CLASS=\"nopentry\">" + fields[1] + "</TD>";
         strOutput += "<TD bgcolor='#F5F4F1' CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea</TD>";

         if ( DisplayShippingColumn ) {
            if ( parseFloat(fields[4]) > 0 )
               strOutput += "<TD bgcolor='#FBF4FD' CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[4]) + "/ea</TD>";
            else
               strOutput += "<TD bgcolor='#FBF4FD' 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=\"" + 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=\"" + OutputItemWeight    + strFooter + "\" value=\"" + fields[5] + "\">";
		 strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[6] + "\">";
      } 

   }
   //fShipping = parseFloat(GetCookie("sCost"));  //added by ken
   //if ( !TaxByRegion ){
		//fTax = parseFloat((fTotal+fShipping) * TaxRate);
   //}//add by ken
	   
      strTotal    = moneyFormat(fTotal);
	  strShipping = moneyFormat(fShipping);
	  //strTax = moneyFormat(fTax);

  if ( bDisplay ) {
      strOutput += "<TR><TD bgcolor='#F5F4F1' CLASS=\"noptotal\" COLSPAN=3><B>"+strSUB+"</B></TD>";
      strOutput += "<TD bgcolor='#F5F4F1' CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strTotal + "</B></TD>";
      strOutput += "</TR>";

	  if ( DisplayShippingRow ) {
         strOutput += "<TR><TD bgcolor='#F5F4F1' CLASS=\"noptotal\" COLSPAN=3><B>"+strSHIP+"</B></TD>";
         strOutput += "<TD bgcolor='#F5F4F1' CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strShipping + "</B></TD>";
         strOutput += "</TR>";		 
      }	  

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

      strOutput += "<TR><TD bgcolor='#F5F4F1' CLASS=\"noptotal\" COLSPAN=3><B>"+strTOT+"</B></TD>";
      strOutput += "<TD bgcolor='#F5F4F1' CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "</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 + strTotal + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + strShipping + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTax+"\"      value=\""+ MonetarySymbol + strTax + "\">";
         strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\"    value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">";
		 strOutput += "<input type=hidden name=\"SHIPPING_METHOD\" value=\""+shipping_type+"\">";
      }
   }
  
  document.write(strOutput);
   document.close();
}

//---------------------------------------------------------------------||
// FUNCTION:    get UPS shipping quote                                 ||
// coded by jason                                                      ||
//---------------------------------------------------------------------||

function GetUPSCost(){
	//alert("hello");
	//document.getElementById('shippingCostCell').innerHTML = "<b>" + MonetarySymbol + moneyFormat(sc) +"</b>";
	//DeleteCookie("sMethod, "/");
	
   var o = document.mycart.o.value;
   var d = document.mycart.d.value;
   var w = document.mycart.w.value;
   var mstrPage = document.mycart.mstrPage.value;
   var shipping_type = get_shipping_method();
   
   if( shipping_type == -1 ){
       alert("Please select a shipping method.");
	   return ;
   }
   //document.mycart.ship_type.value = shipping_type;
   if ( validateZIP(d) )
   {
      location.href="ups.php?o="+o+"&d="+d+"&w="+w+"&mstrPage="+mstrPage+"&shipping_type="+shipping_type;
   }
}

function validateZIP(field) {
   var valid = "0123456789-";
   var hyphencount = 0;

   if (field.length!=5 && field.length!=10) {
      alert("Please enter your US 5 digit or 5 digit+4 zip code.  For international orders, please call Customer Service at 1-314-772-4610.");
      return false;
   }
   for (var i=0; i < field.length; i++) {
      temp = "" + field.substring(i, i+1);
      if (temp == "-") hyphencount++;
      if (valid.indexOf(temp) == "-1") {
         alert("Invalid characters in your zip code.  Please try again.");
         return false;
      }
      if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) {
         alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
         return false;
      }
   }
   return true;
}

function get_shipping_method()
{
   for(var i=0; i < document.mycart.shipping_mtd.length; i++ )
   {
      if( document.mycart.shipping_mtd[i].checked )
	  {
		   return document.mycart.shipping_mtd[i].value ;
	  }
   }
   return -1;
}

function resolve_shipping_method( $ship_type )
{
  switch( $ship_type )
  {
    case "GND":
	  $shipping = "UPS Ground Shipping ";
	  break;
	case "1DA":
	  $shipping = "UPS Next Day Air";
	  break;
	case "2DA":
	  $shipping = "UPS 2nd Day Air";
	  break;
	default:
	  break;
  }
 return $shipping;
}

var changer = "copy"; 
function func_copy_billing_to_shipping()
{
   var thisForm = document.payment;
   if( changer == "copy" ){
       thisForm.s_first.value  = thisForm.b_first.value;
       thisForm.s_last.value   = thisForm.b_last.value;
       thisForm.s_addr.value   = thisForm.b_addr.value;
	   thisForm.s_city.value   = thisForm.b_city.value;
	   thisForm.s_state.value  = thisForm.b_state[thisForm.b_state.selectedIndex].value;
	   thisForm.s_zip.value    = thisForm.b_zip.value;
       changer = "clear";
   }
   else if( changer == "clear" ){
       thisForm.s_first.value  = "";
       thisForm.s_last.value   = "";
       thisForm.s_addr.value   = "";
	   thisForm.s_city.value   = "";
	   thisForm.s_state.value  = "";
	   thisForm.s_zip.value    = "";
       changer = "copy";
   }   
}
//=====================================================================||
//               END NOP Design SmartPost Shopping Cart                ||
//=====================================================================||

