// ****Note: Roy; Begin shopping cart functions.**** // ** global variables for the shopping cart.** var itemNum = new Array(); var itemDescr = new Array(); var itemCost = new Array(); var itemQt=new Array(); var extCst=new Array(); // **Function to parse the cookie and extract the ordered ** // **items from the string. This in turn triggers the ** // **writeCart() function to display the shopping cart. ** function itemsOrdered() { if (getCookieData("Scart")) { substr0 = getCookieData("Scart") cLen = substr0.length offset0 = substr0.indexOf("@") counter = substr0.substring(0,offset0) j = 0 for (i=1; i<=counter; i++) { offsetq = eval('offset' + j + ''); substrq = eval('substr' + j + ''); eval('ind' + i + ' = offsetq + 1'); eval('substr' + i + ' = substrq.substring(ind' + i + ',cLen)'); eval('offset' + i + ' = substr' + i + '.indexOf("^")'); eval('item' + i + ' = substr' + i + '.substring(0,offset' + i + ')'); eval('catInd' + i + ' = item' + i + '.indexOf("`")'); eval('itemCat' + i + ' = item' + i + '.substring(0,catInd' + i + ')'); eval('catqt' + i + ' = item' + i + '.indexOf("*")'); eval('qtcat' + i + ' = item' + i + '.substring((catInd'+i+'+1),catqt' + i + ')'); eval('descrInd' + i + ' = item' + i + '.indexOf("~")'); eval('itemDes' + i + ' = item' + i + '.substring((catqt' + i + ' + 1),descrInd' + i + ')'); eval('itemPr' + i + ' = item' + i + '.substring((descrInd' + i + ' + 2),offset' + i + ')'); eval('orderDetail(i,itemCat' + i + ',qtcat' + i + ',itemDes' + i + ',itemPr' + i + ')'); j++ } writeCart(); } } // **Builds an array of the items to load the cart.** function orderDetail(seq,num,qt,descr,cost) { itemNum[seq] = num itemQt[seq] = qt itemDescr[seq] = descr itemCost[seq] = cost } // ** Function to write the shopping cart details ** // ** into the table on the shopping cart page and** // ** create the buyer details input form.** function writeCart() { var ordFrm = '

Austin Laser Depot Order Check Out

' // **comment out or delete the next line when formmail.cgi, yform.pl is installed // ordFrm += '

' // **uncomment the next 5 lines when formmail.cgi, yform.pl is installed** ordFrm += '
' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' for (i = 1; i <= counter; i++) { extCst[i]=eval(itemCost[i]*itemQt[i]) ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' ordFrm += '' } ordFrm += '' ordFrm += '
ITEMSTOCK #ITEM
PRICE
ORDER
QTY
EXTENDED
COST
CLICK to
REMOVE
' + itemNum[i] + '' + itemDescr[i] + '' + itemCost[i] + '' + itemQt[i] + '' + fix(extCst[i]) + 'Remove
SUB TOTAL: ' ordFrm += 'Will Be
GRAND TOTAL: '; for (o=0;o':'>') + options[o]; html_code2 += '
NOTE: Add special shipping instructions ' html_code2 += 'to the Gift Message box, below. We will contact you to confirm costs.
'; html_code2 += ' 15) && (document.shopCart.ShipVia.options[0].selected)) { with_Shipping = 15 // adjust to maximum shipping charge for shipping option 0 } if ((with_Shipping > 14) && (document.shopCart.ShipVia.options[1].selected)) { with_Shipping = 14 // adjust to maximum shipping charge for shipping option 1 } if ((with_Shipping > 13) && (document.shopCart.ShipVia.options[2].selected)) { with_Shipping = 13 // adjust to maximum shipping charge for shipping option 2 } if ((with_Shipping > 12) && (document.shopCart.ShipVia.options[3].selected)) { with_Shipping = 12 // adjust to maximum shipping charge for shipping option 3 } */ if (document.shopCart.stateResident[0].checked) { document.shopCart.stateTaxes.value = "0.00" } else { document.shopCart.stateTaxes.value = fix(taxes) } document.shopCart.ShipCharges.value = fix(with_Shipping) grand_total = sub_total + taxes + with_Shipping noTaxTotal = sub_total + with_Shipping if (document.shopCart.stateResident[0].checked) { document.shopCart.grandtotal.value = fix(noTaxTotal) } else { document.shopCart.grandtotal.value = fix(grand_total) } } } function fix(num) { var decplaces = 2 var str = "" + Math.round (eval(num) * Math.pow(10,decplaces)) while (str.length <= decplaces) { str = "0" + str } var decpoint = str.length - decplaces return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length); return str; } // function fix(num) { // string = "" + num; // if (string.indexOf('.') == -1) // return string + '.00'; // seperation = string.length - string.indexOf('.'); // if (seperation > 3) // return string.substring(0,string.length-seperation+3) // else if (seperation == 2) // return string + '0'; // return string; // } function validate_form() { detailUpdate = "\n" for (i=1; i<=counter; i++) { fixExtended = fix(extCst[i]) detailUpdate += itemNum[i] + ' ' + itemDescr[i] + ' QTY ' + itemQt[i] + ' at $' + itemCost[i] + ' ea. = $' + fixExtended + '\n' fixExtended = "" } document.shopCart.orderDetail.value = detailUpdate validity = true; if (document.shopCart.FirstName.value == "") { alert('You must enter your first name!'); validity = false; } if (document.shopCart.LastName.value == "") { alert('You must enter your last name!'); validity = false; } if (document.shopCart.email.value == "") { alert('You must enter your email address!'); validity = false; } if (document.shopCart.phone.value == "") { if (confirm("You did not enter a phone number! Click 'Cancel' if you do not wish to provide a phone number. Click 'OK' if you want to provide a phone number.")) valid = false; else document.shopCart.phone.value = 'no phone number provided'; } if ((document.shopCart.credit_card_number.value == "") && (document.shopCart.pay[0].checked)) { alert('You must enter the credit card number!'); validity = false; } else if ((document.shopCart.expiration_date.value == "") && (document.shopCart.pay[0].checked)) { alert('You must enter the expiration date!'); validity = false; } if ((document.shopCart.Street1.value == "") && (document.shopCart.Street2.value == "")) { alert('You must enter a street address!'); validity = false; } if (document.shopCart.City.value == "") { alert('You must enter a city!'); validity = false; } if (document.shopCart.State.value == "") { alert('You must enter a state or province!'); validity = false; } if (document.shopCart.Country.value == "") { if (confirm("You did not enter a country! Click 'Cancel' if you live in the United States. Click 'OK' if you need to fill in a country.")) valid = false; else document.shopCart.Country.value = 'United States'; } if (document.shopCart.zip.value == "") { alert('You must enter zip code or postal code!'); validity = false; } if (validity) { alert("Thank you for your order!"); killCookie("Scart"); } return validity; } // **Function to clear the shopping cart.** function killCart() { killCookie("Scart") history.go(-1) }