// -------------------------------------------------------------------------
// JavaScript 1.1: Online Ordering System Part I
// Author: All rights reserved, Copyright 2004, Chris Colefax <ccolefax@yahoo.com>
// This script, or any part thereof, may not be modified or used without
// express permission from the author
// -------------------------------------------------------------------------


var useShop = (parseFloat(navigator.appVersion) >= 3.0);

var MaxItems = 15;
var Items = new Array();

// Use unique single-character ID for each colour, pass as string of ID chars
	function ItemColour(Desc, Swatch) { this.description = Desc; this.swatch = Swatch; }
	var ItemColours = new Array();
	ItemColours['A'] = new ItemColour('Rib Cotton Knit', 'swatch_A.jpg');
	ItemColours['B'] = new ItemColour('Medium Cotton Knit', 'swatch_B.jpg');
	ItemColours['C'] = new ItemColour('Supa Light Cotton Knit', 'swatch_C.jpg');
	ItemColours['D'] = new ItemColour('Wide Stripe', 'swatch_D.jpg');
	ItemColours['E'] = new ItemColour('Narrow Stripe', 'swatch_E.jpg');
	ItemColours['F'] = new ItemColour('Natural', 'swatch_F.jpg');
	ItemColours['G'] = new ItemColour('Mango', 'swatch_G.jpg');
	ItemColours['H'] = new ItemColour('Navy', 'swatch_H.jpg');
	ItemColours['I'] = new ItemColour('White Knit', 'swatch_I.jpg');
	ItemColours['J'] = new ItemColour('Sage', 'swatch_J.jpg');
	ItemColours['K'] = new ItemColour('Pecan', 'swatch_K.jpg');
	ItemColours['L'] = new ItemColour('White', 'swatch_L.jpg');
	ItemColours['M'] = new ItemColour('Black', 'swatch_M.jpg');
	ItemColours['N'] = new ItemColour('Natural with Narrow Stripe Trim', 'swatch_E.jpg');
	ItemColours['O'] = new ItemColour('Natural with Wide Stripe Trim', 'swatch_D.jpg');
	ItemColours['P'] = new ItemColour('Coco', 'swatch_P.jpg');
	ItemColours['Q'] = new ItemColour('Lime', 'swatch_Q.jpg');
	ItemColours['R'] = new ItemColour('N/A', 'swatch_R.jpg');



// Pass min and max sizes as integers - if less than minimum numeric size, use array of string sizes
	var ItemMinSize = 8;
	var ItemSizes = new Array();
	ItemSizes[0] = 'XS - Extra Small';
	ItemSizes[1] = 'S - Small';
	ItemSizes[2] = 'M - Medium';
	ItemSizes[3] = 'L - Large';
	ItemSizes[4] = 'XL - X Large';
	ItemSizes[5] = 'XXL - X X Large';


function Item(itmCode, itmDesc, itmPrice, itmColours, itmSmallest, itmLargest, itmWeight, itmPage) {
	this.code = itmCode;
	this.description = itmDesc;
	this.price = itmPrice;
	this.colours = itmColours;	// String of colour initials (above)
	this.smallest = itmSmallest;
	this.largest = itmLargest;
	this.weight = itmWeight;
	this.pagefile = itmPage;
	this.cookiename = '';
	this.quantity = 0;
	}


function CurrencyPopup(QueryString) {
	var CurrencyWindow = window.open ('', 'CurrencyWindow', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,height=170,width=600');
	CurrencyWindow.focus();
	CurrencyWindow.location.href = 'http://www.xe.net/ecc/input.cgi?Template=sw&' + QueryString;
	}


function FormatNumber(val, dec) {
	rval = Math.round(eval(val) * Math.pow(10, dec)).toString();
	if (dec > 0) {
		rval = rval.substring(0, rval.length - dec) + '.' + rval.substring(rval.length - dec, rval.length);
		}
	return rval;
	}


function SaveItem(i) {
	document.cookie = Items[i].cookiename + '=' +
		'(' + escape(Items[i].code) +
		'~' + escape(Items[i].colour) +
		'~' + escape(Items[i].size) +
		'~' + escape(Items[i].description) +
		'~' + escape(Items[i].price) +
		'~' + escape(Items[i].weight) +
		'~' + escape(Items[i].pagefile) +
		'~Q' + escape(Items[i].quantity) +
		');PATH=/';
	}


function DeleteCookie(Name) {
	var ExpireNow = new Date(); ExpireNow.setTime(ExpireNow.getTime() - 1000);
	document.cookie = Name + '=null;PATH=/;EXPIRES=' + ExpireNow.toGMTString();
	}
