//=====================================================================||
// 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 ||
//=====================================================================||

//=====================================================================||
// UPS Shiping Mod by Stefko V.1.0.0 ||
// ||
// Version History: 02/23/03 V.1.0.0 Released ||
// includes USERENTRY ||
// 03/02/03 V.1.1.0 Now works with Netscape & Opera ||
// added Taxable and Non-taxable product code||
// added MathRound to Weight ||
//=====================================================================||

//---------------------------------------------------------------------||
// 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="../os1/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;
DisplayChangeQty = true;
DisplayShippingColumn = true;
DisplayShippingRow = true;
TaxRate = 0.042; //set taxable region rate ||
DisplayTaxRow = true;
TaxByRegion = false; //leave this at false, UPS Shipping Mod will activate taxable Zone ||
TaxPrompt = 'For tax purposes, please select if you are an Kansas branch of Oasis before continuing'; //Deactivated ||
TaxablePrompt = 'Kansas Branch'; //Deactivated ||
NonTaxablePrompt = 'Other Branches'; //Deactivated ||
MinimumOrder = 1.00;
MinimumOrderPrompt = 'Oops!\n\nWe can not proceed to check out since\nthere is no item in the shopping cart.';
ZipCodePrompt = ' Please enter a valid Zip Code for Shipping calculations.';
MinimumShipping = 4.90;
MinimumWeight = 0.01;
//original syntax - MinimumOrderPrompt = 'Your order is below our minimum order, please order more before checking out.';

NoQtyPrompt = 'You cannot proceed until a Shipping Zone has been selected'; //If attempted to go to checkout before selecting shipping zone ||

//Payment Processor Options:
PaymentProcessor = 'lp';

//Options for Programmers:
OutputItemId = 'ID_';
OutputItemQuantity = 'QUANTITY_';
OutputItemPrice = 'PRICE_';
OutputItemName = 'NAME_';
OutputItemWeight = 'WEIGHT_'; //Added for UPS mod ||
OutputItemAddtlInfo = 'ADDTLINFO_';
OutputItemXtend = 'XTEND_';
OutputOrderZone = 'SHIPZONE';
OutputOrderSubtotal = 'SUBTOTAL';
OutputOrderShipping = 'SHIPPING';
OutputOrderHandling = 'HANDLING';
OutputOrderTax = 'TAX';
OutputOrderTotal = 'TOTAL';
AppendItemNumToOutput = true;
HiddenFieldsToCheckout = true;

//Options for Shipping by Weight:
LocationLabel = 'ZONE';
LocationPrompt = 'For shipping purpose, please select the zone that your location is in.';
MaxWeightPrompt = 'Sorry, maximum weight allowable is 500lbs.';



//=====================================================================||
//---------------------------------------------------------------------||
// 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 = "Qty";
strPLabel = "Price";
strSLabel = "Weight"; //Added for UPS mod ||
strRLabel = "Remove From Cart";
strRButton= "Remove";
strSUB = "SUBTOTAL";
strWTOT = "TOTAL WEIGHT"; //Added for UPS mod ||
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);
}

// PRODUCT SELECTOR
// FUNCTION:    AddOneOfManyToCart
// PARAMETERS:  Form Object PRODUCTSELECTOR
// RETURNS:     Product parameters to order form
// PURPOSE:     selects one of many products to add to shopping cart

function AddOneOfManyToCart(formToUpdate)
{
   selectedObj = formToUpdate.PRODUCTSELECTOR[formToUpdate.PRODUCTSELECTOR.selectedIndex];

   nameVal = selectedObj.getAttribute("name");
   if (nameVal == "select") {
      alert('Please select an option');
      return false;
   }

   formToUpdate.NAME.value = nameVal;

   costVal = selectedObj.getAttribute("cost");
   formToUpdate.PRICE.value = costVal;

   id_numVal = selectedObj.getAttribute("id_num");
   formToUpdate.ID_NUM.value = id_numVal;

   shippingVal = selectedObj.getAttribute("shipping");
   formToUpdate.SHIPPING.value = shippingVal;

   weightVal = selectedObj.getAttribute("weight");
   formToUpdate.WEIGHT.value = weightVal;

   switch( formToUpdate.PRODUCTSELECTOR[formToUpdate.PRODUCTSELECTOR.selectedIndex].value ) {
   }
   AddToCart(formToUpdate);
}
//---------------------------------------------------------------------||
// FUNCTION: AddToCart ||
// PARAMETERS: Form Object ||
// RETURNS: Cookie to user's browser, with prompt ||
// PURPOSE: Adds a product to the user's shopping cart ||
// EXTRAS ADDED IN: USERENTRY for customer text input ||
//---------------------------------------------------------------------||
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.WEIGHT == null ) //Added for UPS mod ||
strSHIPPING = "0";
else
strSHIPPING = 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; }
if ( thisForm.USERENTRY != null ) {
strADDTLINFO += " " + thisForm.USERENTRY.value;
}
if ( thisForm.USERENTRY2 != null ) {
strADDTLINFO += " " + thisForm.USERENTRY2.value;
}
if ( thisForm.USERENTRY3 != null ) {
strADDTLINFO += " " + thisForm.USERENTRY3.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 &&
fields[5] == strADDTLINFO
) {
bAlreadyInCart = true;
dbUpdatedOrder = strID_NUM + "|" +
(parseInt(strQUANTITY)+parseInt(fields[1])) + "|" +
strPRICE + "|" +
strNAME + "|" +
strSHIPPING + "|" +
strADDTLINFO;
strNewOrder = "Order." + i;
DeleteCookie(strNewOrder, "/");
SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
notice = strAdded + "\n-------------------------------------\n" + "Quantity : " + strQUANTITY + "\nProduct : " + strNAME;
break;
}
}


if ( !bAlreadyInCart ) {
iNumberOrdered++;

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

strNewOrder = "Order." + iNumberOrdered;
SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
SetCookie("NumberOrdered", iNumberOrdered, null, "/");
notice = strAdded + "\n-------------------------------------\n" + "Quantity : " + strQUANTITY + "\nProduct : " + strNAME;
}
}

if ( DisplayNotice && notice!=''){
alert(notice);
}else{
}

}


//---------------------------------------------------------------------||
// 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;
}
}


