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

MonetarySymbol = '$';
DisplayNotice = true;
DisplayChangeQty = true;
DisplayShippingColumn = false;
DisplayShippingRow = true;
TaxRate = 0.07; //set taxable region rate
DisplayTaxRow = false;
TaxByRegion = false; //false: shipping mod will activate taxable zone
TaxPrompt = 'For tax purposes, please select if you are a resident of New Jersey before continuing'; //deactivated
TaxablePrompt = 'New Jersey'; //deactivated
NonTaxablePrompt = 'Other States'; //deactivated
MinimumOrder = 0.01;
MinimumOrderPrompt = 'Your order is below our minimum order, please order more before checking out.';
NoQtyPrompt = 'You cannot proceed until a Shipping Option has been selected';

OutputItemId = 'ID_';
OutputItemQuantity = 'QUANTITY_';
OutputItemPrice = 'PRICE_';
OutputItemName = 'NAME_';
OutputItemWeight = 'WEIGHT_'; //added for shipping mod
OutputItemAddtlInfo = 'ADDTLINFO_';
OutputItemXtend = 'XTEND_';
OutputOrderZone = 'SHIPZONE';
OutputOrderSubtotal = 'SUBTOTAL';
OutputOrderShipping = 'SHIPPING';
OutputOrderTax = 'TAX';
OutputOrderTotal = 'TOTAL';
AppendItemNumToOutput = true;
HiddenFieldsToCheckout = true;

// Options for Shipping by Weight:
LocationLabel = 'ZONE';
LocationPrompt = 'For shipping purposes, please select the Shipping Option before continuing.';
MaxWeightPrompt = 'Sorry, maximum weight allowable is 70 lb.';

// Language Strings
if ( !bLanguageDefined ) {
strSLabel = "Weight"; //added for shipping mod
strWTOT = "TOTAL WEIGHT"; //added for shipping mod
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
// 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 shipping 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 += "<br>" + 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++;

browserie = ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) < 7 ))
browserop = (navigator.appName == "Opera")

if ((browserie) && (iNumberOrdered > 18)) {
alert( strSorry );
} else if ((browserop) && (iNumberOrdered > 28)) {
alert( strSorry );
} else if (iNumberOrdered > 48) {
alert( strSorry );
} else {

//if ( iNumberOrdered > 18 )
//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 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

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

LocationSelected = GetCookie("ZoneSelected");
if (LocationSelected == null) LocationSelected = 8; //use as default checked if customer goes to checkout with an empty cart

if ( bDisplay )
strOutput = "<table cellspacing=0 cellpadding=3 border=0 class=nopcart><tr>" +
"<td class=nopheader align=center><b>"+strILabel+"</b></td>" +
"<td class=nopheader align=left><b>"+strDLabel+"</b></td>" +
"<td class=nopheader align=center><b>"+strQLabel+"</b></td>" +
"<td class=nopheader align=center><b>"+strPLabel+"</b></td>" +
"<td class=nopheader width=5></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]) ) * TaxRate;
}

strTotal = moneyFormat(fTotal);
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 class=nobottom value=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\" align=center></td>";
} else {
strOutput += "<td class=nopeven align=center>" + fields[1] + "</td>";
}
strOutput += "<td class=nopeven align=center>"+ 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>&nbsp;</td><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 class=nobottom value=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\" align=center></td>";
} else {
strOutput += "<td class=nopentry align=center>" + fields[1] + "</td>";
}
strOutput += "<td class=nopentry align=center>"+ 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>&nbsp;</td><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=5><br><b>"+strSUB+"</b></td>";
strOutput += "<td class=noptotal colspan=1 align=right><br><b>" + MonetarySymbol + strTotal + strSpace +"</b></td>";
strOutput += "</tr>";
strOutput += "</table><table width=600 cellspacing=0 cellpadding=5 border=0 class=nopcart>";
strOutput += "<tr><td class=noptotal colspan=6><br><b>Choose Shipping Option:</b></td></tr>";

//displays the shipping matrix and sets the value for each zone

