// include the appropriate libraries function activateLoadingImg(loadingGraphicID) { document.getElementById(loadingGraphicID).src = '/template_images/loading-roller.gif'; } function deactivateLoadingImg(loadingGraphicID) { document.getElementById(loadingGraphicID).src = '/template_images/spacer.gif'; } /* +----------------------------------+ | START Checkout related functions | +----------------------------------+ */ var ajaxReturnVal = ''; // the data returned from the last ajax call //var checkoutSections = new Array('shipping_box','matmoney_coupon_box','taxes_fees_box','matmoney_giftcard_box','payment_method_box','final_review_box'); var checkoutFormName = "checkoutform"; var fieldErrorColor = "#ffacac"; var loadingGraphicID = 'loadingGraphic'; // the id of the image that will be used to indicate loading var loadingGraphicOnSrc = '/template_images/loading-roller.gif'; // the url of the image that will be used to indicate loading var loadingGraphicOffSrc = '/template_images/spacer.gif'; // the url of the place holder image that will be used when not loading var respDelayMS = 1000; // the number of millisecojnds to wait for server resposes to ajax requests function activateLoadingImg() { document.getElementById(loadingGraphicID).src = loadingGraphicOnSrc; } function deactivateLoadingImg() { document.getElementById(loadingGraphicID).src = loadingGraphicOffSrc; } function convFormVarsToNameValueStr(formObject) { var formAgrs = ""; var formVarName = ''; var formVarValue = ''; if (formObject) { for (i=0; iContinue Without An Account'; content += '

Create An Account

'; content += '

Login To My Account