//---------------------------------------------------------------------||
// 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 ||
// EXTRAS ADDED IN: Code to enable UPS mod. ||
//---------------------------------------------------------------------||
function ManageCart( ) {
var iNumberOrdered = 0; //Number of products ordered
var fTotal = 0; //Total cost of order
var fTax = 0; //Tax amount
var fWeight = 0; //Weight
var fShipping = 0; //Shipping amount
var fHandling = 5.00;
var strTotal = ""; //Total cost formatted as money
var strTax = ""; //Total tax formatted as money
var strShipping = ""; //Total shipping formatted as money
var strHandling = "";
var strOutput = ""; //String to be written to page
var bDisplay = true; //Whether to write string to the page (here for programmers)

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

//REM ADD THIS FOR ZIPCODE FUNCTIONALITY

ANS = GetCookie("ZoneSelected");
if (ANS == null) ANS = 0; // Code to use Kingsport as default checked if customer goes to Checkout with an empty Cart ||


if ( bDisplay )
strOutput = "<TABLE CELLSPACING=0 CELLPADDING=2 BORDER=0 CLASS=\"nopcart\"><TR>" +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strILabel+"</B></TD>" +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strDLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strQLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strPLabel+"</B></TD>" +
(DisplayShippingColumn?"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strSLabel+"</B></TD>":"") +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><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++ ) {
even = Math.round(i/2);
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 ); // Weight
fields[5] = database.substring( Token4+1, database.length ); //Additional Information

fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );
fWeight += (parseInt(fields[1]) * parseFloat(fields[4]) );
fWeight = Math.round(fWeight * 100)/100;
var strProductId = fields[0];
if( strProductId[0] != 'n' ) {
fTax += (parseInt(fields[1]) * parseFloat(fields[2]) + fShipping )  * TaxRate;
fTax = Math.round(fTax * 100)/100;
}

strTotal = moneyFormat(fTotal);
strHandling = moneyFormat(fHandling);
strTax = moneyFormat(fTax);

if ( bDisplay ){
if ((even) ==(i/2) ) {
strOutput += "<TR><TD CLASS=\"nopeven\" ALIGN=CENTER>" + fields[0] + "</TD>";

if ( fields[5] == "" )
strOutput += "<TD CLASS=\"nopeven\">" + fields[3] + "</TD>";
else
strOutput += "<TD CLASS=\"nopeven\">" + fields[3] + " - <I>"+ fields[5] + "</I></TD>";

if ( DisplayChangeQty ) {
strOutput += "<TD CLASS=\"nopeven\" ALIGN=CENTER><INPUT TYPE=TEXT NAME=Q SIZE=2 VALUE=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";
} else {
strOutput += "<TD CLASS=\"nopeven\" ALIGN=CENTER>" + fields[1] + "</TD>";
}
strOutput += "<TD CLASS=\"nopeven\" ALIGN=RIGHT>"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea</TD>";

if ( DisplayShippingColumn ) {

strOutput += "<TD CLASS=\"nopeven\" ALIGN=RIGHT>"+ MonetarySymbol + moneyFormat(parseInt(fields[1]) * parseFloat(fields[2]) ) + "</TD>";
}else {
strOutput += "<TD CLASS=\"nopeven\" ALIGN=RIGHT>N/A</TD>";
}

strOutput += "<TD CLASS=\"nopeven\" ALIGN=CENTER><input type=button value=\" "+strRButton+" \" onClick=\"RemoveFromCart("+i+")\" class=\"nopbutton\"></TD></TR>";
}
else {
strOutput += "<TR><TD CLASS=\"nopentry\" ALIGN=CENTER>" + fields[0] + "</TD>";

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

if ( DisplayChangeQty ) {
strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER><INPUT TYPE=TEXT NAME=Q SIZE=2 VALUE=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";
} else {
strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER>" + fields[1] + "</TD>";
}
strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea</TD>";

if ( DisplayShippingColumn ) {

strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>"+ MonetarySymbol + moneyFormat(parseInt(fields[1]) * parseFloat(fields[2]) ) + "</TD>";
}else {
strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>N/A</TD>";
}

strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER><input type=button value=\" "+strRButton+" \" onClick=\"RemoveFromCart("+i+")\" class=\"nopbutton\"></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=\"" + OutputItemWeight + strFooter + "\" value=\"" + fields[4] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">";
}

}