if (( DisplayShippingRow ) && ( iNumberOrdered != 0)) {
strOutput += "<tr><td width=10 class=nopship colspan=1><br></td>";
strOutput += "<td width=290 class=nopship colspan=2 valign=top>";
strOutput += '<b>Domestic - USA</b><img src=dot.gif width=135 height=1 border=0><a href="javascript:void(0);" onmouseover="Tip(\'<i>Domestic Shipping</i>:<div id=one-em><ul><li>Flat Rate envelope: 12.5&quot; x 9.5&quot;</li><li>Flat Rate boxes have different sizes; max. 70 lb</li><li>Small Box: 8-5/8&quot; x 5-3/8&quot; x 1-5/8&quot;</li><li>Medium Box: 11&quot; x 8.5&quot; x 5.5&quot;<br>(similar to shoe box)</li><li>Medium Box: 13-5/8&quot; x 11-7/8&quot; x 3-3/8&quot;<br>(similar to clothing box)</li><li>Large Box: 12-1/4&quot; x 12-1/4&quot; x 6&quot;</li><li>Express Mail envelope: 12.5&quot; x 9.5&quot;</li></ul></div>\', WIDTH, 280, PADDING, 6, BGCOLOR, \'#efefef\')"><img src=info.gif height=20 width=20 border=0 align=absbottom></a>';
if(fWeight>369){
strOutput += "<br><input type=radio name=\"ZONE\" value=\"1" + "\" DISABLED>";
strOutput += "First Class (<i>max. 13 oz</i>)";
}else{
strOutput += "<br><input type=radio name=\"ZONE\" value=\"1" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "First Class (<i>max. 13 oz</i>)";
}
if(fWeight>2268){
strOutput += "<br><input type=radio name=\"ZONE\" value=\"2" + "\" DISABLED>";
strOutput += "Priority Mail (<i>max. 5 lb</i>)";
}else{
strOutput += "<br><input type=radio name=\"ZONE\" value=\"2" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Priority Mail (<i>max. 5 lb</i>)";
}
strOutput += "<br><input type=radio name=\"ZONE\" value=\"31" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Flat Rate - envelope or small box";
strOutput += "<br><input type=radio name=\"ZONE\" value=\"33" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Flat Rate - medium box";
strOutput += "<br><input type=radio name=\"ZONE\" value=\"3" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Flat Rate - large box";
strOutput += "<br><input type=radio name=\"ZONE\" value=\"32" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Express Mail Flat Rate - envelope";
strOutput += '<br><br><b>International</b><img src=dot.gif width=150 height=1 border=0><a href="javascript:void(0);" onmouseover="Tip(\'<i>International Shipping</i>:<div id=one-em><ul><li>First Class is based on weight and distance</li><li>Envelope: 32 x 24 cm</li><li>Box: 27 x 21 x 14 cm or 30 x 34 x 8.5 cm</li><li>Large Box: 31 x 31 x 14 cm</li></ul></div>\', WIDTH, 280, PADDING, 6, BGCOLOR, \'#efefef\')"><img src=info.gif height=20 width=20 border=0 align=absbottom></a>';
if(fWeight>1814){
strOutput += "<br><input type=radio name=\"ZONE\" value=\"7" + "\" DISABLED>";
strOutput += "First Class (<i>max. 1.8 kg</i>)";
}else{
strOutput += "<br><input type=radio name=\"ZONE\" value=\"7" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "First Class (<i>max. 1.8 kg</i>)";
}
if(fWeight>1814){
strOutput += "<br><input type=radio name=\"ZONE\" value=\"71" + "\" DISABLED>";
strOutput += "Flat rate - envelope (<i>max. 1.8 kg</i>)";
}else{
strOutput += "<br><input type=radio name=\"ZONE\" value=\"71" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Flat rate - envelope (<i>max. 1.8 kg</i>)";
}
strOutput += "<br><input type=radio name=\"ZONE\" value=\"72" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Flat rate - box (<i>max. 9 kg</i>)";
strOutput += "<br><input type=radio name=\"ZONE\" value=\"73" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Flat rate - large box (<i>max. 9 kg</i>)";
strOutput += "</td><td width=290 class=nopship colspan=3 valign=top>";
strOutput += "<b>New Jersey Residents</b>";
if(fWeight>369){
strOutput += "<br><input type=radio name=\"ZONE\" value=\"4" + "\" DISABLED>";
strOutput += "First Class (<i>max. 13 oz</i>)";
}else{
strOutput += "<br><input type=radio name=\"ZONE\" value=\"4" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "First Class (<i>max. 13 oz</i>)";
}
if(fWeight>2268){
strOutput += "<br><input type=radio name=\"ZONE\" value=\"5" + "\" DISABLED>";
strOutput += "Priority Mail (<i>max. 5 lb</i>)";
}else{
strOutput += "<br><input type=radio name=\"ZONE\" value=\"5" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Priority Mail (<i>max. 5 lb</i>)";
}
strOutput += "<br><input type=radio name=\"ZONE\" value=\"61" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Flat Rate - envelope or small box";
strOutput += "<br><input type=radio name=\"ZONE\" value=\"63" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Flat Rate - medium box";
strOutput += "<br><input type=radio name=\"ZONE\" value=\"6" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Flat Rate - large box";
strOutput += "<br><input type=radio name=\"ZONE\" value=\"62" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Express Mail Flat Rate - envelope";
strOutput += "<br><br><b>Canada or Mexico</b><img src=dot.gif width=20 height=20 border=0>";
if(fWeight>1814){
strOutput += "<br><input type=radio name=\"ZONE\" value=\"7" + "\" DISABLED>";
strOutput += "First Class (<i>max. 1.8 kg</i>)";
}else{
strOutput += "<br><input type=radio name=\"ZONE\" value=\"70" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "First Class (<i>max. 1.8 kg</i>)";
}
if(fWeight>1814){
strOutput += "<br><input type=radio name=\"ZONE\" value=\"75" + "\" DISABLED>";
strOutput += "Flat rate - envelope (<i>max. 1.8 kg</i>)";
}else{
strOutput += "<br><input type=radio name=\"ZONE\" value=\"75" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Flat rate - envelope (<i>max. 1.8 kg</i>)";
}
strOutput += "<br><input type=radio name=\"ZONE\" value=\"76" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Flat rate - box (<i>max. 9 kg</i>)";
strOutput += "<br><input type=radio name=\"ZONE\" value=\"77" + "\" onClick=\"ComputeShipping(this.value, "+fWeight+")\">";
strOutput += "Flat rate - large box (<i>max. 9 kg</i>)";
strOutput += "</td>";
strOutput += "</tr>";

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

LocationSelected = GetCookie("ZoneSelected");
if (LocationSelected == null) LocationSelected = 8;
//code to use local area as default checked, but not needed because null selected at this time
//if (LocationSelected != null) document.all.ZONE[LocationSelected].checked = true;

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

if (LocationSelected == 0) LocationLabel = "No Shipping Option";
if (LocationSelected == 1) LocationLabel = "First Class - Domestic";
if (LocationSelected == 2) LocationLabel = "Priority Mail - Domestic";
if (LocationSelected == 3) LocationLabel = "Flat Rate - Domestic - large box";
if (LocationSelected == 31) LocationLabel = "Flat Rate - Domestic - envelope or small box";
if (LocationSelected == 32) LocationLabel = "Express Mail Flat Rate - Domestic";
if (LocationSelected == 33) LocationLabel = "Flat Rate - Domestic - medium box";
if (LocationSelected == 4) LocationLabel = "First Class - New Jersey";
if (LocationSelected == 5) LocationLabel = "Priority Mail - New Jersey";
if (LocationSelected == 6) LocationLabel = "Flat Rate - New Jersey - large box";
if (LocationSelected == 61) LocationLabel = "Flat Rate - New Jersey - envelope or small box";
if (LocationSelected == 62) LocationLabel = "Express Mail Flat Rate - New Jersey";
if (LocationSelected == 63) LocationLabel = "Flat Rate - New Jersey - medium box";
if (LocationSelected == 7) LocationLabel = "International Orders - First Class Mail<br>you will receive an e-mail with the total shipping costs";
if (LocationSelected == 71) LocationLabel = "International - Flat rate - envelope";
if (LocationSelected == 72) LocationLabel = "International - Flat rate - box";
if (LocationSelected == 73) LocationLabel = "International - Flat rate - large box";
if (LocationSelected == 70) LocationLabel = "Canada or Mexico - First Class Mail<br>you will receive an e-mail with the total shipping costs";
if (LocationSelected == 75) LocationLabel = "Canada or Mexico - Flat rate - envelope";
if (LocationSelected == 76) LocationLabel = "Canada or Mexico - Flat rate - box";
if (LocationSelected == 77) LocationLabel = "Canada or Mexico - Flat rate - large box";
if (LocationSelected == 8) LocationLabel = '<font color="#FF0000"><b>Select Shipping Option</b></font>';

if (fWeight == 0) fShipping = 0;
else fShipping = ComputeShipping(LocationSelected, fWeight);

strShipping = moneyFormat(fShipping);
strOutput += "<tr><td class=nopship colspan=3><br><b>"+strWTOT+"</b></td>";
strOutput += "<td class=nopship colspan=2 align=right><br><nobr><b>" + moneyFormat(fWeight *  .0352739) + " oz " + " - " + moneyFormat(fWeight * .0022046) + " lb " + " - " + fWeight + " g " +"</b></nobr></td>";
strOutput += "<td class=nopship colspan=1 align=right></td>";
strOutput += "<tr><td class=noptotal colspan=5><br><b>" + strSHIP + "</b>&nbsp;&nbsp;(for " + LocationLabel + ")</td>";
strOutput += "<td class=noptotal colspan=1 align=right><br><b>" + MonetarySymbol + strShipping + strSpace +"</b></td>";
strOutput += "</tr>";
}

