// NebuCart - The JavaScript Shopping Cart
// E-Commerce YOUR way
// by Nebulus Designs
//
// Copyright 1999-2001 all rights reserved.

// None of this script may be redistributed or sold
// without the authors express consent.
// Violations of copyright will be prosecuted.

// If you would like to use NebuCart,
// email us at nebucart@nebulus.org
// or visit http://nebucart.nebulus.org

// ********************************************
// NebuCart User Defined Settings             *
// ********************************************
// Cart variables - you edit these to taste   *
// ********************************************

// Debug Mode. Setting DEBUG to true will allow
// you to see descriptions of errors in a window.
// You should probably set this to false
// when you run the cart live
var DEBUG       = false;

// set your company information here. This will all
// generated on the printable form
// Default settings are for Nebulus Designs
var myName      = 'AquaClip';
var mySite      = 'http://www.aquaclip.com';
var myEmail     = 'aquahook@earthlink.net';
var myPhone     = '(714) 848-7130';
var myAddress   = 'P.O. Box 3656';
var myCityState = 'Huntington Beach, CA';
var myZip       = '92605';
var myCountry   = 'USA';
var myLogo      = '';

// this is your prefix for all cookies written by your
// implementation of the cart. Do not use spaces!
var myStoreName    = 'AquaClip';

// set the domain values for your cookies.
// this should allow you to put catalog
// pages in different directories.
// domain values require two "."!
var unsecureDomain = '';
var secureDomain   = '';

// set the path for the cookies
// currently, we set the path as root.
var cookiePath     = '/';

// set customer Info persistence and
// cart persistence via cookies.
// usage: "setExp(S,M,H,D,W,Mo,Y)"
// S = seconds, M = minutes, H = hours
// D = days, W = weeks, Mo = months, Y = years

// note, customer info should persist for a while, say
// 2 to 3 months or longer, but cart data should only
// last a few minutes for the shopping experience.
// default times:
// customer: 2  months,
// cart:     10 mintues
var customerTime = 'setExp(0,0,0,0,0,12,0)';
var cartTime     = 'setExp(0,45,0,0,0,0,0)';

// set this variable to true if you don't want the
// cart page to display each time an item's added.
// if set to true, you will get a pop up instead.
var supressCart  = false;

// set the font face to whatever font you're using on your site
// Default setting is "arial,helvetica"
var fontFace = 'Arial,Helvetica';

// cart look and feel
// these set the colors for the cart table
var cartHeader       = 'silver';
var cartRow1         = 'white';
var cartRow2         = '#DDDDDD';
var cartTaxRow       = '#DDDDDD';
var cartShipRow      = '#DDDDDD';
var cartSubRow       = '#DDDDDD';
var cartTotalRow     = 'silver';
var cartBorder       = '0';
var cartCellPad      = '2';
var cartCellSpace    = '2';
var cartHeaderTxt    = 'black';
var cartRowTxt       = 'black';
var cartTaxRowTxt    = 'black';
var cartShipRowTxt   = 'black';
var cartSubRowTxt    = 'black';
var cartTotalRowTxt  = 'black';

// cart button text
// these variables set the text for each button in the cart
// some are used in more places than one, so use general
// descriptions!
var backText           = '<< Back';
var clearFormText      = 'Clear';
var cartUpdateText     = 'Update Cart';
var checkoutText       = 'Checkout >>';
var keepShopText       = '<< Conintue Shopping';
var deleteCartText     = 'Empty Cart';
var printFormText      = 'Print Order';
var unsecureFormText   = 'Email Order';
var unsecureCreditText = 'Unsecure Credit Card';
var secureFormText     = 'Secure Email';
var secureCreditText   = 'Secure Credit Card >>';
var printMyOrderText   = 'Print My Order';
var orderFinalizeText  = 'Finalize My Order';
var editCartText       = 'Edit Cart';

// cart title text
// these variables set the text for the cart table header
// and for other titles in the cart table
var cartIDText         = 'Item Number';
var cartDescText       = 'Description';
var cartOptText        = 'Options';
var cartPriceText      = 'Price';
var cartCostText       = 'Cost';
var cartQtyText        = 'Quantity';
var cartTotalText      = 'Total:';
var cartSubtotalText   = 'Subtotal:';
var cartTaxText        = 'Tax:';
var cartSnHText        = 'S &amp; H';
var cartDiscountText   = 'Quantity Discount:';
var cartEmptyText      = 'Your cart is currently empty';

