//JRA Interactive, Olympia,Wa var strMyTitlevar strMyNumvar strMyPrice//load page data. Called by an internal script on each product page.function setPageData(title,catNum,price) {//global used by showBasket() and calc()	 strMyTitle = title	 strMyNum = catNum	 strMyPrice = price}//check for cookie before going to the backpackfunction goPack() {	//get the current basket from the cookie	var strBasket=getBasket();	if (strBasket==null) {		//no basket started, so alert visitor		alert("Therešs nothing in your backpack yet.")	} else {	 	window.location="http://www.gnomesworld.com/pages/orderNew.html"	}}//Add page info to basket. This function is in all product pages and is here in basketCode//for testing. If it doesn't appear in a product page, it runs from here.function addToBasket() { 	addBasket(strMyTitle,strMyNum,strMyPrice,1) 	alert('"' + strMyTitle + '"' + " added to your pack. \r\nYou can change this later.")}	//convert basket to a multi-dimensional array and use it to add quantities,//then save to the cookiefunction addBasket(strTitle,strCatNum,strPrice,strQty) {	//get the current basket from the cookie	var strBasket=getBasket();	if (strBasket==null) {		//no basket started, so create one		var lstBasket = new Array(escape(strTitle) + "," + strCatNum + "," + strPrice + "," + strQty)	} else {		//need to add to the current basket		//convert to a multidimensional array		lstBasket = stringToList(strBasket)				//now we have the list of product property arrays		iNext = (lstBasket.length)		var iCatTest		var fMatch = 0		iLast = ( lstBasket.length - 1)		//for each title in the list, test for a matching catNum		for (var i = 0; i <= iLast; i++){			iCatTest = (lstBasket[i][1])			if (strCatNum == iCatTest) {				//match. So add to the quantity and prepare to return the list				iQty = lstBasket[i][3]				iQty++				lstBasket[i][3] = (iQty)				fMatch = 1				break  //leave the loop			}		}		//now, if there was a match, we're done with the list, else add the new list		if (fMatch == 0) {			lstBasket[iNext] = new Array(escape(strTitle),strCatNum,strPrice,strQty)			}	} //end old or new basket routine		//test	strBasketNew = lstBasket.join(",")	SetCookie ("gnomePack",strBasketNew,null,"/");	}//take a string (from the cookie) and turn it into a multi-dimensional listfunction stringToList(strPackList) {	var lstBasic = strPackList.split(",");	var lastitem = (lstBasic.length);	//set final list	var lstMulti = new Array();	//counter to group items into fours	var iCounter = 0;	//for the individual product lists	var lstTemp = new Array();	//form a list of lists (4 elements of each product)		for (var i = 0; i <= lastitem; i++) {		//make four element list from next 4 items in lstBasic		lstTemp[iCounter] = lstBasic[i]		iCounter++		//after iCounter incremented, if it is 4, we're done with this list		if (iCounter == 4) {			//prod list is complete, so add to lstMulti				lstMulti[lstMulti.length] = new Array(lstTemp[0],lstTemp[1],lstTemp[2],lstTemp[3]) 			iCounter = 0		}	}	//lstMulti should now be a list of product attribute lists	return(lstMulti)}// PRIVATE: returns the decoded value of 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));}//  Returns the value of the cookie specified by "name".//  returns - String object containing the cookie value, or null if//      the cookie does not exist.//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;}//  Create or update a cookie.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" : "");}//  Delete a cookie. (Sets expiration date to start of epoch)//    name -   String object containing the cookie name//    path -   String object containing the path of the cookie to delete.  This MUST//             be the same as the path used to create the cookie, or null/omitted if//             no path was specified when creating the cookie.//    domain - String object containing the domain of the cookie to delete.  This MUST//             be the same as the domain used to create the cookie, or null/omitted if//             no domain was specified when creating the cookie.//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";  }}//get the basket contents so we can add to them. If there's no basket, it //returns nullfunction getBasket() {	var strBasket=GetCookie("gnomePack");	return(strBasket)}