if ( DisplayTaxRow || TaxByRegion ) {
if ( TaxByRegion ) {
strOutput += "<tr><td class=noptotal colspan=5><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=5><b>"+strTAX+"</b></td>";
strOutput += "<td class=noptotal colspan=1 align=right><b>" + MonetarySymbol + strTax + strSpace +"</b></td>";
strOutput += "</tr>";
}
}

//NJ is 4, 5, 6, 61, 62, 63
if ((LocationSelected != 0) || (LocationSelected == 1) || (LocationSelected == 2) || (LocationSelected == 3) || (LocationSelected == 31) || (LocationSelected == 32) || (LocationSelected == 33) || (LocationSelected == 7) || (LocationSelected == 71) || (LocationSelected == 72) || (LocationSelected == 73) || (LocationSelected == 70) || (LocationSelected == 75) || (LocationSelected == 76) || (LocationSelected == 77))
fTax = 0.00;
if ((LocationSelected == 0) || (LocationSelected == 4) || (LocationSelected == 5) || (LocationSelected == 6) || (LocationSelected == 61) || (LocationSelected == 62) || (LocationSelected == 63))
fTax = TaxRate * fTotal;

if ((LocationSelected == 0) || (LocationSelected == 4) || (LocationSelected == 5) || (LocationSelected == 6) || (LocationSelected == 61) || (LocationSelected == 62) || (LocationSelected == 63)) {
strOutput += "<tr><td class=noptotal colspan=5><b>"+strTAX+"</b></td>";
strOutput += "<td class=noptotal colspan=1 align=right><b>" + MonetarySymbol + strTax + strSpace +"</b></td>";
strOutput += "</tr>";
}

