//=====================================================================||
// NOP Design JavaScript Shopping Cart ||
// ||
// For more information on SmartSystems, or how NOPDesign can help you ||
// Please visit us on the WWW at http://www.nopdesign.com ||
// ||
// Javascript portions of this shopping cart software are available as ||
// freeware from NOP Design. You must keep this comment unchanged in ||
// your code. For more information contact FreeCart@NopDesign.com. ||
// ||
// JavaScript Shop Module, V.4.4.0 ||
//=====================================================================||

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


//=====================================================================||
//
// Australia Post shipping mods by Bob Gilmour - 2004
//
// Version History: Nov 2, 2004 - Initial Working Draft
//					March, 2006 - Interim Update
//					April, 2006 - Begin full update


//=====================================================================||

//---------------------------------------------------------------------||
// Global Options ||
// ---------------- ||
// Shopping Cart Options, you can modify these options to change the ||
// the way the cart functions. ||
// ||
// Language Packs ||
// ============== ||
// You may include any language pack before nopcart.js in your HTML ||
// pages to change the language. Simply include a language pack with ||
// a script src BEFORE the <SCRIPT SRC="../os1/nopcart.js">... line. ||
// For example: <SCRIPT SRC="language-en.js"></SCRIPT> ||
// ||
// Options For Everyone: ||
// ===================== ||
// * MonetarySymbol: string, the symbol which represents dollars/euro, ||
// in your locale. ||
// * DisplayNotice: true/false, controls whether the user is provided ||
// with a popup letting them know their product is added to the cart ||
// * DisplayShippingColumn: true/false, controls whether the managecart||
// and checkout pages display shipping cost column. ||
// * DisplayShippingRow: true/false, controls whether the managecart ||
// and checkout pages display shipping cost total row. ||
// * DisplayTaxRow: true/false, controls whether the managecart ||
// and checkout pages display tax cost total row. ||
// * TaxRate: number, your area's current tax rate, ie: if your tax ||
// rate was 7.5%, you would set TaxRate = 0.075 ||
// * TaxByRegion: true/false, when set to true, the user is prompted ||
// with TaxablePrompt to determine if they should be charged tax. ||
// In the USA, this is useful to charge tax to those people who live ||
// in a particular state, but no one else. ||
// * TaxPrompt: string, popup message if user has not selected either ||
// taxable or nontaxable when TaxByRegion is set to true. ||
// * TaxablePrompt: string, the message the user is prompted with to ||
// select if they are taxable. If TaxByRegion is set to false, this ||
// has no effect. Example: 'Arizona Residents' ||
// * NonTaxablePrompt: string, same as above, but the choice for non- ||
// taxable people. Example: 'Other States' ||
// * MinimumOrder: number, the minium dollar amount that must be ||
// purchased before a user is allowed to checkout. Set to 0.00 ||
// to disable. ||
// * MinimumOrderPrompt: string, Message to prompt users with when ||
// they have not met the minimum order amount. ||
// ||
// Payment Processor Options: ||
// ========================== ||
// * PaymentProcessor: string, the two digit payment processor code ||
// for support payment processor gateways. Setting this field to ||
// anything other than an empty string will override your OutputItem ||
// settings -- so please be careful when receiving any form data. ||
// Support payment processor gateways are: ||
// * Authorize.net (an) ||
// * Worldpay (wp) ||
// * LinkPoint (lp) ||
// ||
// Options For Programmers: ||
// ======================== ||
// * OutputItem<..>: string, the name of the pair value passed at ||
// checkouttime. Change these only if you are connecting to a CGI ||
// script and need other field names, or are using a secure service ||
// that requires specific field names. ||
// * AppendItemNumToOutput: true/false, if set to true, the number of ||
// each ordered item will be appended to the output string. For ||
// example if OutputItemId is 'ID_' and this is set to true, the ||
// output field name will be 'ID_1', 'ID_2' ... for each item. ||
// * HiddenFieldsToCheckout: true/false, if set to true, hidden fields ||
// for the cart items will be passed TO the checkout page, from the ||
// ManageCart page. This is set to true for CGI/PHP/Script based ||
// checkout pages, but should be left false if you are using an ||
// HTML/Javascript Checkout Page. Hidden fields will ALWAYS be ||
// passed FROM the checkout page to the Checkout CGI/PHP/ASP/Script ||
//---------------------------------------------------------------------||

//Options for Everyone:
MonetarySymbol = 'Au$';
DisplayNotice = true;
DisplayChangeQty = true;
DisplayShippingColumn = true;
DisplayShippingRow = true;
TaxRate = 0.063; //set taxable region rate ||
DisplayTaxRow = false;
TaxByRegion = false; //leave this at false, UPS Shipping Mod will activate taxable Zone ||
TaxPrompt = 'For tax purposes, please select if you are an Kansas branch of Oasis before continuing'; //Deactivated ||
TaxablePrompt = 'Kansas Branch'; //Deactivated ||
NonTaxablePrompt = 'Other Branches'; //Deactivated ||
MinimumOrder = 0.01;
MinimumOrderPrompt = 'Oops!\n\nWe can not proceed to check out since\nthere is no item in the shopping cart.';
//original syntax - MinimumOrderPrompt = 'Your order is below our minimum order, please order more before checking out.';

PromptEmptyCart = 'Your shopping cart is empty ... you cannot proceed to the CheckOut.'; //If attempted to go to checkout before selecting shipping zone ||
PromptNoCountry = 'You have not selected a shipping destination country.';
PromptNoShipping = 'Please select a shipping method.';
PromptNoPostCode = 'Please enter your Australian shipping address post code';
PromptNoInsurance = 'Please select if insurance is required or not';

//Payment Processor Options:
PaymentProcessor = '';

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

//Options for Shipping by Weight:
LocationLabel = 'ZONE';
LocationPrompt = 'For shipping purpose, please select the zone that your location is in.';
ShippingPrompt = 'Please indicate a shipping method.';
MaxWeightPrompt = 'Sorry, maximum weight allowable is 20 kgs.';



//=====================================================================||
//---------------------------------------------------------------------||
// YOU DO NOT NEED TO MAKE ANY MODIFICATIONS BELOW THIS LINE ||
//---------------------------------------------------------------------||
//=====================================================================||


//---------------------------------------------------------------------||
// Language Strings ||
// ------------------ ||
// These strings will not be used unless you have not included a ||
// language pack already. You should NOT modify these, but instead ||
// modify the strings in language-**.js where ** is the language pack ||
// you are using. ||
//---------------------------------------------------------------------||
if ( !bLanguageDefined ) {
strSorry = "I'm Sorry, your cart is full, please proceed to checkout.";
strAdded = " Added to your shopping cart.";
strRemove = "Click 'Ok' to remove this product from your shopping cart.";
strILabel = "Product Id";
strDLabel = "Product Name/Description";
strQLabel = "Qty";
strPLabel = "Price";
strSLabel = "Weight"; //Added for UPS mod ||
strRLabel = ""; //Remove From Cart ||
strRButton= "Remove";
strSUB = "SUBTOTAL";
strNULL = "";
strWTOT = "TOTAL WEIGHT"; //Added for UPS mod ||
strSHIP = "SHIPPING";
strINSR = "INSURANCE";
strTAX = "TAX";
strTOT = "TOTAL";
strErrQty = "Invalid Quantity.";
strNewQty = 'Please enter new quantity:';
strSpace = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
bLanguageDefined = false;
}


//---------------------------------------------------------------------||
//---------------------------------------------------------------------||
//DEFINING GLOBAL VARIABLES FOR SINGLE PAGE SHOPPING CART OPERATION
//defining the arrays that transaction data will be storred in
ID = new Array;
QUANTITY = new Array;
PRICE = new Array;
NAME = new Array;
WEIGHT = new Array;
ADDTLINFO = new Array;

EXTAMOUNT = new Array;


//DEFINING SINGLE VARIABLES TO STORE INFO TO GO TO CHECKOUT
var ROWS;

var COUNTRY_SELECTED;
var POST_CODE;
var SHIPPING_CHARGE;
var INSURANCE_CHARGE;
var SHIPPING_METHOD;
var TOTAL_WEIGHT;


var SUB_TOTAL;
var TOTAL;

var ZONE;
var COUNTRY;


// --------------------------------------------------------------------------------------------
// SHIPPING CHARGE CONSTANTS

// AUSTRALIA
var AUST_SHIP = new Array()
AUST_SHIP["N1_base"] = 3.80;
AUST_SHIP["N1_1"] = 4.90;
AUST_SHIP["N1_2"] = 10.00;
AUST_SHIP["N1_x"] = 1.75;

AUST_SHIP["N2_base"] = 3.80;
AUST_SHIP["N2_1"] = 4.90;
AUST_SHIP["N2_2"] = 10.05;
AUST_SHIP["N2_x"] = 1.80;

AUST_SHIP["V1_base"] = 3.80;
AUST_SHIP["V1_1"] = 4.90;
AUST_SHIP["V1_2"] = 10.10;
AUST_SHIP["V1_x"] = 1.85;

AUST_SHIP["V2_base"] = 3.80;
AUST_SHIP["V2_1"] = 4.90;
AUST_SHIP["V2_2"] = 10.60;
AUST_SHIP["V2_x"] = 2.35;

AUST_SHIP["Q1_base"] = 3.80;
AUST_SHIP["Q1_1"] = 4.90;
AUST_SHIP["Q1_2"] = 7.45;
AUST_SHIP["Q1_x"] = 0.90;

AUST_SHIP["Q2_base"] = 3.80;
AUST_SHIP["Q2_1"] = 4.90;
AUST_SHIP["Q2_2"] = 7.45;
AUST_SHIP["Q2_x"] = 0.90;

AUST_SHIP["Q3_base"] = 3.80;
AUST_SHIP["Q3_1"] = 4.90;
AUST_SHIP["Q3_2"] = 7.15;
AUST_SHIP["Q3_x"] = 0.60;

AUST_SHIP["Q4_base"] = 3.80;
AUST_SHIP["Q4_1"] = 4.90;
AUST_SHIP["Q4_2"] = 7.10;
AUST_SHIP["Q4_x"] = 0.55;

AUST_SHIP["S1_base"] = 3.80;
AUST_SHIP["S1_1"] = 4.90;
AUST_SHIP["S1_2"] = 10.70;
AUST_SHIP["S1_x"] = 2.45;

AUST_SHIP["S2_base"] = 3.80;
AUST_SHIP["S2_1"] = 4.90;
AUST_SHIP["S2_2"] = 10.85;
AUST_SHIP["S2_x"] = 2.60;

AUST_SHIP["NT1_base"] = 3.80;
AUST_SHIP["NT1_1"] = 4.90;
AUST_SHIP["NT1_2"] = 10.00;
AUST_SHIP["NT1_x"] = 1.75;

AUST_SHIP["W1_base"] = 3.80;
AUST_SHIP["W1_1"] = 4.90;
AUST_SHIP["W1_2"] = 11.00;
AUST_SHIP["W1_x"] = 2.75;

