var newwindow = ''; function popup(url,name,stuff) { if (!newwindow.closed && newwindow.location) { newwindow.location.href = url; // we need to resize the window to our new image var argz = stuff.split(","); var w = argz[0]; var h = argz[1]; newwindow.resizeTo(w.substring((w.indexOf("=")+1)),h.substring((h.indexOf("=")+1))); } else { newwindow=window.open(url,name,stuff); if (!newwindow.opener) newwindow.opener = self; } if (window.focus) {newwindow.focus()} return false; } function warnShipping(theForm) { var eForm = theForm.form; var changeMe = new Array(); var shipstr = "Due to increasing amounts of Credit Card Fraud, we will now only ship to a shipping address if one of the following is true:\n\n"; var shipstr = shipstr + "- Your Shipping address is on file with the credit card company and will pass an AVS check\n"; var shipstr = shipstr + "- You have done business with us before where we've successfully shipped to a Billing address\n"; var shipstr = shipstr + "\n\nWe regret that we've had to resort to these strict rules, however it has become necessary."; var shipstr = shipstr + " Please call if you would like to discuss shipment options."; changeMe[0] = 'ship_st1'; changeMe[1] = 'ship_st2'; changeMe[2] = 'ship_city'; changeMe[3] = 'ship_state'; changeMe[4] = 'ship_zip'; changeMe[5] = 'ship_country'; changeMe[6] = 'ship_phone'; changeMe[7] = 'ship_name'; var pointer = changeMe[0]; // use this to get state of form var state = eForm.elements[pointer].disabled; if(state) { var newState = false; } else { var newState = true; } if(!newState) { // we're activating the form elements, show the confirm. var agree=confirm(shipstr); } else { // deactivating, they know.. var agree = true; } if(agree) { for(var i=0;i<8;i++) { var theEl = changeMe[i]; eForm.elements[theEl].disabled = newState; } } else { var chk = 'shipToBill'; eForm.elements[chk].checked = true; } } function passChange(theForm) { var eForm = theForm.form; var changeMe = new Array(); var str = "Password fields are now active. When you click save, your login password will be changed."; changeMe[0] = 'pass1'; changeMe[1] = 'pass2'; var pointer = changeMe[0]; // use this to get state of form var state = eForm.elements[pointer].disabled; if(state) { var newState = false; } else { var newState = true; } if(!newState) { // we're activating the form elements, show the confirm. var agree=confirm(str); } else { // deactivating, they know.. var agree = true; } if(agree) { for(var i=0;i<6;i++) { var theEl = changeMe[i]; eForm.elements[theEl].disabled = newState; } } else { var chk = 'shipToBill'; eForm.elements[chk].checked = true; } } // Email Validation. doc javascript rules // haxx0red by jay@hmsmotorsport.com function validEmail(str) { if (window.RegExp) { var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)"; var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"; var reg1 = new RegExp(reg1str); var reg2 = new RegExp(reg2str); if (!reg1.test(str) && reg2.test(str)) { return true; } else { return false; } } else { if(str.indexOf("@") >= 0) { return true; } else { return false; } } } function isEmail (s) { // there must be >= 1 character before @, so we // start looking at character position 1 // (i.e. second character) var i = 1; var sLength = s.length; // look for @ while ((i < sLength) && (s.charAt(i) != "@")) { i++ } if ((i >= sLength) || (s.charAt(i) != "@")) return false; else i += 2; // look for . while ((i < sLength) && (s.charAt(i) != ".")) { i++ } // there must be at least one character after the . if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false; else return true; } function trim(str) { // i can't believe js doesn't have a trim() function. i prolly just can't find it. while(''+str.charAt(0)==' ') { // take em off the front str=str.substring(1,str.length); } while(''+str.charAt(str.length-1)==' ') { // and the backside. str=str.substring(0,str.length-1); } return str; } function checkme(e) { e.checked = true; } function techDisclaimer() { var string = "HMS Provides the tech tip service to their customers with no warranty as to their validity and/or truth. "; string += "By posting a Tech Tip here, you are providing the community with information and it is your responsibility to be sure "; string += "that this information is legitimate.\n\n"; string += "Every post will be reviewed and approved at the discretion of HMS. We aim to approve almost all posts as we feel that "; string += "variety of opinion is a good thing. However we will edit and reject posts that are blatantly false and or contain misleading "; string += "information."; var state = confirm(string); return state; } function youAreNotLoggedIn() { var string = "You are trying to use a function that is only available to registered members.\n\n"; string += "Registration takes about 2 minutes and is very easy. For Information on our "; string += "privacy policy please visit our privacy statement on the information page of our website."; string += "\n\nTo be redirected to the signup area, select OK. If you want to continue shopping, click CANCEL"; var state = confirm(string); if(state) { window.location.href = "/myhms.php?page=profile"; } else { // do nothing; } } function checkMultiEmail(erp) { var field = "addresses"; var str = erp.elements[field].value; addys = str.split(","); var errorString = ""; for(var i=0;i12) { errors = true; errorString += "- There are only 12 Months in the year\n"; } } if(form.cvv2.value == "") { warnings = true; warningString += "Your CVV2 field is blank. If you do not enter this number, or it is incorrect, it will throw a flag with your Credit Card Company saying that there is suspicious activity. "; warningString += "Your order will still be processed successfully, however you may receive a phone call validating your order from the Credit Card Company. If you want to enter this number "; warningString += "press cancel and enter the number, otherwise click OK"; } if(errors) { alert(errorString); errors = false; errorString = ""; return false; } else if(warnings) { return confirm(warningString); } } function contactChecker(form) { var returnString = ""; var errors = false; if(form['dept'].value == "false") { returnString += "- You must select something from the drop down list, otherwise we won't know how to direct your comment.\n"; errors = true; } if(form['email'].value == "") { returnString += "- We need to know your email address, or we can't get back in touch with you.\n"; errors = true; } else { if(!isEmail(form['email'].value)) { returnString += "- Your Email address was invalid.\n"; errors = true; } } if(form['name'].value == "") { returnString += "- Please tell us your name.\n"; errors = true; } if(form['message'].value == "") { returnString += "- Your message was blank. Didn't you want to tell us something?\n"; errors = true; } if(errors) { var returnMe = "There were errors with the message you tried to submit:\n\n" + returnString; alert(returnMe); return false; } } // see, i can code javascript. // psyche, no i can't.. this guy's way better than me. // http://www.bobbyvandersluis.com/ // genius. function dynamicSelect(id1, id2) { // Feature test to see if there is enough W3C DOM support if (document.getElementById && document.getElementsByTagName) { // Obtain references to both select boxes var sel1 = document.getElementById(id1); var sel2 = document.getElementById(id2); // Clone the dynamic select box var clone = sel2.cloneNode(true); // Obtain references to all cloned options var clonedOptions = clone.getElementsByTagName("option"); // Onload init: call a generic function to display the related options in the dynamic select box refreshDynamicSelectOptions(sel1, sel2, clonedOptions); // Onchange of the main select box: call a generic function to display the related options in the dynamic select box sel1.onchange = function() { refreshDynamicSelectOptions(sel1, sel2, clonedOptions); }; } } function refreshDynamicSelectOptions(sel1, sel2, clonedOptions) { // Delete all options of the dynamic select box while (sel2.options.length) { sel2.remove(0); } // Create regular expression objects for "select" and the value of the selected option of the main select box as class names var pattern1 = /( |^)(select)( |$)/; var pattern2 = new RegExp("( |^)(" + sel1.options[sel1.selectedIndex].value + ")( |$)"); // Iterate through all cloned options for (var i = 0; i < clonedOptions.length; i++) { // If the classname of a cloned option either equals "select" or equals the value of the selected option of the main select box if (clonedOptions[i].className.match(pattern1) || clonedOptions[i].className.match(pattern2)) { // Clone the option from the hidden option pool and append it to the dynamic select box sel2.appendChild(clonedOptions[i].cloneNode(true)); } } } function updatePrice(partNum,storeID) { if (document.getElementById && document.getElementsByTagName) { var partNumber = partNum.value; var price = document.getElementById(partNumber).value; var priceDisplayFieldTagId = "price_" + storeID; var hiddenPriceFieldTagId = "purchasePrice_" + storeID; var hiddenPartNumFieldTagId = "partNum_" + storeID; var priceDisplayField = document.getElementById(priceDisplayFieldTagId); var hiddenPriceField = document.getElementById(hiddenPriceFieldTagId); var hiddenPartNumField = document.getElementById(hiddenPartNumFieldTagId); hiddenPriceField.value = price; hiddenPartNumField.value = partNumber; priceDisplayField.innerHTML = price; } } function checkDropCart(storeID,opt1,opt2) { var hiddenPartNumFieldTagId = "partNum_" + storeID; var hiddenPartNumField = document.getElementById(hiddenPartNumFieldTagId); if (hiddenPartNumField.value == "null") { alert("You Must select " + opt1 + " and " + opt2 +" before adding this item to your cart."); return false; } else { return true; } }