if ( !TaxByRegion ) {
strOutput += "<tr><td class=noptotal colspan=5><b>"+strTOT+"</b></td>";
strOutput += "<td class=noptotal colspan=1 align=right><b>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + strSpace +"</b></td>";
//strOutput += "<td class=noptotal colspan=1 align=right><b>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + strSpace +"</b>" + fTax + "-" + strTax + "-" + LocationSelected +"</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)) + "\">";
}
}
g_TotalCost = (fTotal + fShipping + fTax);

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

// FUNCTION: ComputeShipping
// PARAMETERS:
// RETURNS:
// PURPOSE: Compute shipping cost due to total weight

function ComputeShipping(Zone, TotWeight) {
LocationValue = GetCookie("ZoneSelected");

if (LocationValue != Zone) {
SetCookie("ZoneSelected", Zone, null, "/");
location.href=location.href;
}

if (TotWeight == 0) return 0.00;

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

// First Class - Domestic
if (LocationValue == 1 ) {
if (TotWeight <= 1) return 3.23;
if ((TotWeight <= 28) && (TotWeight > 1)) return (3.23 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 57) && (TotWeight > 28)) return (3.41 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 85) && (TotWeight > 57)) return (3.57 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 113) && (TotWeight > 85)) return (3.74 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 142) && (TotWeight > 113)) return (3.91 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 170) && (TotWeight > 142)) return (4.08 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 198) && (TotWeight > 170)) return (4.25 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 227) && (TotWeight > 198)) return (4.42 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 255) && (TotWeight > 227)) return (4.59 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 283) && (TotWeight > 255)) return (4.76 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 312) && (TotWeight > 283)) return (4.93 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 340) && (TotWeight > 312)) return (5.10 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 369) && (TotWeight > 340)) return (5.27 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 369) return 0.00;
}