AUST_SHIP["W2_base"] = 3.80;
AUST_SHIP["W2_1"] = 4.90;
AUST_SHIP["W2_2"] = 11.15;
AUST_SHIP["W2_x"] = 2.90;

AUST_SHIP["W3_base"] = 3.80;
AUST_SHIP["W3_1"] = 4.90;
AUST_SHIP["W3_2"] = 11.30;
AUST_SHIP["W3_x"] = 3.05;

AUST_SHIP["T1_base"] = 3.80;
AUST_SHIP["T1_1"] = 4.90;
AUST_SHIP["T1_2"] = 11.15;
AUST_SHIP["T1_x"] = 2.90;

AUST_SHIP["NF_base"] = 3.45;
AUST_SHIP["NF_1"] = 4.45;
AUST_SHIP["NF_2"] = 11.15;
AUST_SHIP["NF_x"] = 3.65;


// INTERNATIONAL
var INTL_AIR_SHIP = new Array() // AIRMAIL
INTL_AIR_SHIP["A_base"] = 6.25;
INTL_AIR_SHIP["A_x1"] = 3.25;
INTL_AIR_SHIP["A_x2"] = 3.40;

INTL_AIR_SHIP["B_base"] = 7.25;
INTL_AIR_SHIP["B_x1"] = 4.25;
INTL_AIR_SHIP["B_x2"] = 4.40;

INTL_AIR_SHIP["C_base"] = 8.25;
INTL_AIR_SHIP["C_x1"] = 5.25;
INTL_AIR_SHIP["C_x2"] = 6.40;

INTL_AIR_SHIP["D_base"] = 9.75;
INTL_AIR_SHIP["D_x1"] = 6.75;
INTL_AIR_SHIP["D_x2"] = 8.40;


var INTL_EPI_SHIP = new Array()
INTL_EPI_SHIP["A_base"] = 34.00;
INTL_EPI_SHIP["A_x"] = 3.40;

INTL_EPI_SHIP["B_base"] = 42.00;
INTL_EPI_SHIP["B_x"] = 4.40;

INTL_EPI_SHIP["C_base"] = 50.00;
INTL_EPI_SHIP["C_x"] = 6.40;

INTL_EPI_SHIP["D_base"] = 62.00;
INTL_EPI_SHIP["D_x"] = 8.40;



var INTL_ECI_SHIP = new Array()
INTL_ECI_SHIP["A_upto_.5"] = 37.50;
INTL_ECI_SHIP["A_upto_1"] = 42.00;
INTL_ECI_SHIP["A_upto_2"] = 49.50;
INTL_ECI_SHIP["A_upto_3"] = 57.00;
INTL_ECI_SHIP["A_upto_5"] = 72.50;
INTL_ECI_SHIP["A_upto_7.5"] = 92.50;
INTL_ECI_SHIP["A_upto_10"] = 113.00;
INTL_ECI_SHIP["A_upto_12.5"] = 133.00;
INTL_ECI_SHIP["A_upto_15"] = 153.00;
INTL_ECI_SHIP["A_upto_17.5"] = 173.00;
INTL_ECI_SHIP["A_upto_20"] = 193.00;

INTL_ECI_SHIP["B_upto_.5"] = 40.00;
INTL_ECI_SHIP["B_upto_1"] = 16.50;
INTL_ECI_SHIP["B_upto_2"] = 55.50;
INTL_ECI_SHIP["B_upto_3"] = 67.50;
INTL_ECI_SHIP["B_upto_5"] = 88.00;
INTL_ECI_SHIP["B_upto_7.5"] = 115.50;
INTL_ECI_SHIP["B_upto_10"] = 143.00;
INTL_ECI_SHIP["B_upto_12.5"] = 170.50;
INTL_ECI_SHIP["B_upto_15"] = 198.00;
INTL_ECI_SHIP["B_upto_17.5"] = 225.50;
INTL_ECI_SHIP["B_upto_20"] = 253.00;

INTL_ECI_SHIP["C_upto_.5"] = 43.50;
INTL_ECI_SHIP["C_upto_1"] = 52.00;
INTL_ECI_SHIP["C_upto_2"] = 62.50;
INTL_ECI_SHIP["C_upto_3"] = 77.00;
INTL_ECI_SHIP["C_upto_5"] = 104.00;
INTL_ECI_SHIP["C_upto_7.5"] = 139.00;
INTL_ECI_SHIP["C_upto_10"] = 174.00;
INTL_ECI_SHIP["C_upto_12.5"] = 211.00;
INTL_ECI_SHIP["C_upto_15"] = 248.50;
INTL_ECI_SHIP["C_upto_17.5"] = 286.00;
INTL_ECI_SHIP["C_upto_20"] = 323.50;

INTL_ECI_SHIP["D_upto_.5"] = 45.50;
INTL_ECI_SHIP["D_upto_1"] = 55.00;
INTL_ECI_SHIP["D_upto_2"] = 69.50;
INTL_ECI_SHIP["D_upto_3"] = 86.50;
INTL_ECI_SHIP["D_upto_5"] = 120.50;
INTL_ECI_SHIP["D_upto_7.5"] = 163.00;
INTL_ECI_SHIP["D_upto_10"] = 205.50;
INTL_ECI_SHIP["D_upto_12.5"] = 248.00;
INTL_ECI_SHIP["D_upto_15"] = 290.50;
INTL_ECI_SHIP["D_upto_17.5"] = 333.00;
INTL_ECI_SHIP["D_upto_20"] = 375.50;










AUST_SHIP_INSURANCE_BASE = 2.60;
AUST_SHIP_INSURANCE_per100 = 1.15;
INTL_SHIP_INSURANCE_BASE = 5.50;
INTL_SHIP_INSURANCE_per100 = 2.00;

//---------------------------------------------------------------------||
// 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.value == null ) || ( thisForm.QUANTITY.value == "" ) || ( thisForm.QUANTITY.value == "NaN.aN" ))
strQUANTITY = "1";
else
strQUANTITY = thisForm.QUANTITY.value;


if ( thisForm.PRICE == null )
strPRICE = "0.00";
else
strPRICE = thisForm.PRICE.value;

if ( thisForm.NAME == null )
strNAME = "";
else
strNAME = thisForm.NAME.value;

if ( thisForm.WEIGHT == null ) //Added for UPS mod ||
strSHIPPING = "0";
else
strSHIPPING = thisForm.WEIGHT.value;

if ( thisForm.ADDITIONALINFO == null ) { strADDTLINFO = ""; } else { strADDTLINFO = thisForm.ADDITIONALINFO[thisForm.ADDITIONALINFO.selectedIndex].value; } if ( thisForm.ADDITIONALINFO2 != null ) { strADDTLINFO += "; " + thisForm.ADDITIONALINFO2[thisForm.ADDITIONALINFO2.selectedIndex].value; } if ( thisForm.ADDITIONALINFO3 != null ) { strADDTLINFO += "; " + thisForm.ADDITIONALINFO3[thisForm.ADDITIONALINFO3.selectedIndex].value; } if ( thisForm.ADDITIONALINFO4 != null ) { strADDTLINFO += "; " + thisForm.ADDITIONALINFO4[thisForm.ADDITIONALINFO4.selectedIndex].value; }
if ( thisForm.USERENTRY != null ) {
strADDTLINFO += "; " + thisForm.USERENTRY.value;
}
if ( thisForm.USERENTRY2 != null ) {
strADDTLINFO += "; " + thisForm.USERENTRY2.value;
}
if ( thisForm.USERENTRY3 != null ) {
strADDTLINFO += "; " + thisForm.USERENTRY3.value;
}
//Is this product already in the cart? If so, increment quantity instead of adding another.
for ( i = 1; i <= iNumberOrdered; i++ ) {
NewOrder = "Order." + i;
database = "";
database = GetCookie(NewOrder);

Token0 = database.indexOf("|", 0);
Token1 = database.indexOf("|", Token0+1);
Token2 = database.indexOf("|", Token1+1);
Token3 = database.indexOf("|", Token2+1);
Token4 = database.indexOf("|", Token3+1);

fields = new Array;
fields[0] = database.substring( 0, Token0 );
fields[1] = database.substring( Token0+1, Token1 );
fields[2] = database.substring( Token1+1, Token2 );
fields[3] = database.substring( Token2+1, Token3 );
fields[4] = database.substring( Token3+1, Token4 );
fields[5] = database.substring( Token4+1, database.length );

if ( fields[0] == strID_NUM &&
fields[2] == strPRICE &&
fields[3] == strNAME &&
fields[5] == strADDTLINFO
) {
bAlreadyInCart = true;
dbUpdatedOrder = strID_NUM + "|" +
(parseInt(strQUANTITY)+parseInt(fields[1])) + "|" +
strPRICE + "|" +
strNAME + "|" +
strSHIPPING + "|" +
strADDTLINFO;
strNewOrder = "Order." + i;
DeleteCookie(strNewOrder, "/");
SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
notice = strAdded + "\n-------------------------------------\n" + "Quantity : " + strQUANTITY + "\nProduct  : " + strNAME;
break;
}
}


if ( !bAlreadyInCart ) {
iNumberOrdered++;

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

strNewOrder = "Order." + iNumberOrdered;
SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
SetCookie("NumberOrdered", iNumberOrdered, null, "/");
notice = strAdded + "\n-------------------------------------\n" + "Quantity : " + strQUANTITY + "\nProduct  : " + strNAME;
}
}
if ( DisplayNotice && notice!=''){
alert(notice);
}else{
}

}


//---------------------------------------------------------------------||
// FUNCTION: getCookieVal ||
// PARAMETERS: offset ||
// RETURNS: URL unescaped Cookie Value ||
// PURPOSE: Get a specific value from a cookie ||
//---------------------------------------------------------------------||
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);

if ( endstr == -1 )
endstr = document.cookie.length;
return(unescape(document.cookie.substring(offset, endstr)));
}


//---------------------------------------------------------------------||
// FUNCTION: FixCookieDate ||
// PARAMETERS: date ||
// RETURNS: date ||
// PURPOSE: Fixes cookie date, stores back in date ||
//---------------------------------------------------------------------||
function FixCookieDate (date) {
var base = new Date(0);
var skew = base.getTime();

date.setTime (date.getTime() - skew);
}


//---------------------------------------------------------------------||
// FUNCTION: GetCookie ||
// PARAMETERS: Name ||
// RETURNS: Value in Cookie ||
// PURPOSE: Retrieves cookie from users browser ||
//---------------------------------------------------------------------||
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;

while ( i < clen ) {
var j = i + alen;
if ( document.cookie.substring(i, j) == arg ) return(getCookieVal (j));
i = document.cookie.indexOf(" ", i) + 1;
if ( i == 0 ) break;
}

return(null);
}