// billing/shipping titles
// these variables set the text for the billing and shipping
// information form.
var billBillTitleTxt   = 'Billing and Shipping Information:';
var billShipTitleTxt   = 'Shipping Information:';
var billDifShipTxt     = 'different from billing';
var billFirstNameTxt   = 'First Name:';
var billLastNameTxt    = 'Last Name:';
var billEmailTxt       = 'Email:';
var billPhoneTxt       = 'Phone Number:';
var billAdd1Txt        = 'Address 1:';
var billAdd2Txt        = 'Address 2:';
var billCityTxt        = 'City:';
var billStateTxt       = 'State/Province:';
var billZipTxt         = 'Postal Code:';
var billCountryTxt     = 'Country:';

// set wether you want to use a simple text field or a drop down
// list for billing/shipping state. Default is true (use a list)
// Note: The state list uses the ISO US state list, so for a non-US
//       list, you will need to edit the function "writeStates"
//       in the file NC_getshipping.js
var useStateSelect = true;

// set whether you want to make the customer enter their
// credit card security number (cvv2)
var useCVV2 = true;

// set the currency character
var currency = '$';

// set whether you want to use the decimal in the cost or not.
// NOTE: this will concatonate values! $10.25 will become $1025.
// Default is true.
var useDecimal   = true;

// set whether you want to use a thousands delimiter.
// NOTE: this will add a comma for every 3 digits. $1025 will become $1,025.
// Default is false
var useThousands = false;

// set wether you want to gather seperate shipping info
var getAltShipping = true;

// enter the percentage tax to charge customers if
// you will charge tax. example - .06 is 6%
// To use only one tax rate for all transactions, just enter
// on percentage. For multiple rates, usea one to one relationship
// for rates to states, zipcodes, or countries.
// Default setting is for two states, Arkansas and Kansas.
// 4-7-2009 Troy  Updated tax from .0775 to .0875
// 7-11-2011 Troy  Updated tax from .0875 to .0775
var taxRateArray = new Array(
'.0775'
);

// set whether you want to charge tax all the time. If so,
// you do not need to edit the taxOnCountry or taxOnState variables
// as this variable overrides all other tax flags. It will use the
// first index in the tax rate array only.
var alwaysTax = false;

// set whether you want to charge tax by country or by state/province
// if you want to use either of these two variables, then make sure that
// alwaysTax = false
// NOTE: the variable heirarchy is as follows:
// 1) taxOnState 2) taxOnZipCode 3) taxOnCountry
var taxOnState   = true;
var taxOnZipCode = false;
var taxOnCountry = false;

// some states/provinces/countries require that you tax the shipping
// set this to true if you are required to tax shipping.
var taxShipping  = true;

// set whether you want to charge tax by the billing address
// or shipping address, if shipping address is different.
// Default is shipping address.
// Note: if no alternate shipping address is used,
// tax rate gets calculated by billing address.
var taxOnShipAddress = true;

// set the state(s) you want to flag for taxing. Make sure that
// you use the common abreviation as well as the full name, all lower case!
var taxStateArray = new Array(
'ca',
'california'
);

// set the zipcodes you want to flag for taxing.
var taxZipCodeArray = new Array(
'66062',
'72205'
);

// set the country(s) you want to flag for taxing. Make sure that
// you use the common abreviation as well as the full name, all lower case!
var taxCountryArray = new Array(
'us',
'united states'
);

// enter shipping amount in percentage or straight charge.
// if you use a percentage, then set shipPercent = true,
// otherwise set it to false.
// Default setting is 10%
var shipAmt = '0';
var shipPercent = false;

// set shipping cost per item.
// If set to true and shipPercent is false, then the cusomter will
// be charged shipping on a per item basis.
// If set to true, shipPercent is false, and useShipOptions is false,
// then the cusomter will be charged the set shipping amount per item ordered.
var shipPerItem = true;

