// 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      = 'Travellers Tales';
var mySite      = 'www.traveller.org';
var myEmail     = 'sales@traveller.org';
var myPhone     = '+1.415.566.2081';
var myAddress   = '1168 Stanyan St';
var myCityState = 'San Francisco, CA';
var myZip       = '94117';
var myCountry   = 'United States';
var myLogo      = '';

// this is your prefix for all cookies written by your
// implementation of the cart. Do not use spaces!
var myStoreName    = 'Traveller';

// 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,2,0)';
var cartTime     = 'setExp(0,0,1,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, Verdana, Geneva, Helvetica, sans-serif';

// 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       = 'Keep Shopping';
var deleteCartText     = 'Delete Cart';
var printFormText      = 'Print Order';
var unsecureFormText   = 'Email Order';
var unsecureCreditText = 'Unsecure Credit Card';
var secureFormText     = 'Secure Order';
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        = 'Shipping';
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/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 whether 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, use a one to one relationship
// for rates to states, zipcodes, or countries.
// Default setting is for two states, Arkansas and Kansas.
var taxRateArray = new Array(
'.0775',
'0.825'
);

// 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 = true;
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  = false;

// 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',
'calif',
'cal'
);

// set the zipcodes you want to flag for taxing.
var taxZipCodeArray = new Array(
'94101',
'94102',
'94103',
'94104',
'94105',
'94106',
'94107',
'94108',
'94109',
'94110',
'94111',
'94112',
'94113',
'94114',
'94115',
'94116',
'94117',
'94118',
'94119',
'94120',
'94121',
'94122',
'94123',
'94124',
'94125',
'94126',
'94127',
'94128',
'94129',
'94130',
'94131',
'94132',
'94133',
'94134',
'94135',
'94136',
'94137',
'94138',
'94139',
'94140',
'94141',
'94142',
'94143',
'94144',
'94145',
'94146',
'94147',
'94150',
'94151',
'94152',
'94153',
'94154',
'94155',
'94156',
'94157',
'94158',
'94159',
'94160',
'94161',
'94162',
'94163',
'94164',
'94165',
'94166',
'94167',
'94168',
'94169',
'94170',
'94171',
'94172',
'94175',
'94177',
'94188',
'94199'
);

// 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',
'usa',
'u.s.a.'
);

// 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 = '15.00';
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 = false;

// 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 = true;

// 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",
//
//BR-orig ship options:
//'USPS Priority Mail|4.95|true',
//'UPS Second Day Air|32.50|false',
//'FedEx Ground|40.95|false'
var shipOptions = new Array(
'USPS Priority Mail|4.95|false',
'UPS Second Day Air|32.50|false',
'FedEx Ground|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.
//
//BR- Orig ship rules:
//new shipRule(0,   99.99,0,0,4.5,false,'US|CA',true),
//new shipRule(100,100000,0,0,0.1,true, 'US|CA',false),
//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)

//BR-Country must use both the short 'FR' code and full country name 'France' for shipping
//to work under NS and IE. If only use short code it will work solely in IE.
var myShipRules = new Array(
new shipRule(0,0,1,100000,.16,true,'US|United States',true),
new shipRule(0,0,1,100000,.355,true,'US|United States',false)
);

// set whether you will use discounts on your site or not.
var useDiscount = true;

// 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.
//
//BR-orig list
//'2|4|.05',
//'5|7|.07',
//'8|10|.08'
var discountArray = new Array(
'friend10|.10',
'friend15|.15',
'friend20|.20',
'friend25|.25',
'friend30|.30',
'brazil|.2375',
'stock|.2375'
);

// set this option for which credit cards you accept
// use the same formatting as the shipOptions
var cardOption = new Array(
'Visa',
'MasterCard'
);

// 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 = true;

// set whether you want to allow order submission through a payment
// gateway or alternate method
var useGateway = false;

// 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 = 'http://www.traveller.org/store/cart/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 = '/store/cart/printverify.html';

// the printable order form
var COprint = '/store/cart/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.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.
// OPTION 1: post the order to our FREE mailer.
var unsecurePostAction = 'http://www.traveller.org/cgi-bin/nc.pl';
// OPTION 2: post the order to the cart post testing page
//var unsecurePostAction = 'http://www.javascriptcart.com/testing/cart_tester.asp';
// OPTION 3: post the order to your installation of the Order Capture script
//var unsecurePostAction = 'http://www.yoursite.com/cgi-bin/nc.pl';

// set the Post Action for your particular
// credit card gateway processor
// see your processor documentation for this address
// OPTION 1: post the order to our FREE mailer.
var unsecureGatewayAction = 'http://www.traveller.org/cgi-bin/nc.pl';
// OPTION 2: post the order to the cart post testing page
//var unsecureGatewayAction = 'http://www.javascriptcart.com/testing/cart_tester.asp';
// OPTION 3: post the order to your installation of the Order Capture script
//var unsecureGatewayAction = 'http://www.yoursite.com/cgi-bin/nc.pl';

// set up the Post action for your secure form.
// If you aren't using secure ordering, then set securePostAction = ""
// OPTION 1: post the order to our FREE mailer.
var securePostAction = 'https://secure.hostmonster.com/~travell6/cgi-bin/nc.pl';
// OPTION 2: post the order to the cart post testing page
//var securePostAction = 'https://www.yoursite.com/cgi-bin/nc.pl';
// OPTION 3: post the order to your installation of the Order Capture script
//var securePostAction = 'https://www.yoursite.com/cgi-bin/nc.pl';

// set up the Post action for your secure form.
// If you aren't using secure ordering, then set securePostAction = ""
// OPTION 1: post the order to our FREE mailer.
var secureGatewayAction = 'https://secure.hostmonster.com/~travell6/cgi-bin/nc.pl';
// OPTION 2: post the order to the cart post testing page
//var secureGatewayAction = 'https://www.yoursite.com/cgi-bin/nc.pl';
// OPTION 3: post the order to your installation of the Order Capture script
//var secureGatewayAction = 'https://www.yoursite.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://secure.hostmonster.com/~travell6/store/cart/';

// 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="NC_FromCart"      value="1">',
'<input type="hidden" name="NC_Email"         value="sales@traveller.org">',
'<input type="hidden" name="NC_Subject"       value="Traveller New Order">',
'<input type="hidden" name="NC_Header"        value="Thank you for your recent Travellers Tales Order">',
'<input type="hidden" name="NC_Footer"        value="www.traveller.org">',
'<input type="hidden" name="NC_Message"       value="Thank you.">',
'<input type="hidden" name="NC_Redirect2"     value="http://www.traveller.org">',
'<input type="hidden" name="NC_EmailCustomer" value="1">',
'<input type="hidden" name="NC_SilentPost"    value="http://www.javascriptcart.com/NC_silentpost.asp">'
);

// 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