//---------------------------------------------------------------------||
// FUNCTION: SetCookie ||
// PARAMETERS: name, value, expiration date, path, domain, security ||
// RETURNS: Null ||
// PURPOSE: Stores a cookie in the users browser ||
//---------------------------------------------------------------------||
function SetCookie (name,value,expires,path,domain,secure) {
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}


//---------------------------------------------------------------------||
// FUNCTION: DeleteCookie ||
// PARAMETERS: Cookie name, path, domain ||
// RETURNS: null ||
// PURPOSE: Removes a cookie from users browser. ||
//---------------------------------------------------------------------||
function DeleteCookie (name,path,domain) {
if ( GetCookie(name) ) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}


//---------------------------------------------------------------------||
// FUNCTION: MoneyFormat ||
// PARAMETERS: Number to be formatted ||
// RETURNS: Formatted Number ||
// PURPOSE: Reformats Dollar Amount to #.## format ||
//---------------------------------------------------------------------||
function moneyFormat(input) {
var dollars = Math.floor(input);
var tmp = new String(input);

for ( var decimalAt = 0; decimalAt < tmp.length; decimalAt++ ) {
if ( tmp.charAt(decimalAt)=="." )
break;
}

var cents = "" + Math.round(input * 100);
cents = cents.substring(cents.length-2, cents.length)
dollars += ((tmp.charAt(decimalAt+2)=="9")&&(cents=="00"))? 1 : 0;

if ( cents == "0" )
cents = "00";


return(dollars + "." + cents);
}


//---------------------------------------------------------------------||
// FUNCTION: RemoveFromCart ||
// PARAMETERS: Order Number to Remove ||
// RETURNS: Null ||
// PURPOSE: Removes an item from a users shopping cart ||
//---------------------------------------------------------------------||
function RemoveFromCart(RemOrder) {
if ( confirm( strRemove ) ) {
NumberOrdered = GetCookie("NumberOrdered");
for ( i=RemOrder; i < NumberOrdered; i++ ) {
NewOrder1 = "Order." + (i+1);
NewOrder2 = "Order." + (i);
database = GetCookie(NewOrder1);
SetCookie (NewOrder2, database, null, "/");
}
NewOrder = "Order." + NumberOrdered;
SetCookie ("NumberOrdered", NumberOrdered-1, null, "/");
DeleteCookie(NewOrder, "/");
location.href=location.href;
}
}


//---------------------------------------------------------------------||
// FUNCTION: ChangeQuantity ||
// PARAMETERS: Order Number to Change Quantity ||
// RETURNS: Null ||
// PURPOSE: Changes quantity of an item in the shopping cart ||
//---------------------------------------------------------------------||
function ChangeQuantity(OrderItem,NewQuantity) {
if ( isNaN(NewQuantity) ) {
alert( strErrQty );
} else {
NewOrder = "Order." + OrderItem;
database = "";
database = GetCookie(NewOrder);

Token0 = database.indexOf("|", 0);
Token1 = database.indexOf("|", Token0+1);
Token2 = database.indexOf("|", Token1+1);
Token3 = database.indexOf("|", Token2+1);
Token4 = database.indexOf("|", Token3+1);

fields = new Array;
fields[0] = database.substring( 0, Token0 );
fields[1] = database.substring( Token0+1, Token1 );
fields[2] = database.substring( Token1+1, Token2 );
fields[3] = database.substring( Token2+1, Token3 );
fields[4] = database.substring( Token3+1, Token4 );
fields[5] = database.substring( Token4+1, database.length );

dbUpdatedOrder = fields[0] + "|" +
NewQuantity + "|" +
fields[2] + "|" +
fields[3] + "|" +
fields[4] + "|" +
fields[5];
strNewOrder = "Order." + OrderItem;
DeleteCookie(strNewOrder, "/");
SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
location.href=location.href;
}
}


//---------------------------------------------------------------------||
// FUNCTION: GetFromCart ||
// PARAMETERS: Null ||
// RETURNS: Product Table Written to Document ||
// PURPOSE: Draws current cart product table on HTML page ||
// **DEPRECATED FUNCTION, USE ManageCart or Checkout** ||
//---------------------------------------------------------------------||
function GetFromCart( fShipping ) {
ManageCart( );
}


//---------------------------------------------------------------------||
// FUNCTION:    RadioChecked                                           ||
// PARAMETERS:  Radio button to check                                  ||
// RETURNS:     True if a radio has been checked                       ||
// PURPOSE:     Form fillin validation                                 ||
//---------------------------------------------------------------------||
function RadioChecked( radiobutton ) {
   var bChecked = false;
   var rlen = radiobutton.length;
   for ( i=0; i < rlen; i++ ) {
      if ( radiobutton[i].checked )
         bChecked = true;
   }
   return bChecked;
}



//---------------------------------------------------------------------||
// FUNCTION: QueryString ||
// PARAMETERS: Key to read ||
// RETURNS: value of key ||
// PURPOSE: Read data passed in via GET mode ||
//---------------------------------------------------------------------||
QueryString.keys = new Array();
QueryString.values = new Array();
function QueryString(key) {

var value = null;

for (var i=0;i<QueryString.keys.length;i++) {

if (QueryString.keys[i]==key) {

value = QueryString.values[i];

break;
}
}
return value;
}

//---------------------------------------------------------------------||
// FUNCTION: QueryString_Parse ||
// PARAMETERS: (URL string) ||
// RETURNS: null ||
// PURPOSE: Parses query string data, must be called before Q.S. ||
//---------------------------------------------------------------------||
function QueryString_Parse() {

var query = window.location.search.substring(1);
var pairs = query.split("&");

for (var i=0;i>pairs.length;i++) {

	var pos = pairs[i].indexOf('=');

if (pos >= 0) {

var argname = pairs[i].substring(0,pos);

var value = pairs[i].substring(pos+1);
QueryString.keys[QueryString.keys.length] = argname;
QueryString.values[QueryString.values.length] = value;

}

}

}


//---------------------------------------------------------------------||
// FUNCTION: ManageCart ||
// PARAMETERS: Null ||
// RETURNS: Product Table Written to Document ||
// PURPOSE: Draws current cart product table on HTML page ||
// EXTRAS ADDED IN: Code to enable UPS mod. ||
//---------------------------------------------------------------------||

function ManageCart( ) {
var iNumberOrdered = 0; //Number of products ordered
var fTotal = 0; //Total cost of order
var fTax = 0; //Tax amount
var fWeight = 0; //Weight
var fShipping = 0; //Shipping amount
var strTotal = ""; //Total cost formatted as money
var strTax = ""; //Total tax formatted as money
var strShipping = ""; //Total shipping formatted as money
var strOutput = ""; //String to be written to page
var bDisplay = true; //Whether to write string to the page (here for programmers)

iNumberOrdered = GetCookie("NumberOrdered");

if ( iNumberOrdered == null )
iNumberOrdered = 0;


// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
strOutput += "<TABLE class=\"table\" CELLSPACING=0><TR class=\"row-header\">" +
	"<TH class=\"header-name\">"+strDLabel+"</TH>" + 	//name/description
	"<TH class=\"header-qty\">"+strQLabel+"</TH>" +  //quantity
	"<TH class=\"header-price\">"+strPLabel+"</TH>" +  //price
	"<TH class=\"header-ext\">"+strSLabel+"</TH>" +  //extended amount
	"<TH class=\"header-rmv\">"+strRLabel+"</TH></TR>";  //remove from cart

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// Message to show if cart is empty |
if ( iNumberOrdered == 0 ) {
strOutput += "<TR class=\"row-entry\"><TD COLSPAN=5>Your cart is empty</TD></TR>";
}

// Getting the data values |
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);



// - Writing lines of data to the table |

strOutput += "<TR class=\"row-entry\">";
if ( fields[5] == "" )
strOutput += "<TD class=\"cell-name\">" + fields[3] + "</TD>"; // write the product name |
else
strOutput += "<TD class=\"cell-name\">" + fields[3] + " - <I>"+ fields[5] + "</I></TD>"; // write the product name and description if avail |

// writing the quantity and change quantity fields |
strOutput += "<TD class=\"cell-qty\"><INPUT TYPE=\"text\" NAME=\"Q\" class=\"textbox-qty\" VALUE=\"" + fields[1] +"\" onChange=\"ChangeQuantity("+i+", this.value);\">"+ strSpace1 +"";
strOutput += "<INPUT CLASS=\"button-qty\" TYPE=\"button\" VALUE=\"Change\" onClick=\"ChangeQuantity("+i+", Q.value)\"></TD>";


// writing the price per item fields |
strOutput += "<TD class=\"cell-price\">"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea" +"</TD>";

// writing the extended price fields - ie number of items times the price per item |
strOutput += "<TD class=\"cell-ext\">"+ MonetarySymbol + moneyFormat(parseInt(fields[1]) * parseFloat(fields[2]) ) + "</TD>";

// adding the remove from cart button option to table field #5 |
strOutput += "<TD CLASS=\"cell-rmv\"><INPUT  CLASS=\"button-rmv\" NAME=Button_Remove TYPE=BUTTON VALUE=\"Remove\" onClick=\"RemoveFromCart("+i+")\"></TD></TR>";



// setting value of item number
strFooter = i;

// passing data values to an array for parsing later by the checkout function
ID[i] = OutputItemId + strFooter +  "=" + fields[0];
QUANTITY[i] = OutputItemQuantity + strFooter +  "=" + fields[1];
PRICE[i] = OutputItemPrice + strFooter +  "=" + fields[2];
NAME[i] = OutputItemName + strFooter +  "=" + fields[3];
WEIGHT[i] = OutputItemWeight + strFooter +  "=" + fields[4];
ADDTLINFO[i] = OutputItemAddtlInfo + strFooter +  "=" + fields[5];

} // from Get Data Values
// ----------------------------------------------

//passing the number of rows to the checkout so that the data table can be re-written on the checkout page
ROWS=i-1;

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// writing the sub-total
strOutput += "<TR class=\"row-totals\">" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD>" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD>" +
	"<TD CLASS=\"cell-totals-right\">" + strSUB + "</TD>" + //label
	"<TD CLASS=\"cell-totals-right\">" + MonetarySymbol + strTotal + "</TD>" + //subtotal value
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD></TR>";

// transfer the sub-Total to a variable for later use
SUB_TOTAL = strTotal;

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";


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

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";


// Writing the shipping info header and total shipped weight info ||
strOutput += "<TR class=\"row-shipping\">" +
	"<TD CLASS=\"cell-shipping-right\" COLSPAN=2>CALCULATE SHIPPING CHARGES" + strSpace + strSpace + "</TD>" +
	"<TD CLASS=\"cell-shipping\" COLSPAN=3>" + "Total Shipped Weight:" + strSpace + fWeight + "kgs" + "</TD>" //+
	//"<TD CLASS=\"cell-shipping\">" + strSpace + "</TD></TR>";

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// In preparation for selecting the destination shipping country, we do some setup
// Getting the country drop-down text box to retain the name of the selected country
// by reading the country cookie value to a temp variable "C"
CountrySelected = GetCookie("Country");
if (CountrySelected == null) {
	C = "Select Destination Country"
} else {
	C= CountrySelected
}