if ( bDisplay ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4 ALIGN=RIGHT><B>"+strSUB+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + strTotal +"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" +strSpace+"</B></TD>";
strOutput += "</TR>";

//this displays the shipping matrix and sets the value for each zone ||
if ( fWeight > 0 ) {
if (( DisplayShippingRow ) && ( iNumberOrdered != 0)) {
strOutput += "<TR><TD CLASS=\"nopship\" COLSPAN=2 ALIGN=RIGHT><B>"+"USPS Priority Mail"+"</B></TD>";
strOutput += "<TD CLASS=\"nopship\" COLSPAN=4>";
strOutput += "<TR><TD CLASS=\"nopship\" COLSPAN=5 ALIGN=RIGHT><B>"+"Enter 1st 3 Digits of ZipCode: "+"</B><input type=text size=2 name=\"ZONE\" value=\"" + "\" onBlur=\"ComputeShipping(this.value, "+fWeight+")\"</TD>";
//strOutput += "<input type=radio name=\"ZONE\" value=\"0" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
//strOutput += "1";
//strOutput += "<BR><input type=radio name=\"ZONE\" value=\"1" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
//strOutput += "2";
//strOutput += "<BR><input type=radio name=\"ZONE\" value=\"2" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
//strOutput += "3";
//strOutput += "<BR><input type=radio name=\"ZONE\" value=\"3" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
//strOutput += "4";
//strOutput += "<BR><input type=radio name=\"ZONE\" value=\"4" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
//strOutput += "5";
//strOutput += "<BR><input type=radio name=\"ZONE\" value=\"5" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
//strOutput += "6";
//strOutput += "<BR><input type=radio name=\"ZONE\" value=\"6" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
//strOutput += "7";
//strOutput += "<BR><input type=radio name=\"ZONE\" value=\"7" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
//strOutput += "8";
//strOutput += "<BR><input type=radio name=\"ZONE\" value=\"8" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "</TD>";
strOutput += "</TR>";

document.write(strOutput);
strOutput = "";

ANS = GetCookie("ZoneSelected");
if (ANS == null) ANS = 0; // Code to use Local Area as default checked, but not needed because want null selected at this time ||
//if (LocationSelected != null) document.all.ZONE[LocationSelected].checked = true;

if (ANS != null) {
// var cLocations = document.getElementsByName('ZONE');
// for (var iCtr = 0; iCtr < cLocations.length; iCtr++) {
// if (cLocations[iCtr].value == ANS) cLocations[iCtr].checked = true;
// }
}

//REM YOU WILL NEED TO ADD YOUR SET OF ZIPCODES HERE FROM THE USPS SITE... NOTICE HOW THE LESS THAN AND GREATER THAN SIGNS ARE.... THEN EACH IS SEPARATED BY || THIS MEANS "OR".

//Loc 0
if (ANS == 0 ) LocationLabel = '<font color="#FF0000">Enter 1st 3 Digits of ZipCode</font>';
//Loc 1
else if (ANS >= 286 && ANS <= 289 || ANS == 376 || ANS == 242 ) LocationLabel = "Zone 1";
//Loc 2
else if (ANS >= 296 && ANS <= 297 || ANS == 293 || ANS >= 425 && ANS <= 426 || ANS >= 411 && ANS <= 418 || ANS >= 407 && ANS <= 409 || ANS >= 377 && ANS <= 379 || ANS >= 280 && ANS <= 282 || ANS >= 270 && ANS <= 274 || ANS >= 255 && ANS <= 259 || ANS >= 250 && ANS <= 253 || ANS >= 246 && ANS <= 249 || ANS == 243 || ANS >= 240 && ANS <= 241 ) LocationLabel = "Zone 2";
//Loc 3
else if (ANS >= 470 && ANS <= 474 || ANS == 459 || ANS >=446 && ANS <= 457 || ANS >= 437 && ANS <= 439 || ANS >= 318 && ANS <= 319 || ANS >= 298 && ANS <= 314 || ANS >= 294 && ANS <= 295 || ANS >= 290 && ANS <= 292 || ANS >= 283 && ANS <= 285 || ANS >= 430 && ANS <= 433 || ANS == 427 || ANS >= 421 && ANS <= 423 || ANS == 410 || ANS >= 399 && ANS <= 406 || ANS >= 384 && ANS <= 385 || ANS >= 370 && ANS <= 374 || ANS == 362 || ANS >= 355 && ANS <= 359 || ANS >= 350 && ANS <= 352 || ANS >= 275 && ANS <= 279 || ANS >= 260 && ANS <= 268 || ANS == 254 || ANS == 245 || ANS == 244 || ANS >= 238 && ANS <= 239 || ANS >= 224 && ANS <= 232 || ANS == 215 || ANS == 156 || ANS >= 150 && ANS <= 154 ) LocationLabel = "Zone 3";
//Loc 4
else if (ANS >= 720 && ANS <= 726 || ANS == 716 || ANS == 712 || ANS >= 475 && ANS <= 496 || ANS >= 460 && ANS <= 469 || ANS == 458 || ANS >= 440 && ANS <= 445 || ANS >= 434 && ANS <= 436 || ANS >= 315 && ANS <=317 || ANS == 704 || ANS >= 650 && ANS <= 658 || ANS == 648 || ANS >= 622 && ANS <= 639 || ANS >= 600 && ANS <= 620 || ANS >= 537 && ANS <= 538 || ANS >= 534 && ANS <= 535 || ANS >= 530 && ANS <= 532 || ANS >= 526 && ANS <= 528 || ANS == 424 || ANS == 420 || ANS >= 386 && ANS <= 398 || ANS >= 380 && ANS <= 383 || ANS == 375 || ANS >= 363 && ANS <= 369 || ANS >= 360 && ANS <= 631 || ANS == 354 || ANS >=346 && ANS <= 347 || ANS == 344 || ANS == 342 || ANS >= 335 && ANS <= 338 || ANS >= 320 && ANS <= 329 || ANS >= 233 && ANS <= 237 || ANS >= 216 && ANS <= 223 || ANS == 214 || ANS >= 157 && ANS <= 212 || ANS == 155 || ANS >= 130 && ANS <= 149 || ANS >= 124 && ANS <= 127 || ANS >= 063 && ANS <= 119 || ANS == 005) LocationLabel = "Zone 4";
//Loc 5
else if (ANS >= 733 && ANS <= 738 || ANS >= 727 && ANS <= 731 || ANS >= 717 && ANS <= 719 || ANS >= 713 && ANS <=714 || ANS >= 710 && ANS <= 711 || ANS >= 705 && ANS <= 708 || ANS == 789 || ANS >= 786 && ANS <= 787 || ANS >= 770 && ANS <= 779 || ANS >= 743 && ANS <= 767 || ANS >= 740 && ANS <= 741 || ANS == 703 || ANS >= 700 && ANS <= 701 || ANS >= 683 && ANS <= 689 || ANS >= 680 && ANS <= 681 || ANS == 678 || ANS >= 660 && ANS <= 676 || ANS == 649 || ANS >= 644 && ANS <= 647 || ANS >= 640 && ANS <= 642 || ANS >= 570 && ANS <= 573 || ANS >= 539 && ANS <= 566 || ANS >= 520 && ANS <= 525 || ANS >= 497 && ANS <= 516 || ANS == 349 || ANS >= 339 && ANS <= 341 || ANS >= 330 && ANS <= 334 || ANS >= 128 && ANS <= 129 || ANS >= 120 && ANS <= 123 || ANS >= 010 && ANS <= 062) LocationLabel = "Zone 5";
//Loc 6
else if (ANS >= 881 && ANS <= 885 || ANS >= 877 && ANS <= 878 || ANS == 875 || ANS >= 870 && ANS <= 872 || ANS >= 826 && ANS <= 828 || ANS >= 822 && ANS <= 823 || ANS == 820 || ANS >= 790 && ANS <= 816 || ANS == 788 || ANS >= 780 && ANS <= 785 || ANS >= 768 && ANS <= 769 || ANS == 739 || ANS >= 690 && ANS <= 693 || ANS == 769 || ANS == 677 || ANS == 593 || ANS >= 580 && ANS <= 588 || ANS >= 574 && ANS <= 577 || ANS == 567) LocationLabel = "Zone 6";
//Loc 7
else if (ANS == 893 || ANS >= 879 && ANS <= 880 || ANS >= 873 && ANS <= 874 || ANS >= 863 && ANS <= 865 || ANS >= 859 && ANS <= 860 || ANS >= 855 && ANS <= 857 || ANS >= 852 && ANS <= 853 || ANS == 850 || ANS >= 840 && ANS <= 847 || ANS >= 829 && ANS <= 834 || ANS >= 824 && ANS <= 825 || ANS == 821 || ANS >= 594 && ANS <= 599 || ANS >= 590 && ANS <= 592 || ANS >= 006 && ANS <= 009) LocationLabel = "Zone 7";
//Loc 8
else if (ANS >= 988 && ANS <= 999 || ANS >= 930 && ANS <= 986 || ANS >= 910 && ANS <= 928 || ANS >= 900 && ANS <= 908 || ANS >= 897 && ANS <= 898 || ANS >= 894 && ANS <= 895 || ANS >= 889 && ANS <= 891 || ANS >= 835 && ANS <= 838 ) LocationLabel = "Zone 8";
///WRONG TYPE
else LocationLabel = '<font color="#FF0000" <b>NOT A VALID ZIPCODE!</b></font>';
}
if (fWeight == 0) fShipping = 0;
else fShipping = ComputeShipping(ANS, fWeight);

strShipping = moneyFormat(fShipping);
strOutput += "<TR><TD CLASS=\"nopship\" COLSPAN=4 ALIGN=RIGHT><B>"+strWTOT+"</B></TD>";
strOutput += "<TD CLASS=\"nopship\" COLSPAN=1 ALIGN=RIGHT><B>" + fWeight + "lbs" + "</B></TD>";
strOutput += "<TD CLASS=\"nopship\" COLSPAN=1 ALIGN=RIGHT></TD>";
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4 ALIGN=RIGHT><B>" + LocationLabel + strSpace +strSHIPP + "</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + strShipping +"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" +strSpace+"</B></TD>";
strOutput += "</TR>";
}
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4 ALIGN=RIGHT><B>HANDLING</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + moneyFormat(fHandling) + "</B></TD>";
strOutput += "</TR>";


if ( DisplayTaxRow || TaxByRegion ) {
if ( TaxByRegion ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4 ALIGN=RIGHT><B>"+strTAX+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1><B>";
strOutput += "<input type=radio name=\""+OutputOrderTax+"\" value=\"" + strTax + "\">";
strOutput += TaxablePrompt + ": " + MonetarySymbol + strTax;
strOutput += "<BR><input type=radio name=\""+OutputOrderTax+"\" value=\"0.00\">";
strOutput += NonTaxablePrompt + ": " + MonetarySymbol + "0.00";
strOutput += "</B></TD>";
strOutput += "</TR>";
} else {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4 ALIGN=RIGHT><B>"+strTAX+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + strTax +"</B></TD>";
strOutput += "</TR>";
}
}

if ( !TaxByRegion ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4 ALIGN=RIGHT><B>"+strTOT+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal2\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fHandling + fTax))+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" +strSpace+"</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=\""+OutputOrderHandling+"\" value=\""+ MonetarySymbol + moneyFormat(fHandling) + "\">"; 
strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\" value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">";
}
}
g_TotalCost = (fTotal + fShipping  + fTax);
g_TotalShipping = (fShipping);
g_TotalOrderWeight = (fWeight);

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