// Priority Mail - Domestic
if (LocationValue == 2 ) {
if (TotWeight <= 1) return 7.30;
if ((TotWeight <= 454) && (TotWeight > 1)) return (7.30 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 907) && (TotWeight > 454)) return (10.45 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 1361) && (TotWeight > 907)) return (12.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 1814) && (TotWeight > 1361)) return (15.30 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 2268) && (TotWeight > 1814)) return (17.55 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 2268) return 0.00;
}

// Flat Rate - Domestic - large box
if (LocationValue == 3 ) {
if (TotWeight <= 1) return 16.50;
if ((TotWeight <= 31752) && (TotWeight > 1)) return (16.50 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 31752) return 0.00;
}

// Flat Rate - Domestic - large envelope or small box
if (LocationValue == 31 ) {
if (TotWeight <= 1) return 6.95;
if ((TotWeight <= 31752) && (TotWeight > 1)) return (6.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 31752) return 0.00;
}

// Express Mail - Domestic
if (LocationValue == 32 ) {
if (TotWeight <= 1) return 20.30;
if ((TotWeight <= 31752) && (TotWeight > 1)) return (20.30 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 31752) return 0.00;
}

// Flat Rate - Domestic - medium box
if (LocationValue == 33 ) {
if (TotWeight <= 1) return 12.70;
if ((TotWeight <= 31752) && (TotWeight > 1)) return (12.70 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 31752) return 0.00;
}

// First Class - New Jersey
if (LocationValue == 4 ) {
if (TotWeight <= 1) return 3.23;
if ((TotWeight <= 28) && (TotWeight > 1)) return (3.23 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 57) && (TotWeight > 28)) return (3.41 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 85) && (TotWeight > 57)) return (3.57 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 113) && (TotWeight > 85)) return (3.74 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 142) && (TotWeight > 113)) return (3.91 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 170) && (TotWeight > 142)) return (4.08 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 198) && (TotWeight > 170)) return (4.25 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 227) && (TotWeight > 198)) return (4.42 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 255) && (TotWeight > 227)) return (4.59 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 283) && (TotWeight > 255)) return (4.76 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 312) && (TotWeight > 283)) return (4.93 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 340) && (TotWeight > 312)) return (5.10 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 369) && (TotWeight > 340)) return (5.27 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 369) return 0.00;
}

// Priority Mail - New Jersey
if (LocationValue == 5 ) {
if (TotWeight <= 1) return 7.30;
if ((TotWeight <= 454) && (TotWeight > 1)) return (7.30 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 907) && (TotWeight > 454)) return (7.30 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 1361) && (TotWeight > 907)) return (7.85 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 1814) && (TotWeight > 1361)) return (8.45 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if ((TotWeight <= 2268) && (TotWeight > 1814)) return (9.20 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 2268) return 0.00;
}

// Flat Rate - New Jersey - large box
if (LocationValue == 6 ) {
if (TotWeight <= 1) return 16.50;
if ((TotWeight <= 31752) && (TotWeight > 1)) return (16.50 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 31752) return 0.00;
}

// Flat Rate - New Jersey - large envelope or small box
if (LocationValue == 61 ) {
if (TotWeight <= 1) return 6.95;
if ((TotWeight <= 31752) && (TotWeight > 1)) return (6.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 31752) return 0.00;
}

// Express Mail - New Jersey
if (LocationValue == 62 ) {
if (TotWeight <= 1) return 20.30;
if ((TotWeight <= 31752) && (TotWeight > 1)) return (20.30 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 31752) return 0.00;
}

// Flat Rate - New Jersey - medium box
if (LocationValue == 63 ) {
if (TotWeight <= 1) return 12.70;
if ((TotWeight <= 31752) && (TotWeight > 1)) return (12.70 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 31752) return 0.00;
}