// Writing the country select box
strOutput += "<TR class=\"row-shipping\">";
strOutput += "<TD CLASS=\"cell-shipping-right\" COLSPAN=2>Select Destination country to ship to ->" + strSpace + "</TD>";
// Insert the CountrySelect box
strOutput += "<TD CLASS=\"cell-shipping\" COLSPAN=2>"

// assign dropbox results to variables -> ZONEand COUNTRY
// strOutput += "<select ID=SHIPPING_ZONE name=ZONE class=\"dropbox-country\" style=\"visibility: visible\" onChange=\"ZONE =this.value,COUNTRY=document.all.SHIPPING_ZONE.options[document.all.SHIPPING_ZONE.options.selectedIndex].text\">";
	strOutput += "<select ID=SHIPPING_ZONE name=ZONE class=\"dropbox-country\" style=\"visibility: visible\" onChange=\"StoreShipping(this.value,document.all.SHIPPING_ZONE.options[document.all.SHIPPING_ZONE.options.selectedIndex].text)\">";

// Write the Select Country drop-down box
strOutput += "<option value=\"\" SELECTED> "+ C +""; //temp variable to show the selected country value

strOutput += "<option value=\"0\"> AUSTRALIA";
strOutput += "<option value=\"A\"> NEW ZEALAND";
strOutput += "<option value=\"C\"> USA";
strOutput += "<option value=\"C\"> CANADA";
strOutput += "<option value=\"D\"> UNITED KINGDOM";
strOutput += "<option value=> -----------------";
strOutput += "<option value=\"C\"> Afghanistan";
strOutput += "<option value=\"D\"> Albania";
strOutput += "<option value=\"D\"> Algeria";
strOutput += "<option value=\"D\"> Angola";
strOutput += "<option value=\"D\"> Anguilla";
strOutput += "<option value=\"D\"> Antigua & Barbuda";
strOutput += "<option value=\"D\"> Argentina";
strOutput += "<option value=\"D\"> Armenia";
strOutput += "<option value=\"D\"> Ascention + St Helena";
strOutput += "<option value=\"D\"> AUSTRIA";
strOutput += "<option value=\"D\"> Azerbaijan";
strOutput += "<option value=\"D\"> Bahamas";
strOutput += "<option value=\"C\"> Bahrain";
strOutput += "<option value=\"B\"> Bangladesh";
strOutput += "<option value=\"D\"> Barbados";
strOutput += "<option value=\"D\"> Belarus";
strOutput += "<option value=\"D\"> Belgium";
strOutput += "<option value=\"D\"> Belize";
strOutput += "<option value=\"D\"> Benin";
strOutput += "<option value=\"D\"> Bermuda";
strOutput += "<option value=\"B\"> Bhutan";
strOutput += "<option value=\"D\"> Bolivia";
strOutput += "<option value=\"D\"> Bosnia-Herzegovina";
strOutput += "<option value=\"D\"> Botswana";
strOutput += "<option value=\"D\"> Brazil";
strOutput += "<option value=\"D\"> British Indian Ocean Terr";
strOutput += "<option value=\"B\"> Brunei Darussalam";
strOutput += "<option value=\"D\"> Bulgaria";
strOutput += "<option value=\"D\"> Burkina Faso";
strOutput += "<option value=\"D\"> Burundi";
strOutput += "<option value=\"B\"> Cambodia";
strOutput += "<option value=\"D\"> Cameroon";
strOutput += "<option value=\"C\"> CANADA";
strOutput += "<option value=\"D\"> Cape Verde";
strOutput += "<option value=\"B\"> Caroline Is.";
strOutput += "<option value=\"D\"> Cayman Is.";
strOutput += "<option value=\"D\"> Central African Rep.";
strOutput += "<option value=\"D\"> Chad";
strOutput += "<option value=\"D\"> Chile";
strOutput += "<option value=\"B\"> China";
strOutput += "<option value=\"D\"> Colombia";
strOutput += "<option value=\"C\"> Comoros";
strOutput += "<option value=\"D\"> Congo";
strOutput += "<option value=\"D\"> Congo, Dem Rep";
strOutput += "<option value=\"B\"> Cook Is.";
strOutput += "<option value=\"D\"> Costa Rica";
strOutput += "<option value=\"D\"> Cote d'Ivoire";
strOutput += "<option value=\"D\"> Croatia";
strOutput += "<option value=\"D\"> Cuba";
strOutput += "<option value=\"D\"> Cyprus";
strOutput += "<option value=\"D\"> CZECH REPUBLIC";
strOutput += "<option value=\"D\"> Denmark";
strOutput += "<option value=\"D\"> Djibouti";
strOutput += "<option value=\"D\"> Dominica";
strOutput += "<option value=\"D\"> Dominican Rep";
strOutput += "<option value=\"D\"> Ecuador";
strOutput += "<option value=\"B\"> East Timor";
strOutput += "<option value=\"D\"> Egypt";
strOutput += "<option value=\"D\"> El Salvador";
strOutput += "<option value=\"D\"> Equatorial Guinea";
strOutput += "<option value=\"D\"> Eritrea";
strOutput += "<option value=\"D\"> Estonia";
strOutput += "<option value=\"D\"> Ethiopia";
strOutput += "<option value=\"D\"> Falkland Is. (Malvinas)";
strOutput += "<option value=\"D\"> Faroe Is.";
strOutput += "<option value=\"B\"> FIJI";
strOutput += "<option value=\"D\"> Finland";
strOutput += "<option value=\"D\"> France";
strOutput += "<option value=\"D\"> French Guiana";
strOutput += "<option value=\"B\"> French Polynesia";
strOutput += "<option value=\"D\"> Gabon";
strOutput += "<option value=\"D\"> Gambia";
strOutput += "<option value=\"D\"> Georgia";
strOutput += "<option value=\"D\"> GERMANY";
strOutput += "<option value=\"D\"> Ghana";
strOutput += "<option value=\"D\"> Gibraltar";
strOutput += "<option value=\"D\"> GREECE";
strOutput += "<option value=\"D\"> Greenland";
strOutput += "<option value=\"D\"> Grenada";
strOutput += "<option value=\"D\"> Guadaloupe";
strOutput += "<option value=\"B\"> Guam";
strOutput += "<option value=\"D\"> Guatemala";
strOutput += "<option value=\"D\"> Guinea";
strOutput += "<option value=\"D\"> Guinea-Bissau";
strOutput += "<option value=\"D\"> Guyana";
strOutput += "<option value=\"D\"> Haiti";
strOutput += "<option value=\"C\"> Hawaii";
strOutput += "<option value=\"D\"> Honduras";
strOutput += "<option value=\"B\"> HONG KONG, CHINA";
strOutput += "<option value=\"D\"> Hungary";
strOutput += "<option value=\"D\"> Iceland";
strOutput += "<option value=\"C\"> INDIA";
strOutput += "<option value=\"C\"> INDONESIA";
strOutput += "<option value=\"C\"> Iran";
strOutput += "<option value=\"C\"> Iraq";
strOutput += "<option value=\"D\"> IRELAND";
strOutput += "<option value=\"C\"> ISRAEL";
strOutput += "<option value=\"D\"> ITALY";
strOutput += "<option value=\"D\"> Jamaica";
strOutput += "<option value=\"B\"> JAPAN";
strOutput += "<option value=\"C\"> Jordan";
strOutput += "<option value=\"D\"> Kazakhstan";
strOutput += "<option value=\"D\"> Kenya";
strOutput += "<option value=\"B\"> Kiribati";
strOutput += "<option value=\"B\"> Korea, Rep. of North";
strOutput += "<option value=\"B\"> Korea, Rep. of South";
strOutput += "<option value=\"C\"> Kuwait";
strOutput += "<option value=\"D\"> Kyrgyzstan";
strOutput += "<option value=\"B\"> Lao Peoples Rep";
strOutput += "<option value=\"D\"> Latvia";
strOutput += "<option value=\"C\"> Lebanon";
strOutput += "<option value=\"D\"> Lesotho";
strOutput += "<option value=\"D\"> Liberia";
strOutput += "<option value=\"D\"> Libyan Arab Jamahiriya";
strOutput += "<option value=\"D\"> Liechtenstein";
strOutput += "<option value=\"D\"> Lithuania";
strOutput += "<option value=\"D\"> Luxembourg";
strOutput += "<option value=\"B\"> Macao, China";
strOutput += "<option value=\"D\"> Macedonia";
strOutput += "<option value=\"C\"> Madagascar";
strOutput += "<option value=\"D\"> Malawi";
strOutput += "<option value=\"B\"> MALAYSIA";
strOutput += "<option value=\"B\"> Maldives";
strOutput += "<option value=\"D\"> Mali";
strOutput += "<option value=\"D\"> Malta";
strOutput += "<option value=\"B\"> Mariana Is.";
strOutput += "<option value=\"B\"> Marshall Islands";
strOutput += "<option value=\"D\"> Martinique";
strOutput += "<option value=\"D\"> Mauritania";
strOutput += "<option value=\"C\"> Mauritius";
strOutput += "<option value=\"C\"> Mexico";
strOutput += "<option value=\"B\"> Micronesia, Fed. States of";
strOutput += "<option value=\"D\"> Moldova";
strOutput += "<option value=\"D\"> Monaco";
strOutput += "<option value=\"D\"> Mongolia";
strOutput += "<option value=\"D\"> Montserrat";
strOutput += "<option value=\"D\"> Morocco";
strOutput += "<option value=\"D\"> Mozambique";
strOutput += "<option value=\"B\"> Myanmar";
strOutput += "<option value=\"D\"> Namibia";
strOutput += "<option value=\"B\"> Nauru";
strOutput += "<option value=\"B\"> Nepal";
strOutput += "<option value=\"D\"> NETHERLANDS";
strOutput += "<option value=\"D\"> Netherlands Antilles & Aruba";
strOutput += "<option value=\"B\"> New Caledonia";
strOutput += "<option value=\"A\"> NEW ZEALAND";
strOutput += "<option value=\"D\"> Nicaragua";
strOutput += "<option value=\"D\"> Niger";
strOutput += "<option value=\"D\"> Nigeria";
strOutput += "<option value=\"B\"> Niue (New Zealand)";
strOutput += "<option value=\"0\"> Norfolk Is.";
strOutput += "<option value=\"D\"> Norway";
strOutput += "<option value=\"C\"> Oman";
strOutput += "<option value=\"B\"> Pakistan";
strOutput += "<option value=\"B\"> Palau";
strOutput += "<option value=\"D\"> Panama";
strOutput += "<option value=\"B\"> PAPUA NEW GUINEA";
strOutput += "<option value=\"D\"> Paraguay";
strOutput += "<option value=\"D\"> Peru";
strOutput += "<option value=\"B\"> PHILIPPINES";
strOutput += "<option value=\"B\"> Pitcairn Is.";
strOutput += "<option value=\"D\"> Poland";
strOutput += "<option value=\"D\"> PORTUGAL";
strOutput += "<option value=\"D\"> Puerto Rico";
strOutput += "<option value=\"C\"> Qatar";
strOutput += "<option value=\"C\"> Reunion";
strOutput += "<option value=\"D\"> Romania";
strOutput += "<option value=\"D\"> Russia";
strOutput += "<option value=\"D\"> Rwanda";
strOutput += "<option value=\"D\"> St. Christopher & Nevis";
strOutput += "<option value=\"D\"> St. Lucia";
strOutput += "<option value=\"C\"> St. Pierre & Miquelon";
strOutput += "<option value=\"D\"> St. Vincent & the Grenadines";
strOutput += "<option value=\"B\"> Samoa, American";
strOutput += "<option value=\"B\"> Samoa";
strOutput += "<option value=\"D\"> Sao Tome & Principe";
strOutput += "<option value=\"C\"> Saudi Arabia";
strOutput += "<option value=\"D\"> Senegal";
strOutput += "<option value=\"D\"> Serbia & Montenegro";
strOutput += "<option value=\"D\"> Seychelles";
strOutput += "<option value=\"D\"> Sierra Leone";
strOutput += "<option value=\"B\"> SINGAPORE";
strOutput += "<option value=\"D\"> Slovakia";
strOutput += "<option value=\"D\"> Slovenia";
strOutput += "<option value=\"B\"> Solomon Is.";
strOutput += "<option value=\"D\"> Somalia";
strOutput += "<option value=\"D\"> SOUTH AFRICA";
strOutput += "<option value=\"D\"> Spain";
strOutput += "<option value=\"B\"> Sri Lanka";
strOutput += "<option value=\"D\"> Sudan";
strOutput += "<option value=\"D\"> Suriname";
strOutput += "<option value=\"D\"> Swaziland";
strOutput += "<option value=\"D\"> Sweden";
strOutput += "<option value=\"D\"> SWITZERLAND";
strOutput += "<option value=\"C\"> Syria";
strOutput += "<option value=\"B\"> Taiwan";
strOutput += "<option value=\"D\"> Tajikistan";
strOutput += "<option value=\"D\"> Tanzania";
strOutput += "<option value=\"B\"> Thailand";
strOutput += "<option value=\"D\"> Togo";
strOutput += "<option value=\"B\"> Tokelau Is. (New Zealand)";
strOutput += "<option value=\"B\"> Tonga";
strOutput += "<option value=\"D\"> Trinidad & Tobago";
strOutput += "<option value=\"D\"> Tristan Da Cunha";
strOutput += "<option value=\"D\"> Tunisia";
strOutput += "<option value=\"D\"> Turkey";
strOutput += "<option value=\"D\"> Turkmenistan";
strOutput += "<option value=\"D\"> Turks & Caicos Is.";
strOutput += "<option value=\"B\"> Tuvalu";
strOutput += "<option value=\"D\"> Uganda";
strOutput += "<option value=\"D\"> Ukraine";
strOutput += "<option value=\"C\"> United Arab Emirates";
strOutput += "<option value=\"D\"> UNITED KINGDOM";
strOutput += "<option value=\"D\"> Uruguay";
strOutput += "<option value=\"C\"> USA";
strOutput += "<option value=\"D\"> Uzbekistan";
strOutput += "<option value=\"B\"> Vanuatu";
strOutput += "<option value=\"D\"> Vatican City State";
strOutput += "<option value=\"D\"> Venezuela";
strOutput += "<option value=\"B\"> VIETNAM";
strOutput += "<option value=\"D\"> Virgin Is. (British)";
strOutput += "<option value=\"D\"> Virgin Is. (USA)";
strOutput += "<option value=\"B\"> Wallis & Futuna Is.";
strOutput += "<option value=\"C\"> Yemen Republic";
strOutput += "<option value=\"D\"> Zambia";
strOutput += "<option value=\"D\"> Zimbabwe";
strOutput += "</select>";