//---------------------------------------------------------------------||
// FUNCTION: ComputeShipping ||
// PARAMETERS: ||
// RETURNS: ||
// PURPOSE: Compute shipping cost due to total weight ||
//---------------------------------------------------------------------||
function ComputeShipping(Zone, TotWeight) {

ANS = GetCookie("ZoneSelected");

if (ANS != Zone) {
SetCookie("ZoneSelected", Zone, null, "/");
location.href=location.href;
}
//Zone 0 NOTHING SELECTED ||

if (TotWeight == 0) return 0.00;

if (TotWeight == 0) return 0.00;

if (ANS == 0 ){
if (TotWeight <= 1) return 4.90;
if ((TotWeight <= 500) && (TotWeight > 1)) return (0.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
}

//REM THESE SETS OF STATEMENTS SHOWS AGAIN THE ZONES FOR EACH ZIPCODE... THEN RETURNS THE PRICE FOR WEIGHT AND ZONE FROM THE USPS SITE...

//Zone 1 ||

if (ANS >= 286 && ANS <= 289 || ANS == 376 || ANS == 242 ){
if (TotWeight <= 1) return 4.90;
if ((TotWeight <= 2) && (TotWeight > 1)) return (5.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 3) && (TotWeight > 2)) return (5.70 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 4) && (TotWeight > 3)) return (6.45 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 5) && (TotWeight > 4)) return (7.65 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 6) && (TotWeight > 5)) return (8.30 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 7) && (TotWeight > 6)) return (8.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 8) && (TotWeight > 7)) return (9.60 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 9) && (TotWeight > 8)) return (10.25 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 10) && (TotWeight > 9)) return (10.90 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 11) && (TotWeight > 10)) return (11.70 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 12) && (TotWeight > 11)) return (12.50 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 13) && (TotWeight > 12)) return (13.25 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 14) && (TotWeight > 13)) return (14.05 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 15) && (TotWeight > 14)) return (14.65 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 16) && (TotWeight > 15)) return (15.10 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 17) && (TotWeight > 16)) return (15.65 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 18) && (TotWeight > 17)) return (15.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 19) && (TotWeight > 18)) return (16.45 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 20) && (TotWeight > 19)) return (16.85 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 20) return 17.35;

}
//Zone 2 ||
if (ANS >= 296 && ANS <= 297 || ANS == 293 || ANS >= 425 && ANS <= 426 || ANS >= 411 && ANS <= 418 || ANS >= 407 && ANS <= 409 || ANS >= 377 && ANS <= 379 || ANS >= 280 && ANS <= 282 || ANS >= 270 && ANS <= 274 || ANS >= 255 && ANS <= 259 || ANS >= 250 && ANS <= 253 || ANS >= 246 && ANS <= 249 || ANS == 243 || ANS >= 240 && ANS <= 241 ){
if (TotWeight <= 1) return 4.90;
if ((TotWeight <= 2) && (TotWeight > 1)) return (5.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 3) && (TotWeight > 2)) return (5.70 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 4) && (TotWeight > 3)) return (6.45 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 5) && (TotWeight > 4)) return (7.65 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 6) && (TotWeight > 5)) return (8.30 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 7) && (TotWeight > 6)) return (8.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 8) && (TotWeight > 7)) return (9.60 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 9) && (TotWeight > 8)) return (10.25 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 10) && (TotWeight > 9)) return (10.90 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 11) && (TotWeight > 10)) return (11.70 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 12) && (TotWeight > 11)) return (12.50 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 13) && (TotWeight > 12)) return (13.25 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 14) && (TotWeight > 13)) return (14.05 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 15) && (TotWeight > 14)) return (14.65 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 16) && (TotWeight > 15)) return (15.10 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 17) && (TotWeight > 16)) return (15.65 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 18) && (TotWeight > 17)) return (15.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 19) && (TotWeight > 18)) return (16.45 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 20) && (TotWeight > 19)) return (16.85 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 20) return 17.35;

}
//Zone 3 ||
if (ANS >= 470 && ANS <= 474 || ANS == 459 || ANS >=446 && ANS <= 457 || ANS >= 437 && ANS <= 439 || ANS >= 318 && ANS <= 319 || ANS >= 298 && ANS <= 314 || ANS >= 294 && ANS <= 295 || ANS >= 290 && ANS <= 292 || ANS >= 283 && ANS <= 285 || ANS >= 430 && ANS <= 433 || ANS == 427 || ANS >= 421 && ANS <= 423 || ANS == 410 || ANS >= 399 && ANS <= 406 || ANS >= 384 && ANS <= 385 || ANS >= 370 && ANS <= 374 || ANS == 362 || ANS >= 355 && ANS <= 359 || ANS >= 350 && ANS <= 352 || ANS >= 275 && ANS <= 279 || ANS >= 260 && ANS <= 268 || ANS == 254 || ANS == 245 || ANS == 244 || ANS >= 238 && ANS <= 239 || ANS >= 224 && ANS <= 232 || ANS == 215 || ANS == 156 || ANS >= 150 && ANS <= 154 ){
if (TotWeight <= 1) return 4.95;
if ((TotWeight <= 2) && (TotWeight > 1)) return (5.35 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 3) && (TotWeight > 2)) return (6.55 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 4) && (TotWeight > 3)) return (7.55 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 5) && (TotWeight > 4)) return (8.75 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 6) && (TotWeight > 5)) return (9.65 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 7) && (TotWeight > 6)) return (10.55 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 8) && (TotWeight > 7)) return (11.45 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 9) && (TotWeight > 8)) return (12.35 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 10) && (TotWeight > 9)) return (13.25 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 11) && (TotWeight > 10)) return (14.20 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 12) && (TotWeight > 11)) return (15.20 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 13) && (TotWeight > 12)) return (16.15 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 14) && (TotWeight > 13)) return (17.10 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 15) && (TotWeight > 14)) return (18.10 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 16) && (TotWeight > 15)) return (19.05 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 17) && (TotWeight > 16)) return (20.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 18) && (TotWeight > 17)) return (20.65 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 19) && (TotWeight > 18)) return (21.10 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 20) && (TotWeight > 19)) return (21.40 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 20) return 21.70;

}
//Zone 4 ||
if (ANS >= 720 && ANS <= 726 || ANS == 716 || ANS == 712 || ANS >= 475 && ANS <= 496 || ANS >= 460 && ANS <= 469 || ANS == 458 || ANS >= 440 && ANS <= 445 || ANS >= 434 && ANS <= 436 || ANS >= 315 && ANS <=317 || ANS == 704 || ANS >= 650 && ANS <= 658 || ANS == 648 || ANS >= 622 && ANS <= 639 || ANS >= 600 && ANS <= 620 || ANS >= 537 && ANS <= 538 || ANS >= 534 && ANS <= 535 || ANS >= 530 && ANS <= 532 || ANS >= 526 && ANS <= 528 || ANS == 424 || ANS == 420 || ANS >= 386 && ANS <= 398 || ANS >= 380 && ANS <= 383 || ANS == 375 || ANS >= 363 && ANS <= 369 || ANS >= 360 && ANS <= 631 || ANS == 354 || ANS >=346 && ANS <= 347 || ANS == 344 || ANS == 342 || ANS >= 335 && ANS <= 338 || ANS >= 320 && ANS <= 329 || ANS >= 233 && ANS <= 237 || ANS >= 216 && ANS <= 223 || ANS == 214 || ANS >= 157 && ANS <= 212 || ANS == 155 || ANS >= 130 && ANS <= 149 || ANS >= 124 && ANS <= 127 || ANS >= 063 && ANS <= 119 || ANS == 005){
if (TotWeight <= 1) return 5.05;
if ((TotWeight <= 2) && (TotWeight > 1)) return (5.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 3) && (TotWeight > 2)) return (7.50 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 4) && (TotWeight > 3)) return (8.60 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 5) && (TotWeight > 4)) return (9.85 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 6) && (TotWeight > 5)) return (11.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 7) && (TotWeight > 6)) return (11.75 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 8) && (TotWeight > 7)) return (13.30 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 9) && (TotWeight > 8)) return (14.40 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 10) && (TotWeight > 9)) return (15.70 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 11) && (TotWeight > 10)) return (16.90 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 12) && (TotWeight > 11)) return (18.15 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 13) && (TotWeight > 12)) return (19.20 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 14) && (TotWeight > 13)) return (20.35 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 15) && (TotWeight > 14)) return (21.50 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 16) && (TotWeight > 15)) return (22.65 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 17) && (TotWeight > 16)) return (23.85 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 18) && (TotWeight > 17)) return (25.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 19) && (TotWeight > 18)) return (25.50 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 20) && (TotWeight > 19)) return (25.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 20) return 26.35;

}
//Zone 5 ||
if (ANS >= 733 && ANS <= 738 || ANS >= 727 && ANS <= 731 || ANS >= 717 && ANS <= 719 || ANS >= 713 && ANS <=714 || ANS >= 710 && ANS <= 711 || ANS >= 705 && ANS <= 708 || ANS == 789 || ANS >= 786 && ANS <= 787 || ANS >= 770 && ANS <= 779 || ANS >= 743 && ANS <= 767 || ANS >= 740 && ANS <= 741 || ANS == 703 || ANS >= 700 && ANS <= 701 || ANS >= 683 && ANS <= 689 || ANS >= 680 && ANS <= 681 || ANS == 678 || ANS >= 660 && ANS <= 676 || ANS == 649 || ANS >= 644 && ANS <= 647 || ANS >= 640 && ANS <= 642 || ANS >= 570 && ANS <= 573 || ANS >= 539 && ANS <= 566 || ANS >= 520 && ANS <= 525 || ANS >= 497 && ANS <= 516 || ANS == 349 || ANS >= 339 && ANS <= 341 || ANS >= 330 && ANS <= 334 || ANS >= 128 && ANS <= 129 || ANS >= 120 && ANS <= 123 || ANS >= 010 && ANS <= 062){
if (TotWeight <= 1) return 5.15;
if ((TotWeight <= 2) && (TotWeight > 1)) return (7.50 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 3) && (TotWeight > 2)) return (9.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 4) && (TotWeight > 3)) return (11.90 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 5) && (TotWeight > 4)) return (13.50 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 6) && (TotWeight > 5)) return (15.05 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 7) && (TotWeight > 6)) return (16.80 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 8) && (TotWeight > 7)) return (18.20 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 9) && (TotWeight > 8)) return (19.75 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 10) && (TotWeight > 9)) return (21.35 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 11) && (TotWeight > 10)) return (23.05 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 12) && (TotWeight > 11)) return (24.70 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 13) && (TotWeight > 12)) return (26.15 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 14) && (TotWeight > 13)) return (27.80 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 15) && (TotWeight > 14)) return (29.40 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 16) && (TotWeight > 15)) return (31.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 17) && (TotWeight > 16)) return (32.65 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 18) && (TotWeight > 17)) return (34.25 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 19) && (TotWeight > 18)) return (35.15 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 20) && (TotWeight > 19)) return (35.75 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 20) return 36.35;
bfound=true;
}
//Zones 6 ||
if (ANS >= 881 && ANS <= 885 || ANS >= 877 && ANS <= 878 || ANS == 875 || ANS >= 870 && ANS <= 872 || ANS >= 826 && ANS <= 828 || ANS >= 822 && ANS <= 823 || ANS == 820 || ANS >= 790 && ANS <= 816 || ANS == 788 || ANS >= 780 && ANS <= 785 || ANS >= 768 && ANS <= 769 || ANS == 739 || ANS >= 690 && ANS <= 693 || ANS == 769 || ANS == 677 || ANS == 593 || ANS >= 580 && ANS <= 588 || ANS >= 574 && ANS <= 577 || ANS == 567){
if (TotWeight <= 1) return 5.25;
if ((TotWeight <= 2) && (TotWeight > 1)) return (8.10 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 3) && (TotWeight > 2)) return (9.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 4) && (TotWeight > 3)) return (13.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 5) && (TotWeight > 4)) return (14.85 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 6) && (TotWeight > 5)) return (16.65 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 7) && (TotWeight > 6)) return (18.40 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 8) && (TotWeight > 7)) return (20.20 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 9) && (TotWeight > 8)) return (22.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 10) && (TotWeight > 9)) return (23.75 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 11) && (TotWeight > 10)) return (25.55 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 12) && (TotWeight > 11)) return (27.75 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 13) && (TotWeight > 12)) return (29.75 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 14) && (TotWeight > 13)) return (31.40 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 15) && (TotWeight > 14)) return (32.80 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 16) && (TotWeight > 15)) return (34.60 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 17) && (TotWeight > 16)) return (36.40 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 18) && (TotWeight > 17)) return (38.25 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 19) && (TotWeight > 18)) return (40.05 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 20) && (TotWeight > 19)) return (41.05 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 20) return 41.70;

}
//Zones 7 ||
if (ANS == 893 || ANS >= 879 && ANS <= 880 || ANS >= 873 && ANS <= 874 || ANS >= 863 && ANS <= 865 || ANS >= 859 && ANS <= 860 || ANS >= 855 && ANS <= 857 || ANS >= 852 && ANS <= 853 || ANS == 850 || ANS >= 840 && ANS <= 847 || ANS >= 829 && ANS <= 834 || ANS >= 824 && ANS <= 825 || ANS == 821 || ANS >= 594 && ANS <= 599 || ANS >= 590 && ANS <= 592 || ANS >= 006 && ANS <= 009){
if (TotWeight <= 1) return 5.35;
if ((TotWeight <= 2) && (TotWeight > 1)) return (8.60 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 3) && (TotWeight > 2)) return (10.70 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 4) && (TotWeight > 3)) return (13.80 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 5) && (TotWeight > 4)) return (15.85 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 6) && (TotWeight > 5)) return (17.80 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 7) && (TotWeight > 6)) return (20.05 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 8) && (TotWeight > 7)) return (22.05 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 9) && (TotWeight > 8)) return (23.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 10) && (TotWeight > 9)) return (26.30 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 11) && (TotWeight > 10)) return (29.05 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 12) && (TotWeight > 11)) return (31.40 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 13) && (TotWeight > 12)) return (32.65 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 14) && (TotWeight > 13)) return (34.50 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 15) && (TotWeight > 14)) return (35.25 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 16) && (TotWeight > 15)) return (37.20 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 17) && (TotWeight > 16)) return (39.15 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 18) && (TotWeight > 17)) return (41.10 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 19) && (TotWeight > 18)) return (43.05 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 20) && (TotWeight > 19)) return (44.60 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 20) return 45.35;

}
//Zones 8 ||
if (ANS >= 988 && ANS <= 999 || ANS >= 930 && ANS <= 986 || ANS >= 910 && ANS <= 928 || ANS >= 900 && ANS <= 908 || ANS >= 897 && ANS <= 898 || ANS >= 894 && ANS <= 895 || ANS >= 889 && ANS <= 891 || ANS >= 835 && ANS <= 838 ){
if (TotWeight <= 1) return 5.55;
if ((TotWeight <= 2) && (TotWeight > 1)) return (9.55 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 3) && (TotWeight > 2)) return (12.70 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 4) && (TotWeight > 3)) return (15.30 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 5) && (TotWeight > 4)) return (17.65 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 6) && (TotWeight > 5)) return (19.90 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 7) && (TotWeight > 6)) return (22.40 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 8) && (TotWeight > 7)) return (25.10 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 9) && (TotWeight > 8)) return (27.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 10) && (TotWeight > 9)) return (30.40 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 11) && (TotWeight > 10)) return (33.35 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 12) && (TotWeight > 11)) return (35.85 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 13) && (TotWeight > 12)) return (37.10 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 14) && (TotWeight > 13)) return (38.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 15) && (TotWeight > 14)) return (40.05 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 16) && (TotWeight > 15)) return (42.30 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 17) && (TotWeight > 16)) return (44.55 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 18) && (TotWeight > 17)) return (46.80 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 19) && (TotWeight > 18)) return (49.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 20) && (TotWeight > 19)) return (51.25 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 20) return 52.40;

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

