var rows = new Array(); var cart_ttl; var cart_value; var mssg; var mssgValue; var mssgColour; var emailTextValue; var userP1TextValue; var userP2TextValue; var userP1Text; var userP2Text; var firstnameTextValue; var secondnameTextValue; var firstnameText; var secondnameText; var pmttype function initPage(loc){ if (document.getElementById("cartMessage")!= null){ mssg = document.getElementById("cartMessage"); mssgValue = mssg.firstChild.nodeValue; // mssgColour = mssg.getAttribute("color"); } if (document.getElementById("userWelcome")== null){ if (document.getElementById("checkout") != null){ document.getElementById("checkout").setAttribute('disabled', 'true'); document.getElementById("checkout").setAttribute('src', 'images/checkoutGhost.png'); document.getElementById("cartMessage").firstChild.nodeValue = "You must sign in or register before you can complete your order"; } } if (document.getElementById("firstAddress")!= null){ if (document.getElementById("checkout")!= null){ document.getElementById("checkout").setAttribute('disabled', 'true'); document.getElementById("checkout").setAttribute('src', 'images/checkoutGhost.png'); if (document.getElementById("userWelcome")!= null){ document.getElementById("cartMessage").firstChild.nodeValue = "You must set up an address before you can complete your order"; } } } getPaymentType(); if (loc != "") { location.hash = loc; } } function editRow(rownum, mode, event){ if (cart_ttl == null){ cart_ttl = document.getElementById("cartTotal"); cart_value = parseFloat(cart_ttl.firstChild.nodeValue); if (isNaN(cart_value)) {cart_value = 0.0;} } document.getElementById("saveCart").style.visibility = "visible"; document.getElementById("undoCart").style.visibility = "visible"; mssg.firstChild.nodeValue = "Save or Undo changes to recalculate delivery and final total"; // mssg.style.color="RED"; document.getElementById("cartDelivery").firstChild.nodeValue = ""; document.getElementById("cartFinalTotal").firstChild.nodeValue = ""; // document.getElementById("checkout").removeAttribute('disabled'); document.getElementById("checkout").setAttribute('disabled', 'true'); document.getElementById("checkout").setAttribute('src', 'images/checkoutGhost.png'); if(rows[rownum] == null) rows[rownum] = new item(rownum); if (mode == "CLICK"){ rows[rownum].switchState(); } if (mode == "CHANGE"){ rows[rownum].changeQuantity(event); } } function item(rownum){ // alert("new item"+rownum); this.rownum = rownum; this.state = 1; this.mfr = document.getElementById(rownum+"MFR"); this.item = document.getElementById(rownum+"ITM"); this.qty = document.getElementById(rownum+"QTY"); this.price = document.getElementById(rownum+"PRC"); this.size = document.getElementById(rownum+"SZE"); this.ttl = document.getElementById(rownum+"TTL"); this.img = document.getElementById(rownum+"IMG"); this.original_qty = parseInt(this.qty.value); this.current_qty = this.original_qty; this.original_total = parseFloat(this.ttl.firstChild.nodeValue); this.current_total = this.original_total; this.current_price = parseFloat(this.price.firstChild.nodeValue); this.switchState = switchState; this.changeQuantity = changeQuantity; } function switchState(){ if (this.state == 1){ this.state = 0; this.img.src = 'images/add.gif'; this.img.alt = "Replace item"; this.img.title = "Replace item"; this.size.style.textDecoration = "line-through"; this.price.style.textDecoration = "line-through"; this.mfr.style.textDecoration = "line-through"; this.item.style.textDecoration = "line-through"; this.ttl.style.textDecoration = "line-through"; this.qty.setAttribute('disabled', 'true'); // this.qty.value = 0; cart_value -= this.current_total; cart_ttl.firstChild.nodeValue = format_number(cart_value, 2); }else{ this.state = 1; this.img.src = 'images/remove.gif'; this.img.alt = "Remove item"; this.img.title = "Remove item"; this.size.style.textDecoration = "none"; this.price.style.textDecoration = "none"; this.mfr.style.textDecoration = "none"; this.item.style.textDecoration = "none"; this.ttl.style.textDecoration = "none"; this.qty.removeAttribute('disabled'); // this.qty.value = this.current_qty; cart_value += this.current_total; cart_ttl.firstChild.nodeValue = format_number(cart_value, 2); } } function changeQuantity(e){ // find out which event handling model the browser is using then retrieve the key stroke as appropriate var code; if (!e) var e = window.event; if (e.keyCode) code = e.keyCode; else if (e.which) code = e.which; var new_total; if ((code > 45 && code < 58) || code == 8 || code == 16 || code == 33 || code == 34){ this.current_qty = parseFloat(this.qty.value); new_total = this.current_qty * this.current_price; if (isNaN(new_total)) new_total = 0.0; cart_value = cart_value - this.current_total + new_total; this.current_total = new_total; this.ttl.firstChild.nodeValue = format_number(new_total, 2); cart_ttl.firstChild.nodeValue = format_number(cart_value, 2); }else{ this.qty.value = this.qty.value.substring(0,1); if (isNaN(parseFloat(this.qty.value))) { this.qty.value = 0; } this.current_qty = parseFloat(this.qty.value); new_total = this.current_qty * this.current_price; if (isNaN(new_total)) new_total = 0.0; cart_value = cart_value - this.current_total + new_total; this.current_total = new_total; this.ttl.firstChild.nodeValue = format_number(new_total, 2); cart_ttl.firstChild.nodeValue = format_number(cart_value, 2); } } function getPaymentType(){ if (document.getElementById("radioPaymentCcard")!= null){ pmttype = "NONE"; accepted = "Y"; pmtmssg = document.getElementById("paymentMessage"); if (document.getElementById("radioPaymentCcard").checked){ pmttype="CCARD"; pmtmssg.style.color="BLUE"; pmtmssg.firstChild.nodeValue = "You have chosen to pay by credit card. Click the confirm button to be transferred to the secure card payments page"; } if (document.getElementById("radioPaymentXfr").checked){ pmttype="XFR"; pmtmssg.style.color="BLUE"; pmtmssg.firstChild.nodeValue = "You have chosen to pay by bank transfer. Click the confirm button to see the payment instructions"; } // if (document.getElementById("radioPaymentCheque").checked){ // pmttype="CHEQUE"; // pmtmssg.style.color="BLUE"; // pmtmssg.firstChild.nodeValue = "You have chosen to pay by bank cheque. Click the confirm button to see the payment instructions"; // } // if (document.getElementById("radioPaymentCash").checked){ // pmttype="CASH"; // pmtmssg.style.color="BLUE"; // pmtmssg.firstChild.nodeValue = "You have chosen to pay by cash over the bank counter. Click the confirm button to see the payment instructions"; // } if (document.getElementById("OOCaccept")!= null){ if (!document.getElementById("OOCaccept").checked){ accepted = "N"; } } if (pmttype == "NONE" || accepted == "N") { document.getElementById("confirmCheckout").setAttribute('disabled', 'true'); document.getElementById("confirmCheckout").setAttribute('src', 'images/confirmGhost.png'); }else{ document.getElementById("confirmCheckout").removeAttribute('disabled'); document.getElementById("confirmCheckout").setAttribute('src', 'images/confirmMouseOut.png'); } } } function setMode(mode){ var hval = document.getElementById("cartFunction"); if (hval != null){ hval.value = mode; } return true; } function verifyRegistration(event){ regmssg = document.getElementById("registerMessage"); email = document.getElementById("registerEmail"); emailText = document.getElementById("registerEmailText"); if (emailTextValue == null) emailTextValue = emailText.firstChild.nodeValue; userP1 = document.getElementById("userP1"); userP1Text = document.getElementById("userP1Text"); if (userP1TextValue == null) userP1TextValue = userP1Text.firstChild.nodeValue; userP2 = document.getElementById("userP2"); userP2Text = document.getElementById("userP2Text"); if (userP2TextValue == null) userP2TextValue = userP2Text.firstChild.nodeValue; firstname = document.getElementById("firstName"); firstnameText = document.getElementById("firstnameText"); if (firstnameTextValue == null) firstnameTextValue = firstnameText.firstChild.nodeValue; secondname = document.getElementById("secondName"); secondnameText = document.getElementById("secondnameText"); if (secondnameTextValue == null) secondnameTextValue = secondnameText.firstChild.nodeValue; valid = true; emailOK = false; e1 = email.value.split("@"); if (e1[1]){ e2 = e1[1].split("."); if (e2[1]) emailOK = true; } if (!emailOK){ emailText.style.color="RED"; emailText.style.fontWeight ="bolder"; emailText.firstChild.nodeValue = "Email Address Invalid"; valid = false; }else{ emailText.style.color="BLUE"; emailText.style.fontWeight ="normal"; emailText.firstChild.nodeValue = emailTextValue; } if (userP1.value.length <5){ userP1Text.style.color="RED"; userP1Text.style.fontWeight ="bolder"; userP1Text.firstChild.nodeValue = "Password must be at least 5 characters"; valid = false; }else{ userP1Text.style.color="BLUE"; userP1Text.style.fontWeight ="normal"; userP1Text.firstChild.nodeValue = userP1TextValue; } if (userP2.value != userP1.value){ userP2Text.style.color="RED"; userP2Text.style.fontWeight ="bolder"; userP2Text.firstChild.nodeValue = "Please enter the same password twice"; valid = false; }else{ userP2Text.style.color="BLUE"; userP2Text.style.fontWeight ="normal"; userP2Text.firstChild.nodeValue = userP2TextValue; } if (firstname.value.length == 0){ firstnameText.style.color="RED"; firstnameText.style.fontWeight ="bolder"; valid = false; }else{ firstnameText.style.color="BLUE"; firstnameText.style.fontWeight ="normal"; } if (secondname.value.length == 0){ secondnameText.style.color="RED"; secondnameText.style.fontWeight ="bolder"; valid = false; }else{ secondnameText.style.color="BLUE"; secondnameText.style.fontWeight ="normal"; } return valid; } function verifyNewPassword(event){ userP1 = document.getElementById("userP1"); userP1Text = document.getElementById("userP1Text"); if (userP1TextValue == null) userP1TextValue = userP1Text.firstChild.nodeValue; userP2 = document.getElementById("userP2"); userP2Text = document.getElementById("userP2Text"); if (userP2TextValue == null) userP2TextValue = userP2Text.firstChild.nodeValue; valid = true; if (userP1.value.length <5){ userP1Text.style.color="RED"; userP1Text.style.fontWeight ="bolder"; userP1Text.firstChild.nodeValue = "Password must be at least 5 characters"; valid = false; }else{ userP1Text.style.color="BLUE"; userP1Text.style.fontWeight ="normal"; userP1Text.firstChild.nodeValue = userP1TextValue; } if (userP2.value != userP1.value){ userP2Text.style.color="RED"; userP2Text.style.fontWeight ="bolder"; userP2Text.firstChild.nodeValue = "Please enter the same password twice"; valid = false; }else{ userP2Text.style.color="BLUE"; userP2Text.style.fontWeight ="normal"; userP2Text.firstChild.nodeValue = userP2TextValue; } return valid; } function verifyEmail(event){ var email = document.getElementById("emailaddress"); var emailText = document.getElementById("emailText"); // var emailText = document.getElementById("registerEmailText"); if (emailTextValue == null) emailTextValue = emailText.firstChild.nodeValue; valid = true; emailOK = false; e1 = email.value.split("@"); if (e1[1]){ e2 = e1[1].split("."); if (e2[1]) emailOK = true; } if (!emailOK){ emailText.style.color="RED"; emailText.style.fontWeight ="bolder"; emailText.firstChild.nodeValue = "Email Address Invalid"; valid = false; }else{ emailText.style.color="BLUE"; emailText.style.fontWeight ="normal"; emailText.firstChild.nodeValue = emailTextValue; } return valid; } function format_number(pnumber,decimals){ if (isNaN(pnumber)) { return 0}; if (pnumber=='') { return 0}; var snum = new String(pnumber); var sec = snum.split('.'); var whole = parseFloat(sec[0]); var result = ''; if(sec.length > 1){ var dec = new String(sec[1]); dec = String(parseFloat(sec[1])/Math.pow(10,(dec.length - decimals))); dec = String(whole + Math.round(parseFloat(dec))/Math.pow(10,decimals)); var dot = dec.indexOf('.'); if(dot == -1){ dec += '.'; dot = dec.indexOf('.'); } while(dec.length <= dot + decimals) { dec += '0'; } result = dec; } else{ var dot; var dec = new String(whole); dec += '.'; dot = dec.indexOf('.'); while(dec.length <= dot + decimals) { dec += '0'; } result = dec; } if (pnumber >= -0.0001 && pnumber <= 0.0001) result = '0.00'; return result; } function showOverseasOrderConditions(){ window.open("shop04.php", "","width=600,height=300,toolbar=0,status=0"); } function showTellaFriend(param){ if (param == null){ window.open("shop05.php", "","width=580,height=640,toolbar=0,status=0,scrollbars=1"); }else{ window.open("shopping/shop05.php", "","width=580,height=640,toolbar=0,status=0,scrollbars=1"); } } function show10Reasons(param){ var url = "shopping/"; if (param == null){ url = ""; } url = url +"shop02.php"; window.open(url, "","width=580,height=480,toolbar=0,status=0,scrollbars=1"); } function showContact(param){ var url = "shopping/"; if (param == null){ url = ""; } url = url +"shop03.php"; window.open(url, "","width=720,height=660,toolbar=0,status=0,scrollbars=1"); } function showService(param){ var url = "shopping/"; if (param == null){ url = ""; } url = url +"shop06.php"; window.open(url, "","width=720,height=600,toolbar=0,status=0,scrollbars=1"); } function showHints(param){ var url = "shopping/"; if (param == null){ url = ""; } url = url +"shop08.php"; window.open(url, "","width=720,height=600,toolbar=0,status=0,scrollbars=1"); } function showBachConsultant(param){ var url = "shopping/"; if (param == null){ url = ""; } url = url +"shop11.php"; window.open(url, "","width=720,height=600,toolbar=0,status=0,scrollbars=1"); } function showBachExplanation(param){ var url = "shopping/"; if (param == null){ url = ""; } url = url +"shop12.php"; window.open(url, "","width=720,height=600,toolbar=0,status=0,scrollbars=1"); } function emailForm(param){ var url = "shopping/"; if (param == null){ url = ""; } url = url +"shop07.php"; window.open(url, "","width=720,height=480,toolbar=0,status=0,scrollbars=0"); } function askTheNaturopath(){ window.open("emailNaturopath.php", "","width=600,height=640,toolbar=0,status=0,scrollbars=0"); } function showNaturopath(){ window.open("naturopathInfo.php", "","width=600,height=640,toolbar=0,status=0,scrollbars=1"); } function showOwner(){ window.open("ownerInfo.php", "","width=600,height=640,toolbar=0,status=0,scrollbars=1"); } function openTrackWindow(trackno){ var h = "height = " + Math.round(window.innerHeight * 0.95); var w = "width = " + Math.round(window.innerWidth * 0.95); w="width = " +800; h="height = " +600; var features = w+","+h+",toolbar=0,status=0,scrollbars=1,resizable=1"; if (trackno == "Not Tracked.."){ url = "shop13.php"; }else{ url = "http://www.trackandtrace.courierpost.co.nz/search/"; url += trackno; } window.open(url, "",features); } function showDPS(){ var h = "height = " + Math.round(window.innerHeight * 0.95); var w = "width = " + Math.round(window.innerWidth * 0.95); w="width = " +800; h="height = " +600; var features = w+","+h+",toolbar=0,status=0,scrollbars=1,resizable=1"; var url = "http://www.paymentexpress.com"; window.open(url, "",features); } function showForgottenPassword(){ window.open("shop09.php", "","width=400,height=400,toolbar=0,status=0,scrollbars=0"); } function viewCart(){ location.hash = "viewCart"; } function checkoutConfirmation(){ return true; // return confirm('Have set the delivery address for your order\n\n and address?') ; } function ccardConfirmation(){ // pmt = "not found"; // if (document.getElementById("radioPayment")!= null){ // pmt = document.getElementById("radioPayment").value; // } // return val = confirm ("You will now be transferred to a secure page for "+pmt+" processing"); return true; } // google analytics script var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-17173013-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();