strOutput += "</TD>";
strOutput += "<TD CLASS=\"cell-shipping\">" + strSpace + "</TD></TR>";

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";


// // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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


// retrieve the stored zone and country values from cookies
ZONE = GetCookie("Zone");
COUNTRY = GetCookie("Country");


//now, the sections that collect info regarding country options - shipping method, insurance etc.



// ####################################
// AUSTRALIA

if (ZONE == "0") {

//------This section for Australia ONLY
// see if a postcode has already been recorded
code = GetCookie("PostCode");
if (code == null) {
	code = ""
}

//-------------------------------------

// write the postcode request box for Australian Shipping
strOutput += "<TR class=\"row-shipping\">" +
	"<TD CLASS=\"cell-shipping-right\" COLSPAN=2>Type your Postcode and Press 'ENTER' ->" + strSpace + "</TD>";
strOutput += "<TD CLASS=\"cell-shipping\" COLSPAN=2>";
strOutput += "<INPUT TYPE=\"TEXT\" ID=\"PostCode\" NAME=\"PostCode\" class=\"textbox-postcode\" MINLENGTH=4 MAXLENGTH=4 VALUE="+ code +">";
strOutput += ""+ strSpace2 +"";
strOutput += "<INPUT TYPE=\"BUTTON\" ID=\"Button_Go\" NAME=\"Button_Go\" class=\"button-go\" VALUE=\"ENTER\" onClick=GetAustZone(PostCode.value)>"
strOutput += "</TD>";
strOutput += "<TD CLASS=\"cell-shipping\">" + strSpace + "</TD></TR>";


//-------------------------------------

//
//now select if insurance is required??

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// write a request if insurance is required
strOutput += "<TR class=\"row-shipping\">";
strOutput += "<TD CLASS=\"cell-shipping-right\" COLSPAN=2>Select Insurance Option (YES or NO) ->" + strSpace + "</TD>";

// see if an insurance request has already been recorded-------------
I = GetCookie("Insurance"); //temp variable for insurance request info

if (I == null) {
	IM = "Select insurance option" //temp variable
} else {
	IM = I
}
if (IM == "YES") {
	IM = "YES, please insure!" //display the label
}
if (IM == "NO") {
	IM = "NO, don't bother" //display label
}

// -------------
strOutput += "<TD CLASS=\"cell-shipping\" COLSPAN=2>"
strOutput += "<select ID=INSURANCEOPTION name=INSURANCE class=\"dropbox-insurance\" onChange=\"GetInsurance(this.value)\">";
strOutput += "<option value=\"\"> "+ IM +"";
strOutput += "<option value=\"YES\"> YES, please insure!";
strOutput += "<option value=\"NO\"> NO, don't bother";
strOutput += "</select></TD>";
strOutput += "<TD CLASS=\"cell-shipping\">" + strSpace + "</TD></TR>";

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";
// -------------


//computing the shipping charges
fShipping = ComputeShipping(fWeight);
//fShipping = 0; //FREE SHIPPING OPTION

// assigning a numeric value to an uncalculated shipping amount
if (fShipping==undefined) {
	fShipping=0
}

//------------------------------------------------------
//computing the insurance charges

Insurance = GetCookie("Insurance");
if (Insurance == "YES") {
	strInsurance = "INSURED";
	//calculating the insurance amount
	fInsAmount=(AUST_SHIP_INSURANCE_BASE+(Math.ceil(fTotal/100)*AUST_SHIP_INSURANCE_per100)-AUST_SHIP_INSURANCE_per100);  // registered postage charge includes $100 insurance ... hence subtracting $1.something at end
	}


if (Insurance == "NO") {
	strInsurance = "NOT INSURED";
	//set insurance amount to zero
	fInsAmount = 0;
	}
if (Insurance == null) {
	strInsurance = "NOT INSURED";
	//set insurance amount to zero
	fInsAmount = 0;
	}

//THIS MODULE WRITES THE TOTALS AND FINALISES SHOPPING CART
//------------------------------------------------------

//Adding a default value for the shipping method output string since this section does not allow the choice of one at this time
strShipping = "Standard Parcel Service";

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// writing the shipping summary line
strOutput += "<TR CLASS=\"row-entry-black\">";
strOutput += "<TD CLASS=\"cell-shipping\" COLSPAN=5>" + strSpace + strSpace + "Sending "+ fWeight +"kgs to " + CountrySelected +" by " + "<u>" + strShipping_Oz_1 + "</u>" + " | " + strShipping + " | " + strInsurance + "</TD>";

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

//output the shipping charge
strOutput += "<TR class=\"row-totals\">" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD>" +
	"<TD CLASS=\"cell-totals-right\" COLSPAN=2 >SHIPPING CHARGE:</TD>" +
	"<TD CLASS=\"cell-totals-right\">" + MonetarySymbol + moneyFormat((fShipping)) + "</TD>" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD></TR>";

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// output the insurance charge
strOutput += "<TR class=\"row-totals\">" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD>" +
	"<TD CLASS=\"cell-totals-right\" COLSPAN=2 >INSURANCE CHARGE:</TD>" +
	"<TD CLASS=\"cell-totals-right\">" + MonetarySymbol + moneyFormat((fInsAmount)) + "</TD>" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD></TR>";

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";


// output the total charge estimate prior to confirmation at check-out
strOutput += "<TR class=\"row-totals-gray\">" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD>" +
	"<TD CLASS=\"cell-totals-right\" COLSPAN=2 >TOTAL:</TD>" +
	"<TD CLASS=\"cell-totals-right\">" + MonetarySymbol + moneyFormat((fTotal + fShipping + fInsAmount)) + "</TD>" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD></TR>";

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";



//
strOutput += "</TABLE>";
//
//END OF TOTALS MODULE
//------------------------------------------------------


} //CLOSE BRACKET FOR AUSTRALIA SECTION
// ####################################


// ####################################
// INTERNATIONAL