// International
if (LocationValue == 7 ) {
if (TotWeight <= 1) return 0.00;
if ((TotWeight <= 31752) && (TotWeight > 1)) return (0.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
}

// International - Flat rate - envelope
if (LocationValue == 71 ) {
if (TotWeight <= 1) return 15.45;
if ((TotWeight <= 1814) && (TotWeight > 1)) return (15.45 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 1814) return 0.00;
}

// International - Flat rate - box
if (LocationValue == 72 ) {
if (TotWeight <= 1) return 45.45;
if ((TotWeight <= 9072) && (TotWeight > 1)) return (45.45 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 9072) return 0.00;
}

// International - Flat rate - large box
if (LocationValue == 73 ) {
if (TotWeight <= 1) return 57.95;
if ((TotWeight <= 9072) && (TotWeight > 1)) return (57.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 9072) return 0.00;
}

// Canada or Mexico
if (LocationValue == 70 ) {
if (TotWeight <= 1) return 0.00;
if ((TotWeight <= 31752) && (TotWeight > 1)) return (0.00 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
}

// Canada or Mexico - Flat rate - envelope
if (LocationValue == 75 ) {
if (TotWeight <= 1) return 13.45;
if ((TotWeight <= 1814) && (TotWeight > 1)) return (13.45 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 1814) return 0.00;
}

// Canada or Mexico - Flat rate - box
if (LocationValue == 76 ) {
if (TotWeight <= 1) return 28.95;
if ((TotWeight <= 9072) && (TotWeight > 1)) return (28.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 9072) return 0.00;
}

// Canada or Mexico - Flat rate - large box
if (LocationValue == 77 ) {
if (TotWeight <= 1) return 35.95;
if ((TotWeight <= 9072) && (TotWeight > 1)) return (35.95 + (0.00 * Math.ceil(parseFloat((TotWeight - 1) / 1))));
if (TotWeight > 9072) return 0.00;
}

if (LocationValue == 8 ) return 0.00;
}

// 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 ( isNaN (g_TotalCost) ) {
      alert( NoQtyPrompt );
      return false;
   }

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

   if ( !RadioChecked(theForm.ZONE) ) {
      alert( LocationPrompt );
      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
var strPP = ""; //Payment Processor Description Field

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=3 border=0 class=nopcart><tr>" +
"<td class=nopheader align=center><b>"+strILabel+"</b></td>" +
"<td class=nopheader align=left><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;
}
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>&nbsp;</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>&nbsp;</td>";
}

strOutput += "</tr>";
}
}
if ( AppendItemNumToOutput ) {
strFooter = i;
} else {
strFooter = "";
}
if ( PaymentProcessor == 'pp' ) {
//Process description field for payment processors instead of hidden values.
//Format Description of product as: ID, Name, Qty X
strPP += fields[3];
if ( fields[5] != "" )
strPP += " - " + fields[5] + "\n";
strOutput += "<input type=hidden name=\"item_number_" + strFooter + "\" value=\"" + fields[0] + "\">";
strOutput += "<input type=hidden name=\"add_" + strFooter + "\" value=\"" + fields[1] + "\">";
strOutput += "<input type=hidden name=\"quantity_" + strFooter + "\" value=\"" + fields[1] + "\">";
strOutput += "<input type=hidden name=\"amount_" + strFooter + "\" value=\"" + fields[2] + "\">";
strOutput += "<input type=hidden name=\"item_name_" + strFooter + "\" value=\"" + fields[3] + "\">";
//strOutput += "<input type=hidden name=\"on0_" + strFooter + "\" value=\"" + fields[5] + "\">";
if (i == iNumberOrdered) {
//strOutput += "<input type=hidden name=\"shipping_" + strFooter + "\" value=\"" + fShipping + "\">";
//strOutput += "<input type=hidden name=\"tax_1\" value=\"" + fTax + "\">";
}
} else 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=3><br><b>"+strSUB+"</b></td>";
strOutput += "<td class=noptotal colspan=2 align=right><br><b>" + MonetarySymbol + strTotal + "</b></td>";
strOutput += "</tr>";

