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



// set your company information here. This will all

// generated on the printable form

// Default settings are for Nebulus Designs

var myName      = 'University of Alaska Press';

var mySite      = 'http://www.uaf.edu/uapress';

var myEmail     = 'fypress@uaf.edu';

var myPhone     = 'Phone: (907) 474-5831 Fax: (907) 474-5502';

var myAddress   = 'P.O. Box 756240';

var myCityState = 'Fairbanks, AK';

var myZip       = '99775-6240';

var myCountry   = 'USA';

var myLogo      = 'http://www.uaf.edu/uapress/logo7trans.gif';



// this is your prefix for all cookies written by your

// implementation of the cart. Do not use spaces!

var myStoreName    = 'UAPRESS';



// 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: 5 mintues

var customerTime = 'setExp(0,0,0,0,0,2,0)';

var cartTime     = 'setExp(0,30,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 = 'Verdana,Arial,Helvetica';



// cart look and feel

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 cartCellSpace = 1;

var cartCellPad   = 2;



// 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 itemUpdateText     = 'Update';

var itemDeleteText     = 'Delete';

var checkoutText       = 'Checkout';

var keepShopText       = 'Keep Shopping';

var deleteCartText     = 'Delete Cart';

var printFormText      = 'Printable Form';

var unsecureFormText   = 'Unsecure Form Order';

var unsecureCreditText = 'Secure Credit';

var secureFormText     = 'Secure Form Order';

var secureCreditText   = 'Unsecure Credit';

var printMyOrderText   = 'Print My Order';

var orderFinalizeText  = 'Finalize My Order';

var editCartText       = 'Edit Cart';



// set the currency character

var currency = '$';



// set wether you want to gather seperate shipping info

var getAltShipping = true;



// enter the percentag tax to charge customers if

// they reside in your state. example - .06 is 6%

// Default setting is 6.5% for Kansas (where I live).

var stateTax = '.00';



// enter the abreviation and name of the state you live in.

// if the customer lives here, then they will get

// charged the sales tax.

// Important - leave the state abreviation and name in lower case!

// Default setting is ks/kansas

var myState1 = 'ak';

var myState2 = 'alaska';



// 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 = '10.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 = true;



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

'Domestic 4th Class Mail One Book|3.00|false',

'Domestic 4th Class Mail 2 Books|4.00|false',

'Domestic 4th Class Mail 3 Books|5.00|false',

'Domestic 4th Class Mail 4 Books|6.00|false',

'Domestic 4th Class Mail 5 Books|7.50|false',

'Domestic 4th Class Mail 6 Books|8.00|false',

'Domestic 4th Class Mail 7 Books|9.00|false',

'Domestic 4th Class Mail 8 Books|10.00|false',

'Domestic 4th Class Mail 9 Books|11.00|false',

'Domestic 4th Class Mail 10 Books or more we will contact you with shipping information|12.00|false',

'Domestic UPS Ground One Book|6.00|false',

'Domestic UPS Ground 2 Books|8.00|false',

'Domestic UPS Ground 3 Books|10.00|false',

'Domestic UPS Ground 4 Books|12.00|false',

'Domestic UPS Ground 5 Books or more we will contact you |14.00|false',

'Canadian Orders One Book|6.00|false',

'Canadian Orders 2 Books|9.00|false',

'Canadian Orders 3 Books|12.00|false',

'Canadian Orders 4 Books|15.00|false',

'Canadian Orders 5 Books or more we will contact you |18.00|false',

'Other International Orders One Book|10.00|false',

'Other International Orders 2 Books|15.00|false',

'Other International Orders 3 Books|20.00|false',

'Other International Orders 4 Books|25.00|false',

'Other International Orders 5 Books or more we will contact you |30.00|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,'USA|Canada',true),

new shipRule(100,100000,0,0,0.1,true, 'USA|Canada',true),

new shipRule(0,   49.99,0,0,9.0,false,'USA|Canada',false),

new shipRule(50, 100000,0,0,0.2,true, 'USA|Canada',false)

);



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



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

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;



// 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.html';



// set CGI/ASP Post Action path (non-secure)

// if you aren't using CGI/ASP submission, then set to ""

var unsecurePostAction = 'http://www.uaf.edu/uapress/cgi-bin/NC_writeorder.cgi';



// set the Post Action for your particular

// credit card gateway processor

// see your processor documentation for this address

var unsecureGatewayAction = 'http://www.uaf.edu/uapress/cgi-bin/NC_writeorder.cgi';



// set up the Post action for your secure form.

// If you aren't using secure ordering, then set securePostAction = ""

var securePostAction = 'https://ssl.uaf.edu/uapress/forms/NC_writeorder.cgi';



// set up the Post action for your secure form.

// If you aren't using secure ordering, then set securePostAction = ""

var secureGatewayAction = 'https://ssl.uaf.edu/uapress/forms/NC_writeorder.cgi';



// set the path to your SSL here. If you aren't using

// secure server, then this variable isn't necessary

var securePath = 'https://ssl.uaf.edu/uapress/forms';



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

);



// 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 = 'uapress@uaf.edu';



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

}