// set this to true if you want to use shipping
// options as opposed to a set amount or percentage.
// set to false to use a set amount or percentage
// This will override the variables shipAmt, shipPercent, and shipPerItem
var useShipOptions = false;

// set this to true if you want to use shipping
// rules as opposed to a set amount, percentage, or straight shipping options
// shipPercent, shipPerItem, and shipOptions must be false!
var useShipRules = false;

// this will define a set of radio buttons for your shipping options.
// the true/false at the end is for setting that shipping option to
// be charged per each item ordered.
// Formatting:
// One option per line - "Options Description + | + option cost + | true/false",
var shipOptions = new Array(
'UPS Ground|14.95|true',
'UPS Second Day Air|32.50|false',
'FedEx Overnight|40.95|false'
);

// this will define a set of rules for what amount ot charge for shipping
// should you decide not to use options, set amount, percentage, etc.
// Formatting:
// Define a new shipRule per line and pass the proper arguments:
// new shipRule(amtLbound,amtUbound,qtyLbound,qtyUbound,shipCost,percent,countries,applyDomestic)
// amtLbound & amtUbound - the monetary range of the order to apply this rule.
//						   set both  to 0 to disqualify the amount range.
//						   if you don't use amount, then you must use the quantity
//						   bounds for the rule.
// qtyLbound & qtyUbound - the item quantity range of the order to apply this rule
//						   set both  to 0 to disqualify the quantity range.
//						   if you don't use quantity, then you must use the amount
//						   bounds for the rule.
// shipCost              - any numerical value
// percent               - true/false. True charges the shipCost as a percentage of
//						   the order subtotal. False charges as a straight amount
// countries             - the listing of the countries that you consider in your
//                         national shipping area. List must be delimited with a |
// applyDomestic         - true/false. True applies the rule if the customer's
//                         country of residence matches your list and other
//                         qualifiers apply. False applies the rule if the
//                         customer's country does NOT match the list (international)
//                         and other qualifiers apply.
var myShipRules = new Array(
new shipRule(0,   99.99,0,0,4.5,false,'US|CA',true),
new shipRule(100,100000,0,0,0.1,true, 'US|CA',true),
new shipRule(0,   49.99,0,0,9.0,false,'US|CA',false),
new shipRule(50, 100000,0,0,0.2,true, 'US|CA',false)
);

// set whether you will use discounts on your site or not.
var useDiscount = false;

// if you're using discounts, set whether you want to allow
// discounts by quantity or by a code. If set to false,
// then the discount will be by code. Default is to
// discount by quantity!
var discountByQty = false;

// fill this array with the quantity range and the percentage discount.
// Formatting (discount by quantity):
// one discount option per line: 'Min qty | Max qty | Percent'
// Formatting (discount by code):
// one discount option per line: 'Code | Percent'
// to make things easy, discount codes will be converted to lowercase
// before matching so customers won't need to worry about it.
var discountArray = new Array(
'2|4|.05',
'5|7|.07',
'8|10|.08'
);

// set this option for which credit cards you accept
// use the same formatting as the shipOptions
var cardOption = new Array(
'Visa',
'MasterCard',
'Discover'
);

// set whether you'd like to allow a printable form for orders
// If you don't use a printable form, then make sure you
// have your form or gateway based ording variables set!
// default is true
var usePrint = false;

// set whether you want to allow CGI or ASP form based order submission.
// default is true
var useForm = false;

// set whether you want to allow order submission through a payment
// gateway or alternate method
var useGateway = true;

// set wether you want to allow customers the option to use
// unsecure order submission (not including printable forms)
// if useSecure is false and/or you're missing your secure
// page settings, the cart defaults to unsecure ordering
var useUnsecure = false;

// set whether you want to allow secure order submission.
// default is true
var useSecure = true;

// if your site uses framesets, then set secureBreakFrames to true.
// this will allow the transfer to the secure sever occur outside
// the frameset so the browser will display the lock icon.
//
// if you are using frames and do not set this variable to true,
// the cart may not transfer to secure properly
//
// if you aren't using frames, dont' touch, and keep moving!
var secureBreakFrames = false;

// the page that displays the cart contents
// if the cart script is on this page, it will display
// update/delete buttons for your items
// otherwise, it displays as a receipt format.
var cartPage = 'cart.html';