if (ZONE != "0") {

// Writing the shipping method box
strOutput += "<TR class=\"row-shipping\">";
strOutput += "<TD CLASS=\"cell-shipping-right\" COLSPAN=2>Select shipping method ->" + strSpace + "</TD>";
// Insert the CountrySelect box
strOutput += "<TD CLASS=\"cell-shipping\" COLSPAN=3>"

//

	// see if a shipping method has already been selected--------------
	S = GetCookie("ShippingMethod"); //store any previous shipping method in a temp variable
	if (S == null) {
		SM = "Select Shipping Method"  //temp variable
		} else {
	SM = S
		}
	if (SM == "Airmail") {
		SM = "Airmail - up to 10 days" // getting the text box to read the label value instead of the variable value
		}
	 if (SM == "EPI") {
		SM = "Express Post - up to 7 days" // getting the text box to read the label value instead of the variable value
		}
	 if (SM == "ECI") {
		SM = "Express Courier - up to 4 days" // getting the text box to read the label value instead of the variable value
		}
// ------------


strOutput += "<select ID=\"SHIPPINGMETHOD\" name=\"SHIPMETHOD\" class=\"dropbox-shipping\" style=\"visibility: visible\" onChange=\"GetShippingMethod(this.value)\">";
//strOutput += "<option value=\"Airmail\"> FREE SHIPPING";  //FREE SHIPPING OPTION
strOutput += "<option value=\"\"> "+ SM +"";  //show the text contained in the temp variable
strOutput += "<option value=\"Airmail\"> Airmail - up to 10 days";
strOutput += "<option value=\"EPI\"> Express Post - up to 7 days";
strOutput += "<option value=\"ECI\"> Express Courier - up to 4 days";
strOutput += "</select>";
strOutput += "</TD>";
strOutput += "</TR>";
//


//now select if insurance is required??

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// write a request if insurance is required
strOutput += "<TR class=\"row-shipping\">";
strOutput += "<TD CLASS=\"cell-shipping-right\" COLSPAN=2>Select Insurance Option (YES or NO) ->" + strSpace + "</TD>";

// see if an insurance request has already been recorded-------------
I = GetCookie("Insurance"); //temp variable for insurance request info

if (I == null) {
	IM = "Select insurance option" //temp variable
} else {
	IM = I
}
if (IM == "YES") {
	IM = "YES, please insure!" //display the label
}
if (IM == "NO") {
	IM = "NO, don't bother" //display label
}

// -------------
strOutput += "<TD CLASS=\"cell-shipping\" COLSPAN=2>"
strOutput += "<select ID=INSURANCEOPTION name=INSURANCE class=\"dropbox-insurance\" style=\"visibility: visible\" onChange=\"GetInsurance(this.value)\">";
strOutput += "<option value=\"\"> "+ IM +"";
strOutput += "<option value=\"YES\"> YES, please insure!";
strOutput += "<option value=\"NO\"> NO, don't bother";
strOutput += "</select></TD>";
strOutput += "<TD CLASS=\"cell-shipping\">" + strSpace + "</TD></TR>";

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";
// -------------


ShippingMethod = GetCookie("ShippingMethod");
if (ShippingMethod == "Airmail") strShipping = "AirMail";
if (ShippingMethod == "EPI") strShipping = "Express Post International";
if (ShippingMethod == "ECI") strShipping = "Express Courier International";
if (ShippingMethod == null) strShipping = "AirMail";
if (ShippingMethod == 0) strShipping = "AirMail";


//------------------------------------------------------
//computing the shipping charges
fShipping = ComputeShipping(fWeight);
//fShipping = 0; //FREE SHIPPING OPTION

// assigning a numeric value to an uncalculated shipping amount
if (fShipping==undefined) {
	fShipping=0
}
//
//------------------------------------------------------
//computing the insurance charges

Insurance = GetCookie("Insurance");
if (Insurance == "YES") {
	strInsurance = "INSURED";
	//calculating the insurance amount
	fInsAmount=(INTL_SHIP_INSURANCE_BASE+(Math.ceil(fTotal/100)*INTL_SHIP_INSURANCE_per100));
	}

if (Insurance == "NO") {
	strInsurance = "NOT INSURED";
	//set insurance amount to zero
	fInsAmount = 0;
	}
if (Insurance == null) {
	strInsurance = "NOT INSURED";
	//set insurance amount to zero
	fInsAmount = 0;
	}

//
//THIS MODULE WRITES THE TOTALS AND FINALISES SHOPPING CART
//------------------------------------------------------
// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// writing the shipping summary line
strOutput += "<TR CLASS=\"row-entry-black\">";
strOutput += "<TD CLASS=\"cell-shipping\" COLSPAN=5>" + strSpace + strSpace + "Sending "+ fWeight +"kgs to " + CountrySelected +" by " + "<u>" + strShipping_Oz_1 + "</u>" + " | " + strShipping + " | " + strInsurance + "</TD>";

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

//output the shipping charge
strOutput += "<TR class=\"row-totals\">" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD>" +
	"<TD CLASS=\"cell-totals-right\" COLSPAN=2 >SHIPPING CHARGE:</TD>" +
	"<TD CLASS=\"cell-totals-right\">" + MonetarySymbol + moneyFormat((fShipping)) + "</TD>" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD></TR>";

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// output the insurance charge
strOutput += "<TR class=\"row-totals\">" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD>" +
	"<TD CLASS=\"cell-totals-right\" COLSPAN=2 >INSURANCE CHARGE:</TD>" +
	"<TD CLASS=\"cell-totals-right\">" + MonetarySymbol + moneyFormat((fInsAmount)) + "</TD>" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD></TR>";

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";


// output the total charge estimate prior to confirmation at check-out
strOutput += "<TR class=\"row-totals-gray\">" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD>" +
	"<TD CLASS=\"cell-totals-right\" COLSPAN=2 >TOTAL:</TD>" +
	"<TD CLASS=\"cell-totals-right\">" + MonetarySymbol + moneyFormat((fTotal + fShipping + fInsAmount)) + "</TD>" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD></TR>";

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";



//
strOutput += "</TABLE>";
//
//END OF TOTALS MODULE
//------------------------------------------------------


} //CLOSE BRACKET FOR INTERNATIONAL SECTION
// ####################################




//sending out the transaction values to complete the checkout page
COUNTRY_SELECTED = COUNTRY;
SHIPPING_METHOD = ShippingMethod;

//adding a default shipping method for Australian domestic shipping
if (COUNTRY_SELECTED == "AUSTRALIA") {
	SHIPPING_METHOD = "Australia Post";
	}

TOTAL_WEIGHT = fWeight;
SHIPPING_CHARGE = fShipping;
INSURANCE_CHARGE = fInsAmount;



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









//=====================================================================||
// CALCULATION CODE MODULES BELOW HERE ||
//=====================================================================||









//---------------------------------------------------------------------||
// FUNCTION: SetShippingCookies ||
// PARAMETERS: ||
// RETURNS: ||
// PURPOSE: Store zone and country values in cookies for later use ||
//---------------------------------------------------------------------||

function StoreShipping(ZONE,COUNTRY) {
// this function takes the selection from the Shipping Country drop-box and stores the
// zone and country values in cookies - Zone and Country

SetCookie("Zone", ZONE, null, "/");
location.href=location.href;
SetCookie("Country", COUNTRY, null, "/");
location.href=location.href;
}


//---------------------------------------------------------------------||
// FUNCTION: GetAustZone ||
// PARAMETERS: ||
// RETURNS: ||
// PURPOSE: Return Australian shipping zone from postcode ||
//---------------------------------------------------------------------||
 function GetAustZone(PostCode) {

 if (PostCode == "") alert( "Please enter a postcode to calculate Australian shipping." );
 if (PostCode != "") {
 	AustPostZone = CalculateZone(PostCode);

//  			// store postcode for form validation later
//  			SetCookie("PostCode", PostCode, null, "/");
//  			location.href=location.href;

 			// store Australian post zone
 			SetCookie("AustPostZone", AustPostZone, null, "/");
 			location.href=location.href;
 			return;

 	}

}


//---------------------------------------------------------------------||
// FUNCTION: CalculateZone ||
// PARAMETERS: ||
// RETURNS: ||
// PURPOSE: actually works out the zone ||
//---------------------------------------------------------------------||
function CalculateZone(PostCode) {

	SetCookie("PostCode", PostCode, null, "/");
	location.href=location.href;


//determining Australian shipping zones & charges according to postcode
//NSW
if ((PostCode >= 0200) && (PostCode <= 0299)) return "N2";
if ((PostCode >= 1000) && (PostCode <= 2263)) return "N1";
if ((PostCode >= 2264) && (PostCode <= 2484)) return "N2";
if ((PostCode >= 2485) && (PostCode <= 2486)) return "Q1";
if ((PostCode >= 2487) && (PostCode <= 2499)) return "N2";
if ((PostCode >= 2500) && (PostCode <= 2530)) return "N1";
if ((PostCode >= 2531) && (PostCode <= 2554)) return "N2";
if ((PostCode >= 2555) && (PostCode <= 2574)) return "N1";
if ((PostCode >= 2575) && (PostCode <= 2647)) return "N2";
if (PostCode == 2648) return "V2";
if ((PostCode >= 2649) && (PostCode <= 2714)) return "N2";
if (PostCode == 2715) return "V2";
if (PostCode == 2716) return "N2";
if ((PostCode >= 2717) && (PostCode <= 2719)) return "V2";
if ((PostCode >= 2720) && (PostCode <= 2730)) return "N2";
if ((PostCode >= 2731) && (PostCode <= 2739)) return "V2";
if ((PostCode >= 2740) && (PostCode <= 2786)) return "N1";
if ((PostCode >= 2787) && (PostCode <= 2879)) return "N2";
if (PostCode == 2880) return "S2";
if ((PostCode >= 2881) && (PostCode <= 2889)) return "N2";
if (PostCode == 2890) return "N1";
if ((PostCode >= 2891) && (PostCode <= 2898)) return "N2";
if (PostCode == 2899) return "NF";
if ((PostCode >= 2900) && (PostCode <= 2999)) return "N2";
//VIC
if ((PostCode >= 3000) && (PostCode <= 3220)) return "V1";
if ((PostCode >= 3221) && (PostCode <= 3334)) return "V2";
if ((PostCode >= 3335) && (PostCode <= 3341)) return "V1";
if ((PostCode >= 3342) && (PostCode <= 3424)) return "V2";
if ((PostCode >= 3425) && (PostCode <= 3443)) return "V1";
if ((PostCode >= 3444) && (PostCode <= 3688)) return "V2";
if ((PostCode >= 3689) && (PostCode <= 3690)) return "N2";
if ((PostCode >= 3691) && (PostCode <= 3749)) return "V2";
if ((PostCode >= 3750) && (PostCode <= 3811)) return "V1";
if ((PostCode >= 3812) && (PostCode <= 3909)) return "V2";
if ((PostCode >= 3910) && (PostCode <= 3920)) return "V1";
if ((PostCode >= 3921) && (PostCode <= 3925)) return "V2";
if ((PostCode >= 3926) && (PostCode <= 3944)) return "V1";
if ((PostCode >= 3945) && (PostCode <= 3971)) return "V2";
if ((PostCode >= 3972) && (PostCode <= 3978)) return "V1";
if (PostCode == 3979) return "V2";
if ((PostCode >= 3980) && (PostCode <= 3983)) return "V1";
if ((PostCode >= 3984) && (PostCode <= 3999)) return "V2";
if ((PostCode >= 8000) && (PostCode <= 8999)) return "V1";
//QLD
if ((PostCode >= 4000) && (PostCode <= 4299)) return "Q1";
if ((PostCode >= 4300) && (PostCode <= 4449)) return "Q2";
if ((PostCode >= 4450) && (PostCode <= 4499)) return "Q3";
if ((PostCode >= 4500) && (PostCode <= 4549)) return "Q1";
if ((PostCode >= 4550) && (PostCode <= 4699)) return "Q2";
if ((PostCode >= 4700) && (PostCode <= 4805)) return "Q3";
if ((PostCode >= 4806) && (PostCode <= 4899)) return "Q4";
if ((PostCode >= 9000) && (PostCode <= 9299)) return "Q1";
if ((PostCode >= 9400) && (PostCode <= 9596)) return "Q1";
if ((PostCode >= 9597) && (PostCode <= 9599)) return "Q2";
if ((PostCode >= 9700) && (PostCode <= 9799)) return "Q1";
if ((PostCode >= 9880) && (PostCode <= 9919)) return "Q2";
if ((PostCode >= 9920) && (PostCode <= 9959)) return "Q3";
if ((PostCode >= 9960) && (PostCode <= 9999)) return "Q4";
//SA
if ((PostCode >= 5000) && (PostCode <= 5199)) return "S1";
if ((PostCode >= 5200) && (PostCode <= 5749)) return "S2";
if ((PostCode >= 5800) && (PostCode <= 5999)) return "S1";
//NT
if ((PostCode >= 0800) && (PostCode <= 0999)) return "NT1";
//WA
if ((PostCode >= 6000) && (PostCode <= 6205)) return "W1";
if ((PostCode >= 6206) && (PostCode <= 6699)) return "W2";
if ((PostCode >= 6700) && (PostCode <= 6799)) return "W3";
if ((PostCode >= 6800) && (PostCode <= 6999)) return "W1";
//TAS
if ((PostCode >= 7000) && (PostCode <= 7999)) return "T1";

//last resort
alert( "Please enter a valid postcode." );

}