if ( isNaN (g_TotalCost) ) {
alert( NoQtyPrompt );
return false;
}


if ( MinimumOrder >= 0.01 ) {
if ( g_TotalCost < MinimumOrder ) {
alert( MinimumOrderPrompt );
return false;
}
}
//REM THIS CHECKS TO SEE IF THERE IS ANY WEIGHT IN CART, IF SO, MAKE SURE THE ZIP CODE IS LISTED BY CHECKING IF THERE IS A SHIPPING AMOUNT.

if (( MinimumWeight >= 0.01 ) && ( MinimumShipping <=4.90 )){
if (( g_TotalOrderWeight > MinimumWeight ) && ( g_TotalShipping < MinimumShipping )) {
alert( ZipCodePrompt );
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 fWeight = 0; //Weight
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 strPP = ""; //Payment Processor Description Field
var PaymentProcessor = "lp";
var comments = "desc";

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

if ( TaxByRegion ) {
QueryString_Parse();
fTax = parseFloat( QueryString( OutputOrderTax ) );
strTax = moneyFormat(fTax);
}

if ( bDisplay )
strOutput = "<TABLE CELLSPACING=0 CELLPADDING=2 BORDER=0 CLASS=\"nopcart\"><TR>" +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strILabel+"</B></TD>" +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strDLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strQLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strPLabel+"</B></TD>" +
(DisplayShippingColumn?"<TD CLASS=\"nopheader\" ALIGN=CENTER><B>"+strSLabel+"</B></TD>":"") +
"</TR>";

for ( i = 1; i <= iNumberOrdered; i++ ) {
even = Math.round(i/2);
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 ); // Weight
fields[5] = database.substring( Token4+1, database.length ); //Additional Information

fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );
fWeight += (parseInt(fields[1]) * parseFloat(fields[4]) );
fWeight = Math.round(fWeight * 100)/100;
if ( !TaxByRegion ) var strProductId = fields[0];
if( strProductId[0] != 'n' ) {
fTax += (parseInt(fields[1]) * parseFloat(fields[2]) ) * TaxRate;
fTax = Math.round(fTax * 100)/100;
}
strTotal = moneyFormat(fTotal);
if ( !TaxByRegion ) strTax = moneyFormat(fTax);

if ( bDisplay ){
if ((even) ==(i/2) ) {
strOutput += "<TR><TD CLASS=\"nopeven\" ALIGN=CENTER>" + fields[0] + "</TD>";

if ( fields[5] == "" )
strOutput += "<TD CLASS=\"nopeven\">" + fields[3] + "</TD>";
else
strOutput += "<TD CLASS=\"nopeven\">" + fields[3] + " - <I>"+ fields[5] + "</I></TD>";

strOutput += "<TD CLASS=\"nopeven\" ALIGN=CENTER>" + fields[1] + "</TD>";
strOutput += "<TD CLASS=\"nopeven\" ALIGN=RIGHT>"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea</TD>";

if ( DisplayShippingColumn ) {

strOutput += "<TD CLASS=\"nopeven\" ALIGN=RIGHT>"+ MonetarySymbol + moneyFormat(parseInt(fields[1]) * parseFloat(fields[2]) ) + "</TD>";
}else {
strOutput += "<TD CLASS=\"nopeven\" ALIGN=RIGHT>N/A</TD>";
}

strOutput += "</TR>";
}
else {
strOutput += "<TR><TD CLASS=\"nopentry\" ALIGN=CENTER>" + fields[0] + "</TD>";

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

strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER>" + fields[1] + "</TD>";
strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea</TD>";

if ( DisplayShippingColumn ) {

strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>"+ MonetarySymbol + moneyFormat(parseInt(fields[1]) * parseFloat(fields[2]) ) + "</TD>";
}else {
strOutput += "<TD CLASS=\"nopentry\" ALIGN=RIGHT>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 {
LocationSelected = GetCookie("ZoneSelected");
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=\"" + OutputItemWeight + strFooter + "\" value=\"" + fields[4] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemXtend + strFooter + "\" value=\"" + moneyFormat(fields[1] * fields[2]) + "\">";
strOutput += "<input type=hidden name=\"" + OutputOrderZone + strFooter + "\" value=\"" + LocationSelected + "\">";
}

}

if ( bDisplay ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4 ALIGN=RIGHT><B>"+strSUB+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + strTotal + "</B></TD>";
strOutput += "</TR>";

if ( fWeight > 0 ) {
if ( DisplayShippingRow ) {
ANS = GetCookie("ZoneSelected");
if (ANS == null) ANS = 0; //Needed if checkout cart is empty

//Loc 0
if (ANS == 0 ) LocationLabel = '<font color="#FF0000">NOT A VALID ZIPCODE!</font>';
//Loc 1
else if (ANS >= 286 && ANS <= 289 || ANS == 376 || ANS == 242 ) LocationLabel = "Zone 1";
//Loc 2
else if (ANS >= 296 && ANS <= 297 || ANS == 293 || ANS >= 425 && ANS <= 426 || ANS >= 411 && ANS <= 418 || ANS >= 407 && ANS <= 409 || ANS >= 377 && ANS <= 379 || ANS >= 280 && ANS <= 282 || ANS >= 270 && ANS <= 274 || ANS >= 255 && ANS <= 259 || ANS >= 250 && ANS <= 253 || ANS >= 246 && ANS <= 249 || ANS == 243 || ANS >= 240 && ANS <= 241 ) LocationLabel = "Zone 2";
//Loc 3
else if (ANS >= 470 && ANS <= 474 || ANS == 459 || ANS >=446 && ANS <= 457 || ANS >= 437 && ANS <= 439 || ANS >= 318 && ANS <= 319 || ANS >= 298 && ANS <= 314 || ANS >= 294 && ANS <= 295 || ANS >= 290 && ANS <= 292 || ANS >= 283 && ANS <= 285 || ANS >= 430 && ANS <= 433 || ANS == 427 || ANS >= 421 && ANS <= 423 || ANS == 410 || ANS >= 399 && ANS <= 406 || ANS >= 384 && ANS <= 385 || ANS >= 370 && ANS <= 374 || ANS == 362 || ANS >= 355 && ANS <= 359 || ANS >= 350 && ANS <= 352 || ANS >= 275 && ANS <= 279 || ANS >= 260 && ANS <= 268 || ANS == 254 || ANS == 245 || ANS == 244 || ANS >= 238 && ANS <= 239 || ANS >= 224 && ANS <= 232 || ANS == 215 || ANS == 156 || ANS >= 150 && ANS <= 154 ) LocationLabel = "Zone 3";
//Loc 4
else if (ANS >= 720 && ANS <= 726 || ANS == 716 || ANS == 712 || ANS >= 475 && ANS <= 496 || ANS >= 460 && ANS <= 469 || ANS == 458 || ANS >= 440 && ANS <= 445 || ANS >= 434 && ANS <= 436 || ANS >= 315 && ANS <=317 || ANS == 704 || ANS >= 650 && ANS <= 658 || ANS == 648 || ANS >= 622 && ANS <= 639 || ANS >= 600 && ANS <= 620 || ANS >= 537 && ANS <= 538 || ANS >= 534 && ANS <= 535 || ANS >= 530 && ANS <= 532 || ANS >= 526 && ANS <= 528 || ANS == 424 || ANS == 420 || ANS >= 386 && ANS <= 398 || ANS >= 380 && ANS <= 383 || ANS == 375 || ANS >= 363 && ANS <= 369 || ANS >= 360 && ANS <= 631 || ANS == 354 || ANS >=346 && ANS <= 347 || ANS == 344 || ANS == 342 || ANS >= 335 && ANS <= 338 || ANS >= 320 && ANS <= 329 || ANS >= 233 && ANS <= 237 || ANS >= 216 && ANS <= 223 || ANS == 214 || ANS >= 157 && ANS <= 212 || ANS == 155 || ANS >= 130 && ANS <= 149 || ANS >= 124 && ANS <= 127 || ANS >= 063 && ANS <= 119 || ANS == 005) LocationLabel = "Zone 4";
//Loc 5
else if (ANS >= 733 && ANS <= 738 || ANS >= 727 && ANS <= 731 || ANS >= 717 && ANS <= 719 || ANS >= 713 && ANS <=714 || ANS >= 710 && ANS <= 711 || ANS >= 705 && ANS <= 708 || ANS == 789 || ANS >= 786 && ANS <= 787 || ANS >= 770 && ANS <= 779 || ANS >= 743 && ANS <= 767 || ANS >= 740 && ANS <= 741 || ANS == 703 || ANS >= 700 && ANS <= 701 || ANS >= 683 && ANS <= 689 || ANS >= 680 && ANS <= 681 || ANS == 678 || ANS >= 660 && ANS <= 676 || ANS == 649 || ANS >= 644 && ANS <= 647 || ANS >= 640 && ANS <= 642 || ANS >= 570 && ANS <= 573 || ANS >= 539 && ANS <= 566 || ANS >= 520 && ANS <= 525 || ANS >= 497 && ANS <= 516 || ANS == 349 || ANS >= 339 && ANS <= 341 || ANS >= 330 && ANS <= 334 || ANS >= 128 && ANS <= 129 || ANS >= 120 && ANS <= 123 || ANS >= 010 && ANS <= 062) LocationLabel = "Zone 5";
//Loc 6
else if (ANS >= 881 && ANS <= 885 || ANS >= 877 && ANS <= 878 || ANS == 875 || ANS >= 870 && ANS <= 872 || ANS >= 826 && ANS <= 828 || ANS >= 822 && ANS <= 823 || ANS == 820 || ANS >= 790 && ANS <= 816 || ANS == 788 || ANS >= 780 && ANS <= 785 || ANS >= 768 && ANS <= 769 || ANS == 739 || ANS >= 690 && ANS <= 693 || ANS == 769 || ANS == 677 || ANS == 593 || ANS >= 580 && ANS <= 588 || ANS >= 574 && ANS <= 577 || ANS == 567) LocationLabel = "Zone 6";
//Loc 7
else if (ANS == 893 || ANS >= 879 && ANS <= 880 || ANS >= 873 && ANS <= 874 || ANS >= 863 && ANS <= 865 || ANS >= 859 && ANS <= 860 || ANS >= 855 && ANS <= 857 || ANS >= 852 && ANS <= 853 || ANS == 850 || ANS >= 840 && ANS <= 847 || ANS >= 829 && ANS <= 834 || ANS >= 824 && ANS <= 825 || ANS == 821 || ANS >= 594 && ANS <= 599 || ANS >= 590 && ANS <= 592 || ANS >= 006 && ANS <= 009) LocationLabel = "Zone 7";
//Loc 8
else if (ANS >= 988 && ANS <= 999 || ANS >= 930 && ANS <= 986 || ANS >= 910 && ANS <= 928 || ANS >= 900 && ANS <= 908 || ANS >= 897 && ANS <= 898 || ANS >= 894 && ANS <= 895 || ANS >= 889 && ANS <= 891 || ANS >= 835 && ANS <= 838 ) LocationLabel = "Zone 8";
///WRONG TYPE
else LocationLabel = '<font color="#FF0000" <b>NOT A VALID ZIPCODE!</b></font>';

fShipping = ComputeShipping(ANS, fWeight) + 5.00;
strShipping = moneyFormat(fShipping);
//strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strWTOT+"</B></TD>";
//strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + fWeight + " lbs" + "</B></TD>";
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4 ALIGN=RIGHT><B>" + LocationLabel + strSpace +strSHIP + "</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=1 ALIGN=RIGHT><B>" + MonetarySymbol + strShipping + "</B></TD>";
strOutput += "</TR>";
}

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

}
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4 ALIGN=RIGHT><B>"+strTOT+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal2\" COLSPAN=1 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=\"payplus\">";
strOutput += "<input type=hidden name=\"chargetotal\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
strOutput += "<input type=hidden name=\"tax\" value=\""+ strTax + "\">";
strOutput += "<input type=hidden name=\"subtotal\" value=\""+ strTotal + "\">";
strOutput += "<input type=hidden name=\"shipping\" value=\""+ strShipping + "\">";
strOutput += "<input type=hidden name=\"comments\" value=\""+ strPP + "\">";  

} else if (LocationSelected != 0){
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 + (fTax) + "\">";
strOutput += "<input type=hidden name=\"subtotal\" value=\""+ MonetarySymbol + (fTotal) + "\">";
strOutput += "<input type=hidden name=\"shipping\" value=\""+ MonetarySymbol + (fShipping) + "\">";
strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
} else {
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 + (fTax) + "\">";
strOutput += "<input type=hidden name=\"subtotal\" value=\""+ MonetarySymbol + (fTotal) + "\">";
strOutput += "<input type=hidden name=\"shipping\" value=\""+ MonetarySymbol + (fShipping) + "\">";
strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
}
}

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

//---------------------------------------------------------------------||
// FUNCTION: Print_total ||
// PARAMETERS: none ||
// RETURNS: Total cost currently racked up by shopper ||
// PURPOSE: Aesthetics ||
//---------------------------------------------------------------------||
function Print_total( ) {
var strOutput = ""; //String to be written to page
var strTotal = ""; //Total cost formatted as money
var fTotal = 0;
var iNumberOrdered = 0; //Number of products ordered


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


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 ); // Weight
fields[5] = database.substring( Token4+1, database.length ); //Additional Information

fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );

}