if ( DisplayShippingRow ) {
LocationSelected = GetCookie("ZoneSelected");
if (LocationSelected == null) LocationSelected = 0; //needed if cart is empty
if (LocationSelected == 0) LocationLabel = "No Shipping Option";
if (LocationSelected == 1) LocationLabel = "First Class - Domestic";
if (LocationSelected == 2) LocationLabel = "Priority Mail - Domestic";
if (LocationSelected == 3) LocationLabel = "Flat Rate - Domestic - large box";
if (LocationSelected == 31) LocationLabel = "Flat Rate - Domestic - envelope or small box";
if (LocationSelected == 32) LocationLabel = "Express Mail Flat Rate - Domestic";
if (LocationSelected == 33) LocationLabel = "Flat Rate - Domestic - medium box";
if (LocationSelected == 4) LocationLabel = "First Class - New Jersey";
if (LocationSelected == 5) LocationLabel = "Priority Mail - New Jersey";
if (LocationSelected == 6) LocationLabel = "Flat Rate - New Jersey - large box";
if (LocationSelected == 61) LocationLabel = "Flat Rate - New Jersey - envelope or small box";
if (LocationSelected == 62) LocationLabel = "Express Mail Flat Rate - New Jersey";
if (LocationSelected == 63) LocationLabel = "Flat Rate - New Jersey - medium box";
if (LocationSelected == 7) LocationLabel = "International Order - First Class Mail:<br>You will receive an e-mail with the total shipping costs";
if (LocationSelected == 71) LocationLabel = "International - Flat rate - envelope";
if (LocationSelected == 72) LocationLabel = "International - Flat rate - box";
if (LocationSelected == 73) LocationLabel = "International - Flat rate - large box";
if (LocationSelected == 70) LocationLabel = "Canada or Mexico - First Class Mail:<br>You will receive an e-mail with the total shipping costs";
if (LocationSelected == 75) LocationLabel = "Canada or Mexico - Flat rate - envelope";
if (LocationSelected == 76) LocationLabel = "Canada or Mexico - Flat rate - box";
if (LocationSelected == 77) LocationLabel = "Canada or Mexico - Flat rate - large box";
if (LocationSelected == 8) LocationLabel = '<font color="#FF0000">Select Shipping Option</font>';

fShipping = ComputeShipping(LocationSelected, fWeight);
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=3><b>" + strSHIP + "</b>&nbsp;&nbsp;(for " + LocationLabel + ")</td>";
strOutput += "<td class=noptotal colspan=2 align=right><b>" + MonetarySymbol + strShipping + "</b></td>";
strOutput += "</tr>";
}

if ( DisplayTaxRow || TaxByRegion ) {
strOutput += "<tr><td class=noptotal colspan=3><b>"+strTAX+"</b></td>";
strOutput += "<td class=noptotal colspan=2 align=right><b>" + MonetarySymbol + strTax + "</b></td>";
strOutput += "</tr>";
}

//NJ is 4, 5, 6, 61, 62, 63
if ((LocationSelected != 0) || (LocationSelected == 1) || (LocationSelected == 2) || (LocationSelected == 3) || (LocationSelected == 31) || (LocationSelected == 32) || (LocationSelected == 33) ||(LocationSelected == 7) || (LocationSelected == 71) || (LocationSelected == 72) || (LocationSelected == 73) || (LocationSelected == 70) || (LocationSelected == 75) || (LocationSelected == 76) || (LocationSelected == 77))
fTax = 0.00;
if ((LocationSelected == 0) || (LocationSelected == 4) || (LocationSelected == 5) || (LocationSelected == 6) || (LocationSelected == 61) || (LocationSelected == 62) || (LocationSelected == 63))
fTax = TaxRate * fTotal;

if ((LocationSelected == 0) || (LocationSelected == 4) || (LocationSelected == 5) || (LocationSelected == 6) || (LocationSelected == 61) || (LocationSelected == 62) || (LocationSelected == 63)) {
strOutput += "<tr><td class=noptotal colspan=3><b>"+strTAX+"</b></td>";
strOutput += "<td class=noptotal colspan=3 align=right><b>" + MonetarySymbol + strTax + "</b></td>";
strOutput += "</tr>";
}

strOutput += "<tr><td class=noptotal colspan=3><b>"+strTOT+"</b></td>";
strOutput += "<td class=noptotal colspan=2 align=right><b>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "</b></td>";
strOutput += "</tr>";
strOutput += "</table>";

if ( PaymentProcessor == 'an') {
//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') {
//WorldPay
strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
strOutput += "<input type=hidden name=\"amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
} else if ( PaymentProcessor == 'pp') {
//PayPal
strOutput += "<input type=hidden name=\"handling_cart\" value=\"" +moneyFormat(fShipping)+"\">";
strOutput += "<input type=hidden name=\"tax_cart\" value=\"" +moneyFormat(fTax)+"\">";
} 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=\""+OutputOrderTax+"\" value=\""+ MonetarySymbol + moneyFormat(fTax) + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\" value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">";
strOutput += "<input type=hidden name=USPS value=\""+ LocationLabel + "\">";
}
}

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

// MINI CART
// FUNCTION: Print_total
// PARAMETERS: true/false if you want MonetarySymbol added to string
// RETURNS: Total cost currently racked up by shopper
// PURPOSE: Aesthetics

function Print_total(bSymbol) {
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;
if ( bSymbol )
   strOutput = MonetarySymbol + strOutput
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;

}

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