//---------------------------------------------------------------------||
// FUNCTION: GetShippingMethod ||
// PARAMETERS: ||
// RETURNS: ||
// PURPOSE: Get method to be shipped by ||
//---------------------------------------------------------------------||
function GetShippingMethod(ShippingMethod) {

SetCookie("ShippingMethod", ShippingMethod, null, "/");
location.href=location.href;
}


//---------------------------------------------------------------------||
// FUNCTION: GetInsurance ||
// PARAMETERS: ||
// RETURNS: ||
// PURPOSE: Insurance?? ||
//---------------------------------------------------------------------||
function GetInsurance(Insurance) {

SetCookie("Insurance", Insurance, null, "/");
location.href=location.href;
}




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

// Get storred values from cookies
COUNTRY = GetCookie("Country");
Insurance = GetCookie("Insurance");
ShippingMethod = GetCookie("ShippingMethod");

if (TotWeight == 0) ShippingCharge = 0.00;

// Message regarding maximum Aust Post weight restriction
if (TotWeight > 20.00) {
	alert("Maximum shipping weight is 20kg. Please break your total order down to multiple shipments.");
	return;
}


//----------------------------------------------
// AUSTRALIA --
if (ZONE == "0" ) {
AustPostZone = GetCookie("AustPostZone");

	if (TotWeight == 0) return 0;
	if ((TotWeight >= 0.001) && (TotWeight <= 0.250)) return AUST_SHIP[AustPostZone + "_base"];
	if ((TotWeight > 0.250) && (TotWeight <= 0.500)) return AUST_SHIP[AustPostZone + "_1"];
	if ((TotWeight > 0.500) && (TotWeight <= 1.0)) return AUST_SHIP[AustPostZone + "_2"];

	if (TotWeight > 1.00) {
		fCost = (((Math.ceil(TotWeight - 1))*AUST_SHIP[AustPostZone + "_x"])+AUST_SHIP[AustPostZone + "_2"]);
		return fCost;
	}
} // Close bracket for AUSTRALIA

//----------------------------------------------
// INTERNATIONAL --
if (ZONE != "0" ) {


if (ShippingMethod == "Airmail") {
	if (TotWeight <= 0.25) return INTL_AIR_SHIP[ZONE + "_base"];

	if ((TotWeight > 0.25) && (TotWeight <= 2.00)) {
		fCost = (((Math.ceil((TotWeight - 0.25)/0.25))*INTL_AIR_SHIP[ZONE + "_x1"])+INTL_AIR_SHIP[ZONE + "_base"]);
		return fCost;
	}

	if (TotWeight > 2.00) {
		fCost = (((Math.ceil((TotWeight - 2)/0.5))*INTL_AIR_SHIP[ZONE + "_x2"])+ INTL_AIR_SHIP[ZONE + "_base"] + 7*INTL_AIR_SHIP[ZONE + "_x1"]);
		return fCost;
	}
} // End bracket Airmail

if (ShippingMethod == "EPI") {
	if (TotWeight <= 2.00) return INTL_EPI_SHIP[ZONE + "_base"];

	if (TotWeight > 2.00) {
		fCost = (((Math.ceil((TotWeight - 2)/0.5))*INTL_EPI_SHIP[ZONE + "_x"])+ INTL_EPI_SHIP[ZONE + "_base"]);
		return fCost;
	}
} // End bracket EPIl

if (ShippingMethod == "ECI") {
	if (TotWeight <= 0.5) return INTL_ECI_SHIP[ZONE + "_upto_.5"];
	if ((TotWeight > 0.5) && (TotWeight <= 1.0)) return INTL_ECI_SHIP[ZONE + "_upto_1"];
	if ((TotWeight > 1.0) && (TotWeight <= 2.0)) return INTL_ECI_SHIP[ZONE + "_upto_2"];
	if ((TotWeight > 2.0) && (TotWeight <= 3.0)) return INTL_ECI_SHIP[ZONE + "_upto_3"];
	if ((TotWeight > 3.0) && (TotWeight <= 5.0)) return INTL_ECI_SHIP[ZONE + "_upto_5"];
	if ((TotWeight > 5.0) && (TotWeight <= 7.5)) return INTL_ECI_SHIP[ZONE + "_upto_7.5"];
	if ((TotWeight > 7.5) && (TotWeight <= 10.0)) return INTL_ECI_SHIP[ZONE + "_upto_10"];
	if ((TotWeight > 10.0) && (TotWeight <= 12.5)) return INTL_ECI_SHIP[ZONE + "_upto_12.5"];
	if ((TotWeight > 12.5) && (TotWeight <= 15.0)) return INTL_ECI_SHIP[ZONE + "_upto_15"];
	if ((TotWeight > 15.0) && (TotWeight <= 17.5)) return INTL_ECI_SHIP[ZONE + "_upto_17.5"];
	if ((TotWeight > 17.5) && (TotWeight <= 20.0)) return INTL_ECI_SHIP[ZONE + "_upto_20"];
} // End bracket ECIl


} // Close bracket for INTERNATIONAL

} // Close bracket for ComputeShipping()



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

// Get storred values from cookies
COUNTRY = GetCookie("Country");
Insurance = GetCookie("Insurance");


if (TotWeight == 0) ShippingCharge = 0.00;
if (ZONE  == "") ZONE = "0";

// Message regarding maximum Aust Post weight restriction
if (TotWeight > 20.00) {
	alert("Maximum shipping weight is 20kg. Please break your total order down to multiple shipments.");
	return;
}


//----------------------------------------------
// AUSTRALIA --
if (ZONE == "0" ) {
AustPostZone = "V1";

	if (TotWeight == 0) return moneyFormat(0);
	if ((TotWeight >= 0.001) && (TotWeight <= 0.250)) return moneyFormat(AUST_SHIP[AustPostZone + "_base"]);
	if ((TotWeight > 0.250) && (TotWeight <= 0.500)) return moneyFormat(AUST_SHIP[AustPostZone + "_1"]);
	if ((TotWeight > 0.500) && (TotWeight <= 1.0)) return moneyFormat(AUST_SHIP[AustPostZone + "_2"]);

	if (TotWeight > 1.00) {
		fCost = (((Math.ceil(TotWeight - 1))*AUST_SHIP[AustPostZone + "_x"])+AUST_SHIP[AustPostZone + "_2"]);
		return moneyFormat(fCost);
	}
} // Close bracket for AUSTRALIA

//----------------------------------------------
// INTERNATIONAL --
if (ZONE != "0" ) {


ShippingMethod = "Airmail";

	if (TotWeight <= 0.25) return moneyFormat(INTL_AIR_SHIP[ZONE + "_base"]);

	if ((TotWeight > 0.25) && (TotWeight <= 2.00)) {
		fCost = (((Math.ceil((TotWeight - 0.25)/0.25))*INTL_AIR_SHIP[ZONE + "_x1"])+INTL_AIR_SHIP[ZONE + "_base"]);
		return moneyFormat(fCost);
	}

	if (TotWeight > 2.00) {
		fCost = (((Math.ceil((TotWeight - 2)/0.5))*INTL_AIR_SHIP[ZONE + "_x2"])+ INTL_AIR_SHIP[ZONE + "_base"] + 7*INTL_AIR_SHIP[ZONE + "_x1"]);
		return moneyFormat(fCost);
	}




} // Close bracket for INTERNATIONAL
} // Close bracket for EstimateShipping()






//---------------------------------------------------------------------||
// FUNCTION:    ValidateCart                                           ||
// PARAMETERS:  Form to validate                                       ||
// RETURNS:     true/false                                             ||
// PURPOSE:     Validates the managecart form                          ||
//---------------------------------------------------------------------||

// //sending out the transaction values to complete the checkout page
// COUNTRY_SELECTED = CountrySelected;
// SHIPPING_METHOD = ShippingMethod;
// TOTAL_WEIGHT = fWeight;
// SHIPPING_CHARGE = fShipping;
// INSURANCE_CHARGE = fInsAmount;