// set the names of the cart pages
// the page where we get the shipping information
var COstep1 = 'customer_data.html';

// the last step for printing an order form (verify address, etc.)
var COprintVerify = 'printverify.html';

// the printable order form
var COprint = 'printorder.html';

// the page that will build the form data
// for posting to your form handling CGI/ASP
// this will post to the unsecure form handler
// defined by 'unsecurePostAction'
var COform = 'formorder.html';

// the page that will build the form data
// for credit card validation
// through your merchant account
// this will post to the unsecure form handler
// defined by 'unsecureGatewayAction'
var COgateway = 'gateway.html';

// the page that will build the form data
// for the secure CGI/ASP order form submission
// This posts the order to your form handling CGI script
// defined by 'securePostAction'
var COsecureForm = 'secure_formorder.html';

// the page tha will build the form data
// for secure credit card validation
// through your merchant account
// this posts the order to the merchant account gateway
// or account handling script defined by 'secureGatewayAction'
var COsecureGateway = 'secure_gateway_a.html';

// set CGI/ASP Post Action path (non-secure)
// if you aren't using CGI/ASP submission, then set to "not_used"
// if you'd like to test the cart to make sure it's posting,
// uncomment the line below and comment out the line under that
// (the link to nc.pl). The cart_tester.asp link will
// display what's posted from the cart at checkout.
var unsecurePostAction = 'http://www.javascriptcart.com/testing/cart_tester.asp';
//var unsecurePostAction = 'http://www.nebulus.org/Cgi-bin/nc.pl';

// set the Post Action for your particular
// credit card gateway processor
// see your processor documentation for this address
var unsecureGatewayAction = 'http://www.javascriptcart.com/testing/cart_tester.asp';
// var unsecureGatewayAction = 'http://www.nebulus.org/Cgi-bin/nc.pl';

// set up the Post action for your secure form.
// If you aren't using secure ordering, then set securePostAction = ""
var securePostAction = 'https://www.nebulus.org/nebucart/testing/cart_tester.asp';
// var securePostAction = 'https://www.nebulus.org/Cgi-bin/nc.pl';

// set up the Post action for your secure form.
// If you aren't using secure ordering, then set securePostAction = ""
// var secureGatewayAction = 'https://www.nebulus.org/Cgi-bin/nc.pl';
var secureGatewayAction = 'https://www.aquaclip.com/cgi-bin/nc.pl';
// var secureGatewayAction = 'https://207.142.134.121/*aquaclip.com/cgi-bin/nc.pl';


// set the path to your SSL here. If you aren't using
// secure server, then this variable isn't necessary
var securePath = 'https://www.aquaclip.com/';
//var securePath = 'https://www.aquaclip.com/new';
// var securePath = 'https://207.142.134.121/*aquaclip.com/httpdocs/new/';

// set up an array of tags for your specific form handling CGI script
// see the form script help file for required/optional tags
// be sure to use escape charcaters (see example)!
// by default, these tags are specifically coded for use with
// Matt's Script Archive formmail.cgi
var extraFormTags = new Array(
'<input type="hidden" name="Merchant_ID" value="123">',
'<input type="hidden" name="Merchant_Email" value="pfriedl@nebulus.org">'
);

// set the name of the field that designates the mail recipient for
// your form handling CGI or ASP. This gets used to add the customer's email
// to this field so that they get a copy of the order as well.
// leave blank if you have another method of mailing a receipt to the
// customer
var cgiMailField = '';

// Shipping Rule Object - Do not edit
function shipRule(amtLbound,amtUbound,qtyLbound,qtyUbound,shipCost,percent,countries,applyDomestic){
	this.amtLbound     = amtLbound;
	this.amtUbound     = amtUbound;
	this.qtyLbound     = qtyLbound;
	this.qtyUbound     = qtyUbound;
	this.shipCost      = shipCost;
	this.percent       = percent;
	this.countries     = countries;
	this.applyDomestic = applyDomestic
}

// TEST CREDIT CARD NUMBERS
// 370000000000002  American Express
// 6011000000000012 Discover
// 5424000000000015 MasterCard
// 4007000000027    Visa
