// // set up the variables var totLines = 0; var totItems = 0; var totCost = 0.00; var totShipping = 0; var freeShipping = 9999.99; var totInsure = 0; var grandTotal = 0; var countItem = -1; var lastRing = -1; var lastDirect = -1; var descWidth = 0; var typeWidth = 0; var order; var orderStatus=0; var salesNote = ""; // string is blank or has notes to display // itemSize = new Array(); // in mm (i.e. "24mm") itemFits = new Array(); // string; coins this fits itemRing = new Array(); // ring color, or DF itemPrice = new Array(); // price per item itemQty = new Array(); // quantity to be ordered itemTotal = new Array(); // total cost (price x qty) // // define all procedures // // function getOrder() { if (orderStatus == 0) { return "(Order not Finalized Yet)"; } else { var tmpDate = new Date(); var retstr = document.formSubmit.State.value+totItems+"-"+tmpDate.getYear()+(tmpDate.getMonth()+1)+tmpDate.getDate(); retstr += "-"+tmpDate.getHours()+tmpDate.getMinutes()+tmpDate.getSeconds(); } document.formSubmit.form_id.value = "CAMACS Air-Tite Order: "+retstr; return retstr; } // function fix_int(intnum, minsize) { var tmpstr = (0.000050 + intnum) + "000"; var numoutstr; var idx = tmpstr.indexOf("."); numoutstr = tmpstr.substring(0, (idx) ); while (numoutstr.length < minsize) numoutstr = " "+numoutstr; return numoutstr; } // end procedure fix_int // function fix_string( strin, len ) { var strout = strin; while (strout.length < len ) strout += " "; return strout; } // end function fix_string // // function fix_dollar( realnum, len ) { var tmpreal = 0.00001 + realnum; var tmpstr = tmpreal+"000000"; var tmpstr2; var tmplen; if (len < 4) tmplen = 4 else tmplen = len; // need to trim off trailing zeros var idx = tmpstr.indexOf("."); tmpstr2 = tmpstr.substring(0, (idx+3) ); while (tmpstr2.length < tmplen) tmpstr2 = " " + tmpstr2; return tmpstr2; } // end procedure fix_dollar // function calc_costs() { var coststr2; totLines = 0; totItems = 0; totCost = 0.00; totShipping = 0; totInsure = 0; grandTotal = 0; descWidth = 0; for (iline=0; iline <= lastDirect; iline++) { if (itemQty[iline] >= 1 ) { totLines++; totItems += itemQty[iline]; coststr2 = fix_dollar( (itemPrice[iline] * itemQty[iline]) , 6); itemTotal[iline] = "$" + coststr2 ; totCost += eval( coststr2); if (typeWidth < (1+itemSize[iline].length+itemRing[iline].length)) typeWidth = (1+itemSize[iline].length+itemRing[iline].length); } } //calculate insurance if (totCost <= 50) { totInsure = 1.30; } else { if (totCost <= 100) { totInsure = 2.20; } else { totInsure = 2.20 + (1.00 * eval(fix_int( ((totCost)/100)), 2)); } } // end calculate insurance if (document.formSubmit.noInsurance.checked == true) { totInsure = 0; } else { if (document.formSubmit.yesInsurance.checked == true) { } else { alert("You must either Accept or Decline shipping insurance."); orderStatus = 0; return; } } // calculate shipping if (totItems <= 40) { totShipping = 3.85; } else { if (totItems <= 80) { totShipping = 4.45; } else { if (totItems <= 125) { totShipping = 5.65; } else { totShipping = 5.65 + (1.20 * ((totItems-125)/45) ); } } } // end calculate shipping order = getOrder(); if (totInsure < 0.01) { grandTotal = totCost + totShipping + totInsure + 0.40; } else { grandTotal = totCost + totShipping + totInsure ; } if( totCost >= freeShipping) { totShipping = 0.0; totInsure = 0.0; grandTotal = totCost; } if (totItems < 25) { alert("You must select a minimum of 25 Air-Tites to make a purchase.\nPlease enter quantities for each item desired.\n You have selected "+totItems +" pieces so far."); document.formSubmit.Comments.value="You must select a minimum of 25 Air-Tites to make a purchase.\nPlease correct your order.\nYou have selected "+totItems +" pieces so far.\n"; document.formSubmit.Comments.rows = 3; orderStatus = 0; return; } orderStatus = -1; } // end procedure calc_costs function printOrder() { // put a header of instructions to the buyer in the order window (textarea) orderStatus = -1; calc_costs(); document.formSubmit.Comments.value += "\n\nDear "+document.formSubmit.Name.value+",\n\nWhen you receive this E-mail, please complete your Mail-in Order:\n"; document.formSubmit.Comments.value += "(1)Print this E-mail for your records.\n\n"; document.formSubmit.Comments.value += "(2)Print another copy of this E-mail and mail with\n"; document.formSubmit.Comments.value += " your payment for the Final Cost (below), payable to:\n\n"; document.formSubmit.Comments.value += " Pocket Change\n"; document.formSubmit.Comments.value += " P.O. Box 2607\n"; document.formSubmit.Comments.value += " Alamogordo, NM 88311\n\n"; document.formSubmit.Comments.value += "(3)Relax while your order gets delivered.\n\n"; document.formSubmit.Comments.value += "Thank you for ordering from CAMACS\n"; document.formSubmit.Comments.value += "---------------------------------------------------\n\n"; } // end function printOrder function alertPayment( ) { var paymentText = "Payment Instructions:\n\n"; paymentText += "(1) When you click 'Finalize Order & Submit', your order is sent to CAMACS\n"; if( document.formSubmit.payChk.checked == true) { paymentText += "(2) CAMACS will verify item availability and send you an E-mail.\n"; paymentText += "(3) When you receive that E-mail, please make your payment by:\n\n"; paymentText += "Printing a copy of the E-mail, and send the copy and your check to:\n"; paymentText += " Pocket Change\n"; paymentText += " P.O. Box 2607\n"; paymentText += " Alamogordo, NM 88311\n\n"; } if( document.formSubmit.payPal.checked == true) { paymentText += "(2) CAMACS will verify item availability and send you an E-mail.\n"; paymentText += "(3) When you receive that E-mail, please make your payment by:\n\n"; paymentText += "Submitting a PayPal payment to camacs@zianet.com \n"; paymentText += "for the total amount shown on the order. Please\n"; paymentText += "include the order number in the payment message.\n\n"; } if( document.formSubmit.payCCm.checked == true) { paymentText += "(2) CAMACS will verify item availability and send you an E-mail.\n"; paymentText += "(3) When you receive that E-mail, please make your payment by:\n\n"; paymentText += "Calling 1-877-863-2740 Tue-Sat 10 a.m. to 5 p.m. with your\n"; paymentText += "Credit Card to charge the total amount shown on the order.\n\n"; } if( document.formSubmit.payCCo.checked == true) { paymentText += "(2) You then will have a secured form to enter Credit Card information into.\n\n"; paymentText += "(3) CAMACS will verify item availability and send you an E-mail with an invoice.\n"; } paymentText += "(4) Relax while your order gets delivered.\n\n"; paymentText += "The E-mail you'll receive has these instructions in it."; alert( paymentText ); } function submitOrder() { // put a header of instructions to the buyer in the order window (textarea) orderStatus = -1; calc_costs(); if( document.formSubmit.payPal.checked == true) { document.formSubmit.Comments.value += "\n\nDear "+document.formSubmit.Name.value+",\n\nWhen you receive this E-mail, please complete your On-Line Order:\n"; document.formSubmit.Comments.value += "(1)Print this E-mail for your records.\n\n"; document.formSubmit.Comments.value += "(2)Submit a PayPal payment to camacs@zianet.com\n"; { document.formSubmit.Comments.value += " for the Final Cost (below), Please\n"; } } if( document.formSubmit.payCCm.checked == true) { document.formSubmit.Comments.value += "\n\nDear "+document.formSubmit.Name.value+",\n\nWhen you receive this E-mail, please complete your On-Line Order:\n"; document.formSubmit.Comments.value += "(1)Print this E-mail for your records.\n\n"; document.formSubmit.Comments.value += "(2)Call 1-877-863-2740 Tue-Sat 10 a.m. to 5 p.m. with your\n"; document.formSubmit.Comments.value += " Credit Card to charge the Final Cost (below)\n\n"; } if( document.formSubmit.payCCo.checked == true) { document.formSubmit.Comments.value += "\n\nDear "+document.formSubmit.Name.value+",\n\nWhen you receive this E-mail, please complete your On-Line Order:\n"; document.formSubmit.Comments.value += "(1)Print this E-mail for your records.\n\n"; document.formSubmit.Comments.value += "(2)Your Credit Card information was submitted on-line.\n"; } document.formSubmit.Comments.value += "(3)Relax while your order gets delivered.\n\n"; document.formSubmit.Comments.value += "Thank you for ordering from CAMACS\n"; document.formSubmit.Comments.value += "---------------------------------------------------\n\n"; } // end function submit order function calcOrder() { // formats order and displays in the order window (textarea) var coststr; totLines = 0; totItems = 0; totCost = 0.00; totShipping = 0; totInsure = 0; grandTotal = 0; calc_costs(); if (orderStatus == 0) return; document.formSubmit.Comments.value+="CAMACS Air-Tite On-Line Order Number: "+order+"\n\n"; for (iline=0; iline <= lastDirect; iline++) { if (itemQty[iline] >= 1 ) { document.formSubmit.Comments.value += "Item: "+ fix_string(itemSize[iline]+" "+itemRing[iline], typeWidth )+" "+ " Qty: "+fix_int(itemQty[iline], 3)+ " @ $"+ fix_dollar(itemPrice[iline],4)+ "ea Cost: "+itemTotal[iline]+"\n"; } } document.formSubmit.Comments.value += "\n Sub-total: $"+fix_dollar(totCost, 7)+" ("+totItems+" pieces)\n"; if ((totInsure < 0.01) && (totCost < freeShipping)) { document.formSubmit.Comments.value += " Shipping: $"+fix_dollar( (totShipping+0.40), 7)+" (Delivery Confirmation)\n"; document.formSubmit.Comments.value += " Insurance: - (declined - Buyer's Risk)\n"; } else { document.formSubmit.Comments.value += " Shipping: $"+fix_dollar( totShipping, 7)+"\n"; document.formSubmit.Comments.value += " Insurance: $"+fix_dollar( totInsure, 7)+"\n"; } document.formSubmit.Comments.value += " Final Cost: $"+fix_dollar(grandTotal,7)+"\n\n"; document.formSubmit.Comments.value += "Ship this Order to:\n"; if (document.formSubmit.Name.value != "") document.formSubmit.Comments.value += " "+document.formSubmit.Name.value+"\n"; if (document.formSubmit.Address1.value != "") document.formSubmit.Comments.value += " "+document.formSubmit.Address1.value+"\n"; if (document.formSubmit.Address2.value != "") document.formSubmit.Comments.value += " "+document.formSubmit.Address2.value+"\n"; document.formSubmit.Comments.value += " "+document.formSubmit.City.value+", "+document.formSubmit.State.value+" "+document.formSubmit.ZIP_Code.value+"\n\n"; if (document.formSubmit.submit_by.value != "") document.formSubmit.Comments.value += "E-mail Address: "+document.formSubmit.submit_by.value+"\n\n"; document.formSubmit.Comments.value += "Comments: "+document.formSubmit.Notes.value + "\n\n"; if (document.formSubmit.payChk.checked == true) { document.formSubmit.Comments.value += "This Order is a Mail-In, Payment by Check, M.O., or Cash\n\n"; } else { if (document.formSubmit.payPal.checked == true) { document.formSubmit.Comments.value += "This is an On-Line order, Payment by PayPal\n\n"; } else { if (document.formSubmit.payCCm.checked == true) { document.formSubmit.Comments.value += "This is an On-Line order, telephone Payment by MasterCard or VISA\n\n"; } else { if (document.formSubmit.payCCo.checked == true) { document.formSubmit.Comments.value += "This is an On-Line order, secured Payment by MasterCard or VISA\n\n"; } else { document.formSubmit.Comments.value += "WARNING: Payment type has not yet been selected. (See above)\n\n"; } } } } var formLength = totLines+8+8+6+3; document.formSubmit.Comments.rows = formLength; } // end procedure calcOrder function displayOrder() { document.formSubmit.Comments.value = ""; // clear Order Window (textarea) orderStatus = 0; calcOrder(); document.formSubmit.Comments.value += "***** Click 'Finalize Order' to complete this order. *****\n"; orderStatus=0; // do not submit, yet document.formSubmit.finalBtn.focus(); } function zeroForm() { window.document.formSelect.reset(); for (iline=0; iline <= lastDirect; iline++) { itemQty[iline] = 0; } totLines = 0; //window.document.formSubmit.reset(); } // function displayDone() { document.formSubmit.Comments.value="CAMACS Air-Tite On-Line Order Number: "+order+"\n\n"; document.formSubmit.Comments.value += "Final Cost: $"+fix_dollar(grandTotal,6)+" ("+totItems+" pieces)\n"; totItems = 0; if (document.formSubmit.payChk.checked == true) { document.formSubmit.Comments.value += "This Order is a Mail-In, Payment by Check, M.O., or Cash\n"; } if (document.formSubmit.payPal.checked == true) { document.formSubmit.Comments.value += "This is an On-Line order, Payment by PayPal\n"; } if (document.formSubmit.payCCm.checked == true) { document.formSubmit.Comments.value += "This is an On-Line order, telephone Payment by MasterCard or VISA\n"; } if (document.formSubmit.payCCo.checked == true) { document.formSubmit.Comments.value += "This is an On-Line order, secured Payment by MasterCard or VISA\n"; } document.formSubmit.Comments.value += "\nYour order has been E-mailed to CAMACS\n\n"; document.formSubmit.Comments.value += "You will receive a reply aknowledging your order,\n"; document.formSubmit.Comments.value += "and providing payment instructions.\nThank you\n"; } // end function displayDone function finalOrder() { orderStatus = 1; document.formSubmit.Comments.value = ""; // clear Order Window (textarea) // this decides whether to submit on-line or mail-in order if ( (document.formSubmit.payPal.checked == true) || (document.formSubmit.payCCm.checked == true)|| (document.formSubmit.payCCo.checked == true) ) { if (orderStatus != 0) submitOrder(); // put PayPal/CC header info into order window if (orderStatus != 0) calcOrder(); // put order info into order window if (orderStatus != 0) { document.formSubmit.Comments.rows = 6; zeroForm(); document.formSubmit.submit(); // E-mail order to CAMACS //displayDone(); } } else { if (document.formSubmit.payChk.checked == true) { if (orderStatus != 0) printOrder(); // put Mail-In header info into order window if (orderStatus != 0) calcOrder(); // put order info into order window if (orderStatus != 0) { document.formSubmit.Comments.rows = 6; zeroForm(); document.formSubmit.submit(); // E-mail order to CAMACS //displayDone(); } } else { alert("You must select a Payment Method.\n(1)On-Line with PayPal, or\n(2)Mail-In Check, M.O., Cash, or\n(3)On-Line with MasterCard or VISA\n"); orderStatus = 0; var formLength = 6; // zeroForm(); document.formSubmit.Comments.value = "You must select a Payment Method.\n(1)On-Line with PayPal, or\n(2)Mail-In Check, M.O., Cash, or\n(3)On-Line with MasterCard or VISA\n\nPlease correct your order."; document.formSubmit.Comments.rows = 6; return; } } } // end finalOrder // function addQty( idx, object ) { var numbers = "0123456789 "; var tmpstr = object.value; if (tmpstr == "") tmpstr="0"; //document.formSubmit.Comments.value = "Order Form Will be Displayed Here"; //document.formSubmit.Comments.rows = 1; orderStatus =0; for (idx2 =0; idx2= 0) { itemQty[idx] = nbr; } else { alert("Quantity must be a number, 0 or larger.\n Quantity reset to zero.\n Please try again.\n You Entered "+tmpstr); object.value = "0"; itemQty[idx] = 0; object.focus(); return; } } // end procedure addQty // function switch_finalpage() { if( document.formSubmit.payChk.checked == true) { document.formSubmit.ok_url.value = "http://www.camacs.com/thankyou.html"; } if( document.formSubmit.payPal.checked == true) { document.formSubmit.ok_url.value = "http://www.camacs.com/thankyou.html"; } if( document.formSubmit.payCCm.checked == true) { document.formSubmit.ok_url.value = "http://www.camacs.com/thankyou.html"; } if( document.formSubmit.payCCo.checked == true) { document.formSubmit.ok_url.value = "https://secure.zianet.com/camacs/secure_ccform.html"; } //alert( paymentText ); } // end switch function FSubmitValidation() { if (totItems < 25) { return false; } if (document.formSubmit.Name.value == "") { alert("The Name field is required to be filled out.
Order submission cancelled."); return false; } // if (document.formSubmit.submit_by.value == "") { alert("Your E-mail address is required to be filled out.
Order submission cancelled."); return false; } return true; }