var g_TotalCost = 0;
function ValidateCart( theForm ) {


// check for empty cart
if (SUB_TOTAL == "") {
	alert(PromptEmptyCart);
	return false;
}

// check that a destination country has been selected
if (COUNTRY == null) {
	alert(PromptNoCountry);
	return false;
}

// if the selected destination country is Australia, check that a postcode has been entered
if (COUNTRY == "AUSTRALIA") {
	POST_CODE = ""; // clear any latent storred value
	// get the currently storred post code value from the cookie
	POST_CODE = GetCookie("PostCode");
	if (POST_CODE == null) {
		alert(PromptNoPostCode);
		return false;
	}
}


// check that a shipping method has been selected
if (COUNTRY_SELECTED != "AUSTRALIA") {
	if (SHIPPING_METHOD == null) {
		alert(PromptNoShipping);
		return false;
	}
}

// check whether insurance is required
if (Insurance == null) {
	alert(PromptNoInsurance);
	return false;
}




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

   //if ( !RadioChecked(theForm.ZONE) ) {
      //alert( LocationPrompt );
      //return false;
   //}

   //if ( !RadioChecked(theForm.SHIPMETHOD) ) {
   //   alert( ShippingPrompt );
    //  return false;
  // }

	document.all.Check_Out.style.visibility='visible'; 				// bring checkout to the top
 	document.all.Manage_Cart.style.visibility='hidden';			// drop manage cart pane back from view
 	document.all.Manage_Cart_INPUTS_workaround.style.visibility='hidden';			// WORKAROUND 	
 	

 	// these next sections are work-arounds for MS Internet Explorers handling of page elements such as drop down boxes
 	document.all.ZONE.style.visibility='hidden';			// hide the country fropdown
 	document.all.INSURANCEOPTION.style.visibility='hidden';	// hide the insurance select box

 	// if the selected destination country is Australia
	if (COUNTRY_SELECTED != "AUSTRALIA") {					// hide the shipping method dropbox - which occurs on all pages except the Australia page
	document.all.SHIPPINGMETHOD.style.visibility='hidden';
		}

//  	if (SHIPPING_METHOD!=null) {
// 	 	document.getElementById('SHIPPINGMETHOD').style.visibility='hidden';
//  	}

 	//document.getElementById('SHIPPINGMETHOD').style.visibility='hidden';

 	//document.all.SHIPPINGMETHOD.style.visibility='hidden';
//  document.all.Check_Out.style.zIndex='400';, document.all.Manage_Cart.style.zIndex='200',
//    			document.all.SHIPPINGMETHOD.style.visibility='hidden', document.all.SHIPPING_ZONE.style.visibility='hidden', document.all.INSURANCEOPTION.style.visibility='hidden';

}


//---------------------------------------------------------------------||
// FUNCTION: CheckoutCart ||
// PARAMETERS: Null ||
// RETURNS: Product Table Written to Document ||
// PURPOSE: Draws current cart product table on HTML page for ||
// checkout. ||
//---------------------------------------------------------------------||
function CheckoutCart( ) {
var iNumberOrdered = 0; //Number of products ordered
var fTotal = 0; //Total cost of order
var fTax = 0; //Tax amount
var fWeight = 0; //Weight
var fShipping = 0; //Shipping amount
var strTotal = ""; //Total cost formatted as money
var strTax = ""; //Total tax formatted as money
var strShipping = ""; //Total shipping formatted as money
var strOutput = ""; //String to be written to page
var bDisplay = true; //Whether to write string to the page (here for programmers)
var strPP = ""; //Payment Processor Description Field



//the number of rows in the data table is stored in the variable ROWS defined earlier and output at the |
//same time as the data array |

//now we need to parse each variable out of the data pairs which were also stored earlier in their
//respective variables ... since this version of the cart displays all of it's working panes within a
//single html page, there is no need to pass variables outside to another page


//------------ID------------
var pairs = ID;

	for (j=0;j<ROWS;j++)  {
	//find matches for ID_
	searchstring = "ID_" + (j+1);  //search each incidence

	re = searchstring;
	for (i=1;i<pairs.length;i++) {

	m = pairs[i].search(re);

	if (m == "0") {
		mMatch = pairs[i];
		var mmMatch = mMatch.split("=");
		}
	}
	ID[j+1] = mmMatch[1];  //array containing each ID value
} //end bracket for j for loop


// //------------QUANTITY------------
var pairs = QUANTITY

	for (j=0;j<ROWS;j++)  {
	//find matches for QUANTITY_
	searchstring = "QUANTITY_" + (j+1);  //search each incidence

	re = searchstring;
	for (i=1;i<pairs.length;i++) {

	m = pairs[i].search(re);

	if (m == "0") {
		mMatch = pairs[i];
		var mmMatch = mMatch.split("=");
		}
	}
	QUANTITY[j+1] = mmMatch[1];
} //end bracket for j for loop


// //------------PRICE------------
var pairs = PRICE

	for (j=0;j<ROWS;j++)  {
	//find matches for PRICE_
	searchstring = "PRICE_" + (j+1);  //search each incidence

	re = searchstring;
	for (i=1;i<pairs.length;i++) {

	m = pairs[i].search(re);

	if (m == "0") {
		mMatch = pairs[i];
		var mmMatch = mMatch.split("=");
		}
	}
	PRICE[j+1] = mmMatch[1];
} //end bracket for j for loop


// //------------NAME------------
var pairs = NAME

	for (j=0;j<ROWS;j++)  {
	//find matches for NAME_
	searchstring = "NAME_" + (j+1);  //search each incidence

	re = searchstring;
	for (i=1;i<pairs.length;i++) {

	m = pairs[i].search(re);

	if (m == "0") {
		mMatch = pairs[i];
		var mmMatch = mMatch.split("=");
		}
	}
	NAME[j+1] = mmMatch[1];
} //end bracket for j for loop


// //------------WEIGHT------------
var pairs = WEIGHT

	for (j=0;j<ROWS;j++)  {
	//find matches for WEIGHT_
	searchstring = "WEIGHT_" + (j+1);  //search each incidence

	re = searchstring;
	for (i=1;i<pairs.length;i++) {

	m = pairs[i].search(re);

	if (m == "0") {
		mMatch = pairs[i];
		var mmMatch = mMatch.split("=");
		}
	}
	WEIGHT[j+1] = mmMatch[1];
} //end bracket for j for loop


// //------------ADDTLINFO------------
var pairs = ADDTLINFO

	for (j=0;j<ROWS;j++)  {
	//find matches for ADDTLINFO_
	searchstring = "ADDTLINFO_" + (j+1);  //search each incidence

	re = searchstring;
	for (i=1;i<pairs.length;i++) {

	m = pairs[i].search(re);

	if (m == "0") {
		mMatch = pairs[i];
		var mmMatch = mMatch.split("=");
		}
	}
	ADDTLINFO[j+1] = mmMatch[1];
} //end bracket for j for loop


//------------Calculating extended price amount totals for each item row
for (j=1;j<ROWS+1;j++)  {
	EXTAMOUNT[j] = QUANTITY[j]*PRICE[j];
}


// //------------COUNTRY SELECTED------------
//	stored in var COUNTRY_SELECTED



// //------------SHIPPING CHARGE------------
// stored in var SHIPPING_CHARGE


// //------------INSURANCE CHARGE------------
//	stored in var INSURANCE_CHARGE




// Write the check out table header
strOutput += "<TABLE class=\"table\" CELLSPACING=0><TR class=\"row-header\">" +
	"<TH class=\"header-name\">"+strDLabel+"</TH>" + 	//name/description
	"<TH class=\"header-qty\">"+strQLabel+"</TH>" +  //quantity
	"<TH class=\"header-price\">"+strPLabel+"</TH>" +  //price
	"<TH class=\"header-ext\">"+strSLabel+"</TH>" +  //extended amount
	"<TH class=\"header-rmv\">"+strRLabel+"</TH></TR>";  //remove from cart

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// writing the data row by row
for ( i = 1; i < ROWS+1; i++ ) {

strOutput += "<TR class=\"row-entry-single\">" +
	"<TD class=\"cell-name\">"+ NAME[i] +" - "+ ADDTLINFO[i]+"</TD>" +
	"<TD class=\"cell-qty\">" + QUANTITY[i] +"</TD>" +
	"<TD class=\"cell-price\">" + moneyFormat((PRICE[i])) +"</TD>" +
	"<TD class=\"cell-ext\">" + moneyFormat((EXTAMOUNT[i])) +"</TD>" +
	"<TD class=\"cell-rmv\">" + strSpace +"</TD>";

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// output the hidden values for use by the checkout processing script on the server
strOutput += "<input type=hidden name=\"" + OutputItemQuantity + (i) + "\" value=\"" + QUANTITY[i] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemPrice + (i) + "\" value=\"" + PRICE[i] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemName + (i) + "\" value=\"" + NAME[i] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + (i) + "\" value=\"" + ADDTLINFO[i] + "\">";

}

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";
// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

//----------calculating the subtotal for items
subTotal = 0;
for ( i = 1; i < ROWS+1; i++ ) {
subTotal=subTotal + EXTAMOUNT[i];
}

// writing the sub-total
strOutput += "<TR class=\"row-totals\">" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD>" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD>" +
	"<TD CLASS=\"cell-totals-right\">" + strSUB + "</TD>" + //label
	"<TD CLASS=\"cell-totals-right\">" + MonetarySymbol + moneyFormat((subTotal)) + "</TD>" + //subtotal value
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD></TR>";
//output the hidden value to checkout script on server
strOutput += "<input type=hidden name=\"" + OutputOrderSubtotal +"\" value=\"" + moneyFormat((subTotal)) + "\">";

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

//output the shipping charge
strOutput += "<TR class=\"row-totals\">" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD>" +
	"<TD CLASS=\"cell-totals-right\" COLSPAN=2 >SHIPPING CHARGE:</TD>" +
	"<TD CLASS=\"cell-totals-right\">" + MonetarySymbol + moneyFormat((SHIPPING_CHARGE)) + "</TD>" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD></TR>";
//output the hidden value to checkout script on server
strOutput += "<input type=hidden name=\"" + OutputOrderShipping +"\" value=\"" + moneyFormat((SHIPPING_CHARGE)) + "\">";
strOutput += "<input type=hidden name=\"" + OutputOrderShippingMethod +"\" value=\"" + (SHIPPING_METHOD) + "\">";


// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

//output the insurance charge
strOutput += "<TR class=\"row-totals\">" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD>" +
	"<TD CLASS=\"cell-totals-right\" COLSPAN=2 >INSURANCE CHARGE:</TD>" +
	"<TD CLASS=\"cell-totals-right\">" + MonetarySymbol + moneyFormat((INSURANCE_CHARGE)) + "</TD>" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD></TR>";
//output the hidden value to checkout script on server
strOutput += "<input type=hidden name=\"" + OutputOrderInsurance +"\" value=\"" + moneyFormat((INSURANCE_CHARGE)) + "\">";

// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";


//calculate total
TOTAL=SHIPPING_CHARGE+INSURANCE_CHARGE+subTotal;

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

// output the total charge
strOutput += "<TR class=\"row-totals-gray\">" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD>" +
	"<TD CLASS=\"cell-totals-right\" COLSPAN=2 >TOTAL:</TD>" +
	"<TD CLASS=\"cell-totals-right\">" + MonetarySymbol + moneyFormat((TOTAL)) + "</TD>" +
	"<TD CLASS=\"cell-totals\">" + strSpace + "</TD></TR>";
//output the hidden value to checkout script on server
strOutput += "<input type=hidden name=\"" + OutputOrderTotal +"\" value=\"" + moneyFormat((TOTAL)) + "\">";

// Add a blank line
strOutput += "<TR class=\"row-blankgray\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";
// Add a blank line
strOutput += "<TR class=\"row-blank\"><TD COLSPAN=5>"+strSpace+"</TD></TR>";

//--------------------------------------------------------------------------------------




strOutput += "</TABLE>";



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


































//=====================================================================||
// END NOP Design SmartPost Shopping Cart ||
//
// AUSTRALIAN SHIPPING VERSION - GILMOUR ||
//=====================================================================||