strTotal = moneyFormat(fTotal);
strOutput+=strTotal;
document.write(strOutput);

}



//---------------------------------------------------------------------||
// FUNCTION: Print_total_products                                      ||
// PARAMETERS: true/false if you want "item(s)" added to string        ||
// RETURNS: Total cost currently racked up by shopper                  ||
// PURPOSE: Aesthetics                                                 ||
//---------------------------------------------------------------------||
function Print_total_products(bVerbose) {
var strOutput = ""; //String to be written to page
var fTotal = 0;
var iNumberOrdered = 0; //Number of products ordered


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


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 ); // Weight
fields[5] = database.substring( Token4+1, database.length ); //Additional Information

fTotal += (parseInt(fields[1]));

}

strOutput+=fTotal;
if ( bVerbose ) {
   if (fTotal == 1) {
      strOutput+=" item"
   }
   else {
      strOutput+=" items"
   }
}
document.write(strOutput);

}

//---------------------------------------------------------------------||
// FUNCTION: Cart_is_empty                                             ||
// PARAMETERS: none                                                    ||
// RETURNS: Total true if cart is empty, false otherwise               ||
// PURPOSE: Aesthetics                                                 ||
//---------------------------------------------------------------------||
function Cart_is_empty( ) {
   iNumInCart = GetCookie("NumberOrdered");
               
   if ( iNumInCart == null ) iNumInCart = 0;

   if ( iNumInCart == 0 ) return true;
   
   return false;

}

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