'; launchFaceBox(content); return false; } else { document.location = "https://www.matcutter.com/cart.php?paction=checkout"; } return true; } // function that verifies that cc num matches cc type slected in pulldown /*function chkCardType(typeField, numField) { var typeNumber = numField.value.substr(0,1); // get the first digit to determine type var typeName = typeField.options[typeField.selectedIndex].value; // get the value of the card type the user selected // 3=Amex, 4=Visa, 5=Mastercard, 6=Discover if (typeNumber == "3" && typeName == "amex") { return true; } if (typeNumber == "4" && typeName == "visa") { return true; } if (typeNumber == "5" && typeName == "mastercard") { return true; } if (typeNumber == "6" && typeName == "discover") { return true; } // if we've gotten this far, they do not match up alert("The card type you have selected does not\nmatch the card number you have entered.\nPlease correct and re-submit."); return false; }*/ function initPaypal() { var isError = 0; var errMsg = "The following fields have errors that need to be corrected:\n\n"; var formObject = document.forms["checkoutform"]; // clear out previous errors and re-evaluate clearFormErrors("checkoutform"); // make sure we have an email if (formObject.elements["email"].value.length < 5) { isError = 1; errMsg += " - Email For Order Correspondence\n"; document.getElementById("email").style.backgroundColor = fieldErrorColor; } // make sure email matches confirm email if (formObject.elements["email"].value != formObject.elements["email2"].value) { isError = 1; errMsg += " - Email For Order Correspondence Mismatch\n"; document.getElementById("email").style.backgroundColor = fieldErrorColor; document.getElementById("email2").style.backgroundColor = fieldErrorColor; } // evaluate and return accordingly if (isError >= 1) { alert(errMsg); return false; } else { document.location = 'cart.php?paction=setPaypalExpressChkOut&email='+formObject.elements["email"].value; } } function ckCheckoutForm(orderGrandTotal) { var isError = 0; var errMsg = "The following fields have errors that need to be corrected:\n\n"; var formObject = document.forms["checkoutform"]; // clear out previous errors and re-evaluate clearFormErrors("checkoutform"); // make sure we have an email if (formObject.elements["email"].value.length < 5) { isError = 1; errMsg += " - Email For Order Correspondence\n"; document.getElementById("email").style.backgroundColor = fieldErrorColor; } // make sure email matches confirm email if (formObject.elements["email"].value != formObject.elements["email2"].value) { isError = 1; errMsg += " - Email For Order Correspondence Mismatch\n"; document.getElementById("email").style.backgroundColor = fieldErrorColor; document.getElementById("email2").style.backgroundColor = fieldErrorColor; } if (orderGrandTotal > 0) { // make sure we have a credit card number if (formObject.elements["cc_num"].value.length < 6) { isError = 1; errMsg += " - Credit Card Number\n"; document.getElementById("cc_num").style.backgroundColor = fieldErrorColor; } // make sure we have a credit card cvv2 if (formObject.elements["cc_cvv2"].value.length < 3) { isError = 1; errMsg += " - Credit Card CVV2\n"; document.getElementById("cc_cvv2").style.backgroundColor = fieldErrorColor; } // make sure we have a credit card name if (formObject.elements["cc_name"].value.length < 1) { isError = 1; errMsg += " - Credit Card Name\n"; document.getElementById("cc_name").style.backgroundColor = fieldErrorColor; } } // evaluate and return accordingly if (isError >= 1) { alert(errMsg); return false; } else { formObject.submit(); return true; } } // start shipping section function function setAddressTypeFields(addressTypeObject) { if (addressTypeObject.value == "Canada") { document.getElementById("ship_to_type_box").style.display = "block"; } else { document.getElementById("ship_to_type_box").style.display = "none"; } return true; } function chkShipSection() { var isError = 0; var errMsg = "The following fields have errors that need to be corrected:\n\n"; var formObject = document.forms["setShippingForm"]; // clear out previous errors and re-evaluate clearFormErrors("setShippingForm"); // make sure we have a first name if (formObject.elements["ship_to_firstname"].value.length < 1) { isError = 1; errMsg += " - First Name\n"; document.getElementById("ship_to_firstname").style.backgroundColor = fieldErrorColor; } // make sure we have a last name if (formObject.elements["ship_to_lastname"].value.length < 1) { isError = 1; errMsg += " - Last Name\n"; document.getElementById("ship_to_lastname").style.backgroundColor = fieldErrorColor; } // if going to canada, make sure they have selected something in the ship_to_type radio button array if (formObject.elements["ship_to_country"][formObject.elements["ship_to_country"].selectedIndex].value == "Canada") { var isRadioSelected = 0; var selectedRadioVal = ""; for (i=0; i= 1) { alert(errMsg); return false; } else { return true; } } function ckIsShippingDataSet() { if (ajaxReturnVal == "1") { document.location = "https://www.matcutter.com/cart.php?paction=checkout"; } else { launchFaceboxWithRemoteResponse('/cart.php','getShippingForm','setShipStartCheckout'); } } function isShippingDataSet() { sendAJAXpostReq('&paction=isShippingDataSet', '/cart.php'); setTimeout(ckIsShippingDataSet, respDelayMS); } // start shipping section function function chkBillSection() { var isError = 0; var errMsg = "The following fields have errors that need to be corrected:\n\n"; var formObject = document.forms["setBillingForm"]; // clear out previous errors and re-evaluate clearFormErrors("setBillingForm"); // make sure we have a first name if (formObject.elements["bill_to_firstname"].value.length < 1) { isError = 1; errMsg += " - First Name\n"; document.getElementById("bill_to_firstname").style.backgroundColor = fieldErrorColor; } // make sure we have a last name if (formObject.elements["bill_to_lastname"].value.length < 1) { isError = 1; errMsg += " - Last Name\n"; document.getElementById("bill_to_lastname").style.backgroundColor = fieldErrorColor; } // make sure we have a address if (formObject.elements["bill_to_address"].value.length < 1) { isError = 1; errMsg += " - Address\n"; document.getElementById("bill_to_address").style.backgroundColor = fieldErrorColor; } // make sure we have a city if (formObject.elements["bill_to_city"].value.length < 1) { isError = 1; errMsg += " - City\n"; document.getElementById("bill_to_city").style.backgroundColor = fieldErrorColor; } // make sure we have a state if (formObject.elements["bill_to_state"][formObject.elements["bill_to_state"].selectedIndex].value == "--Select--") { isError = 1; errMsg += " - State\n"; document.getElementById("bill_to_state").style.backgroundColor = fieldErrorColor; } // make sure we have a Zip/Postal Code if (formObject.elements["bill_to_zip"].value.length < 3) { isError = 1; errMsg += " - Zip/Postal Code\n"; document.getElementById("bill_to_zip").style.backgroundColor = fieldErrorColor; } // make sure we have a country if (formObject.elements["bill_to_country"][formObject.elements["bill_to_country"].selectedIndex].value == "--Select--") { isError = 1; errMsg += " - Country\n"; document.getElementById("bill_to_country").style.backgroundColor = fieldErrorColor; } // make sure we have a phone if (formObject.elements["bill_to_phone"].value.length < 7) { isError = 1; errMsg += " - Phone\n"; document.getElementById("bill_to_phone").style.backgroundColor = fieldErrorColor; } // evaluate and return accordingly if (isError >= 1) { alert(errMsg); return false; } else { return true; } } function ckIsBillingDataSet() { if (ajaxReturnVal == "1") { document.location = "https://www.matcutter.com/cart.php?paction=checkout"; } else { launchFaceboxWithRemoteResponse('/cart.php','getBillingForm','setBillStartCheckout'); } } function isBillingDataSet() { sendAJAXpostReq('&paction=isBillingDataSet', '/cart.php'); setTimeout(ckIsBillingDataSet, respDelayMS); } function launchFaceboxWithRemoteResponse(destURL, primaryActionValue, subactionValue) { $.facebox.settings.opacity = .5; /* $(document).bind('afterReveal.facebox', function() { $('#facebox .body').width('450px'); }); */ $.facebox(function() { $.ajax({ data: { 'paction' : primaryActionValue, 'subaction' : subactionValue}, error: function() { $.facebox('There was an error when attempting to fetch the shipping form. Please try again shortly.'); }, success: function(data) { $.facebox(data); }, type: 'post', url: destURL }); }); } /*function setShipData() { // eval first if (!chkShipSection()) { return false; } loadingGraphicID = 'shipSectionLoadingGraphic'; var formObject = document.forms[checkoutFormName]; formObject.elements["paction"].value = "setShippingData"; sendFormViaAJAXpost("/cart.php", formObject); setTimeout(setShipResp, respDelayMS); } function setShipResp() { //deactivateLoadingImg(); var respParts = ajaxReturnVal.split("|"); if (respParts.length == 3) { // set totals in the top header bar document.getElementById("shipping_box_total").innerHTML = "$"+parseFloat(respParts[1])+"
Estimated Delivery: "+respParts[2]+"
"; // activate the "next" button document.getElementById("initMatMoneyCouponButtonBox").innerHTML = ""; } return true; } */ /*function getShippingForm(submitTo, formAction, formMethod, paction) { sendAJAXpostReq('paction=getShippingForm', '/cart.php') } function setShippingForm() { } // end shipping section function // start matmoney coupon code section functions function activateMatMoneyCouponSection() { document.getElementById(checkoutSections[0]+"_trigger").style.display = "inline"; closeAllCheckoutBodySections(); document.getElementById(checkoutSections[1]).style.display = "block"; document.getElementById(checkoutSections[1]+"_body").style.display = "block"; } */ function setReferralOtherField(menuObject) { if (menuObject.value == "Other:") { document.getElementById("referralOtherBox").style.display = "block"; if (document.getElementById("referrer_name")) { document.getElementById("referrer_name").focus(); } } else { document.getElementById("referralOtherBox").style.display = "none"; } } function setStateOtherInput(stateMenuObj, stateOtherLayerId, stateOtherInputId) { if (stateMenuObj.value == "Other") { document.getElementById(stateOtherLayerId).style.display = "block"; if (document.getElementById(stateOtherInputId)) { document.getElementById(stateOtherInputId).focus(); } } else { document.getElementById(stateOtherLayerId).style.display = "none"; } } function setCountryOtherInput(countryMenuObj, countryOtherLayerId, countryOtherInputId) { if (countryMenuObj.value == "Other") { document.getElementById(countryOtherLayerId).style.visibility = "visible"; if (document.getElementById(countryOtherInputId)) { //document.getElementById("country_other_input").value = 'Enter your country here.';; document.getElementById(countryOtherInputId).focus(); } //document.forms[formName].elements[""]. } else { document.getElementById(countryOtherLayerId).style.visibility = "hidden"; } } /* +--------------------------------+ | END Checkout related functions | +--------------------------------+ */ // returns true if date appears to be valid // returns false if the date appears to be invalid // 1arg; = text input object, string should be like: mm/dd/yyyy function ckDate(textObject) { var x = 0; var fieldVal = textObject.value; var isError = 0; var errorMsg = "Date must be in MM/DD/YYYY format.\nExample: 01/30/2009"; if (fieldVal.length === 0 || !fieldVal.length) { return true; } if (fieldVal.length != 10) { // all dates should be exactly 10 digits isError = 1; } for (x=0; x 57){ isError = 1; break; } } if (isError == 1) { textObject.select(); alert(errorMsg); return false; } else { return true; } } // The following function creates an XMLHttpRequest object... function createRequestObject() { var request_o = false; //declare the variable to hold the object. var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE if (window.ActiveXObject) { //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken) for (var i=0; i

Error:

"+respParts[1]+""); //alert(respParts[1]); } } }; ajaxReqObj.send('uid='+uid+'&paction=redeemMatMoneyGiftCardCode&matmoneygiftcard_code='+codeValue+'&email='+email+'&emailForOrder='+emailForOrder); return true; } function chkStep1Ship() { // check the email fields if (document.checkoutform.email.value.length < 3) { alert("A valid email address is required.\n"); document.checkoutform.email.focus(); return false; } if (document.checkoutform.email.value != document.checkoutform.email2.value) { alert("Email address mismatch.\nYou must confirm your email address."); document.checkoutform.email2.focus(); return false; } //bill to firstname if (document.checkoutform.bill_to_firstname.value.length < 1) { alert("Billing First Name is required."); document.checkoutform.bill_to_firstname.focus(); return false; } //bill to lastname if (document.checkoutform.bill_to_lastname.value.length < 1) { alert("Billing Last Name is required."); document.checkoutform.bill_to_lastname.focus(); return false; } //bill to address if (document.checkoutform.bill_to_address.value.length < 1) { alert("Billing Address is required."); document.checkoutform.bill_to_address.focus(); return false; } //bill to city if (document.checkoutform.bill_to_city.value.length < 1) { alert("Billing City is required."); document.checkoutform.bill_to_city.focus(); return false; } //bill to state if (document.checkoutform.bill_to_state.value == "--Select--" || document.checkoutform.bill_to_state.value.length < 2) { alert("Billing State is required."); document.checkoutform.bill_to_state.focus(); return false; } //bill to zip if (document.checkoutform.bill_to_zip.value.length < 5) { alert("Billing Zip is required."); document.checkoutform.bill_to_zip.focus(); return false; } //bill to country if (document.checkoutform.bill_to_country.value.length < 1 || document.checkoutform.bill_to_country.value == "--Select--") { alert("Billing Country is required."); document.checkoutform.bill_to_country.focus(); return false; } if (document.checkoutform.bill_to_country.value == "Other" && document.checkoutform.bill_to_country_other.value.length < 1) { alert("Billing Country is required."); document.checkoutform.bill_to_country_other.focus(); return false; } //bill to phone if (document.checkoutform.bill_to_phone.value.length < 1) { alert("Billing Telephone is required."); document.checkoutform.bill_to_phone.focus(); return false; } //ship to firstname if (document.checkoutform.ship_to_firstname.value.length < 1) { alert("Shipping First Name is required."); document.checkoutform.ship_to_firstname.focus(); return false; } //ship to lastname if (document.checkoutform.ship_to_lastname.value.length < 1) { alert("Shipping Last Name is required."); document.checkoutform.ship_to_lastname.focus(); return false; } //ship to address if (document.checkoutform.ship_to_address.value.length < 1) { alert("Shipping Address is required."); document.checkoutform.ship_to_address.focus(); return false; } //ship to city if (document.checkoutform.ship_to_city.value.length < 1) { alert("Shipping City is required."); document.checkoutform.ship_to_city.focus(); return false; } // ship to state if (document.checkoutform.ship_to_state.value == "--Select--" || document.checkoutform.ship_to_state.value.length < 2) { alert("Shipping State is required."); document.checkoutform.ship_to_state.focus(); return false; } //ship to zip if (document.checkoutform.ship_to_zip.value.length < 5) { alert("Shipping Zip is required."); document.checkoutform.ship_to_zip.focus(); return false; } //ship to country if (document.checkoutform.ship_to_country.value.length < 1 || document.checkoutform.ship_to_country.value == "--Select--") { alert("Shipping Country is required."); document.checkoutform.ship_to_country.focus(); return false; } if (document.checkoutform.ship_to_country.value == "Other" && document.checkoutform.ship_to_country_other.value.length < 1) { alert("Shipping Country is required."); document.checkoutform.ship_to_country_other.focus(); return false; } //ship to phone if (document.checkoutform.ship_to_phone.value.length < 1) { alert("Shipping Telephone is required."); document.checkoutform.ship_to_phone.focus(); return false; } // handle the TAXID stuff if (document.checkoutform.ship_to_state.value == "GA" && document.checkoutform.county_id) { if (document.checkoutform.county_id.value == '--SELECT--' || document.checkoutform.county_id.value.length < 1) { alert("You must select a county if shipping to GA.\n\n" + "If we have a Tax Id on file for your account\n" + "you will not be charged sales tax.\n\n" + "If you are a reseller and have not provided\n" + "us with your Tax Id information click the icon\n" + "next to the county menu to download our tax form.\n\n" + "Email to orders@matcutter.com\n\n"); document.checkoutform.county_id.focus(); return false; } } return true; } function clearCountyMenu() { document.getElementById('countyLabel').innerHTML = ' '; document.getElementById('countyMenu').innerHTML = ' '; return true; } function setCounty(menuObject) { if (menuObject.value == "GA") { var countyMenu = ""; document.getElementById('countyLabel').innerHTML = 'County:'; document.getElementById('countyMenu').innerHTML = countyMenu + ''; } else { clearCountyMenu(); } } function setTaxIdField(menuObject) { if (menuObject.value == "GA") { document.getElementById("taxidField").style.display = "block"; } else { document.getElementById("taxidField").style.display = "none"; } } // get the global xmlreq object var http = createRequestObject(); function updateShippingMethod(selectObj, isForPaypal) { if (isForPaypal == "1") { document.step3form.action.value = 'reviewPaypal'; } else { document.step3form.action.value = 'Proceed To Step 3'; } //document.step3form.action.value = selectObj.value; document.step3form.submit(); } function setStepOneShipPrice(selectObj, formName) { // clear out previous options document.getElementById('shipping_price').innerHTML = ''; // make sure we have a shipping option selected if (selectObj.value == 0) { alert("You must select a shipping method."); selectObj.focus(); return false; } // make sure we have a zip code if (document.forms[0].ship_to_zip.value.length < 5) { alert("You must enter a valid zip code."); document.forms[0].ship_to_zip.select(); selectObj.selectedIndex = 0; return false; } // hand off to server to get value http.abort(); http.open('post', 'cart.php'); http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.onreadystatechange = function () { if (http.readyState == 4) { //Finished loading the response var response = http.responseText; document.getElementById('shipping_price').innerHTML = response; } }; http.send('action=getShippingPrice&shipping_method=' + selectObj.value + '&zip=' + document.forms[0].ship_to_zip.value); return false; }