// JavaScript Document //START function submitMe(){ document.forms['sortFormProducts'].submit() } //END //START //function sChange(url){ //document.forms['serverChange'].setAttribute('action',url) //document.getElementById('serverChange').setAttribute('action',url) //document.forms['serverChange'].submit() //document.getElementById('serverChange').submit() //} //END //START function conEmpt(){ var answer = confirm("Are you sure you want to empty the shoping cart?") if (answer){ return true; } else{ return false; } } //END //START //Credit card number format validator //LUHN FORMULA //1. Double the value of alternating digits //2. Add the separate digits of all the products //3. Add the unaffected digits //4. Add the results and divide by 10 //5. The steps don't make sense on their own, so let's walk through an example. //Card Specific Conditions //Card Type Prefix Length //MasterCard 51-55 16 //VISA 4 13, 16 //American Express (AMEX) 34, 37 15 //Diners Club/Carte Blanche 300-305, 36, 38 14 //enRoute 2014, 2149 15 //Discover 6011 16 //JCB 3 16 //JCB 2131, 1800 15 function validateCc(){ //Gather and Modify Vars var ccNumber = document.forms['curForm'].elements['ccNumber'] var cardType = document.forms['curForm'].elements['cardType'].selectedIndex var ccLength=i=ccNumber.value.length-1 var v=0 var vB=0 //Loop through code for each number starting at the right hand end for (i=ccLength; i >= 0; i--){ var x = ccNumber.value.charAt(i); var currentChar = i+1 var currentCharInv = ccLength - i + 1 //convert to right to left reading order //1. Double the value of alternating digits / 2. Add the separate digits of all the products if(currentCharInv%2==0){//if current position has an even value var curVal = String(x * 2)//string needs to be defined as string object rather than literal string or chatAt() doesn't work hence syntax x * 2 also ensure x is a number var val0 = curVal.charAt(0) * 1 //converting text string to number var val1 = curVal.charAt(1) * 1 //converting text string to number var v = v + val0 + val1 } //3. Add the unaffected digits if(currentCharInv%2!=0){//if current position has an odd value x=x*1 //converting text string to number var vB = vB + x } }//End for loop //4. Add the results and divide by 10 var results = vB + v if(results%10==0){ var ccLength = ccLength + 1 //Card Type Prefix Length //MasterCard 51-55 16 //VISA 4 13, 16 //American Express (AMEX) 34, 37 15 //Diners Club/Carte Blanche 300-305, 36, 38 14 //Discover 6011 16 var char1 = ccNumber.value.charAt(0); var char2 = ccNumber.value.charAt(1); var char3 = ccNumber.value.charAt(2); var char4 = ccNumber.value.charAt(3); var relString1 = char1 var relString2 = char1 + char2 var relString3 = char1 + char2 + char3 var relString4 = char1 + char2 + char3 + char4 if(cardType==0){ //Master Card if(ccLength==16){ var ok = 1; }else{ var ok = 0; } if(relString2==51 || relString2==52 || relString2==53 || relString2==54 || relString2==55){ var ok = 1; }else{ var ok = 0; } } if(cardType==1){ //VISA if(ccLength==16 || ccLength==13){ var ok = 1; }else{ var ok = 0; } if(relString1==4){ var ok = 1; }else{ var ok = 0; } } if(cardType==2){ //American Express if(ccLength==15){ var ok = 1; }else{ var ok = 0; } if(relString2==34 || relString2==37){ var ok = 1; }else{ var ok = 0; } } if(cardType==3){ //Diners Club / Carte Blanche if(ccLength==14){ var ok = 1; }else{ var ok = 0; } if(relString3==300 || relString3==301 || relString3==302 || relString3==303 || relString3==304 || relString3==305 || relString2==36 || relString2==38){ var ok = 1; }else{ var ok = 0; } } if(cardType==4){ //Discover if(ccLength==16){ var ok = 1; }else{ var ok = 0; } if(relString4==6011){ var ok = 1; }else{ var ok = 0; } } if(ok==1){ return 1; }else{ return 0; } }else{ return 0; } } //END //START function getPayInfo(){ var payMethod = document.forms['curForm'].elements['chkOutPayMethod'] var chkPaymentTd = document.getElementById('chkPayment') /* Clear chkPaymentTd */ if ( chkPaymentTd.hasChildNodes() ){ while ( chkPaymentTd.childNodes.length >= 1 ){ chkPaymentTd.removeChild( chkPaymentTd.firstChild ); } } var paySpan = document.createElement('span') if(payMethod.selectedIndex==1){ paySpan.innerHTML = "

Once your order has been confirmed, you will be required to deposit the total amount including shipping into our nominated bank account, using the order number you are issued with as the reference.

More detailed instructions will be given on the next page.
" } if(payMethod.selectedIndex==2){ paySpan.innerHTML = "

Once your order has been confirmed you will be required to mail a cheque for the amount including shipping to us. Once your cheque has cleared your order will be mailed immediately.

More detailed instructions will be given on the next page.
" } if(payMethod.selectedIndex==3){ paySpan.innerHTML = "

Once your order has been confirmed you will be required to come into the shop and pay in person.

More detailed instructions will be given on the next page.
" } if(payMethod.selectedIndex==4){ paySpan.innerHTML = "
Card Type:
Card Holder's Name:
Card Number:
V-Code: Where's my V-Code?
Expiration Date: /
" } chkPaymentTd.appendChild( paySpan ) } //END //START function showDetails(id){ var itemDetailsDiv = document.getElementById( 'itemDetailsDivParent' + id ).firstChild if( itemDetailsDiv.style.visibility == "visible" ){ itemDetailsDiv.style.visibility = "hidden"; itemDetailsDiv.style.height = "1px"; itemDetailsDiv.style.overflow = "hidden"; }else{ itemDetailsDiv.style.visibility = "visible"; itemDetailsDiv.style.height = "auto"; itemDetailsDiv.style.overflow = "visible"; } } //END //START function otherbox(target,name,fname,selectTrigger,defaultValue){ var target=document.getElementById(target) if(document.forms[fname].elements[selectTrigger].selectedIndex==18){ if( typeof document.forms[fname].elements[name] == "undefined" ){ var otherInput = document.createElement('span') otherInput.innerHTML=""; target.appendChild( otherInput ) } }else{ if(typeof target != "undefined"){ if ( target.hasChildNodes() ){ while ( target.childNodes.length >= 1 ){ target.removeChild( target.firstChild ); } } } } } //END //START function billShipView(){ var countries = new Array() countries[0] = "Please Select a Country"; countries[1] = "Afghanistan"; countries[2] = "Albania"; countries[3] = "Algeria"; countries[4] = "American Samoa"; countries[5] = "Andorra"; countries[6] = "Angola"; countries[7] = "Anguilla"; countries[8] = "Antarctica"; countries[9] = "Antigua And Barbuda"; countries[10] = "Argentina"; countries[11] = "Armenia"; countries[12] = "Aruba"; countries[13] = "Australia"; countries[14] = "Austria"; countries[15] = "Azerbaijan"; countries[16] = "Bahamas"; countries[17] = "Bahrain"; countries[18] = "Bangladesh"; countries[19] = "Barbados"; countries[20] = "Belarus"; countries[21] = "Belgium"; countries[22] = "Belize"; countries[23] = "Benin"; countries[24] = "Bermuda"; countries[25] = "Bhutan"; countries[26] = "Bolivia"; countries[27] = "Bosnia And Herzegowina"; countries[28] = "Botswana"; countries[29] = "Bouvet Island"; countries[30] = "Brazil"; countries[31] = "British Indian Ocean Territory"; countries[32] = "Brunei Darussalam"; countries[33] = "Bulgaria"; countries[34] = "Burkina Faso"; countries[35] = "Burundi"; countries[36] = "Cambodia"; countries[37] = "Cameroon"; countries[38] = "Canada"; countries[39] = "Cape Verde"; countries[40] = "Cayman Islands"; countries[41] = "Central African Republic"; countries[42] = "Chad"; countries[43] = "Chile"; countries[44] = "China"; countries[45] = "Christmas Island"; countries[46] = "Cocos (Keeling) Islands"; countries[47] = "Colombia"; countries[48] = "Comoros"; countries[49] = "Congo"; countries[50] = "Cook Islands"; countries[51] = "Costa Rica"; countries[52] = "Cote D'Ivoire"; countries[53] = "Croatia (Local Name: Hrvatska)"; countries[54] = "Cuba"; countries[55] = "Cyprus"; countries[56] = "Czech Republic"; countries[57] = "Denmark"; countries[58] = "Djibouti"; countries[59] = "Dominica"; countries[60] = "Dominican Republic"; countries[61] = "East Timor"; countries[62] = "Ecuador"; countries[63] = "Egypt"; countries[64] = "El Salvador"; countries[65] = "Equatorial Guinea"; countries[66] = "Eritrea"; countries[67] = "Estonia"; countries[68] = "Ethiopia"; countries[69] = "Falkland Islands (Malvinas)"; countries[70] = "Faroe Islands"; countries[71] = "Fiji"; countries[72] = "Finland"; countries[73] = "France"; countries[74] = "French Guiana"; countries[75] = "French Polynesia"; countries[76] = "French Southern Territories"; countries[77] = "Gabon"; countries[78] = "Gambia"; countries[79] = "Georgia"; countries[80] = "Germany"; countries[81] = "Ghana"; countries[82] = "Gibraltar"; countries[83] = "Greece"; countries[84] = "Greenland"; countries[85] = "Grenada"; countries[86] = "Guadeloupe"; countries[87] = "Guam"; countries[88] = "Guatemala"; countries[89] = "Guinea"; countries[90] = "Guinea-Bissau"; countries[91] = "Guyana"; countries[92] = "Haiti"; countries[93] = "Heard And Mc Donald Islands"; countries[94] = "Holy See (Vatican City State)"; countries[95] = "Honduras"; countries[96] = "Hong Kong"; countries[97] = "Hungary"; countries[98] = "Icel And"; countries[99] = "India"; countries[100] = "Indonesia"; countries[101] = "Iran (Islamic Republic Of)"; countries[102] = "Iraq"; countries[103] = "Ireland"; countries[104] = "Israel"; countries[105] = "Italy"; countries[106] = "Jamaica"; countries[107] = "Japan"; countries[108] = "Jordan"; countries[109] = "Kazakhstan"; countries[110] = "Kenya"; countries[111] = "Kiribati"; countries[112] = "Korea, Dem People'S Republic"; countries[113] = "Korea, Republic Of"; countries[114] = "Kuwait"; countries[115] = "Kyrgyzstan"; countries[116] = "Lao People'S Dem Republic"; countries[117] = "Latvia"; countries[118] = "Lebanon"; countries[119] = "Lesotho"; countries[120] = "Liberia"; countries[121] = "Libyan Arab Jamahiriya"; countries[122] = "Liechtenstein"; countries[123] = "Lithuania"; countries[124] = "Luxembourg"; countries[125] = "Macau"; countries[126] = "Macedonia"; countries[127] = "Madagascar"; countries[128] = "Malawi"; countries[129] = "Malaysia"; countries[130] = "Maldives"; countries[131] = "Mali"; countries[132] = "Malta"; countries[133] = "Marshall Islands"; countries[134] = "Martinique"; countries[135] = "Mauritania"; countries[136] = "Mauritius"; countries[137] = "Mayotte"; countries[138] = "Mexico"; countries[139] = "Micronesia, Federated States"; countries[140] = "Moldova, Republic Of"; countries[141] = "Monaco"; countries[142] = "Mongolia"; countries[143] = "Montserrat"; countries[144] = "Morocco"; countries[145] = "Mozambique"; countries[146] = "Myanmar"; countries[147] = "Namibia"; countries[148] = "Nauru"; countries[149] = "Nepal"; countries[150] = "Netherlands"; countries[151] = "Netherlands Ant Illes"; countries[152] = "New Caledonia"; countries[153] = "New Zealand"; countries[154] = "Nicaragua"; countries[155] = "Niger"; countries[156] = "Nigeria"; countries[157] = "Niue"; countries[158] = "Norfolk Island"; countries[159] = "Northern Mariana Islands"; countries[160] = "Norway"; countries[161] = "Oman"; countries[162] = "Pakistan"; countries[163] = "Palau"; countries[164] = "Panama"; countries[165] = "Papua New Guinea"; countries[166] = "Paraguay"; countries[167] = "Peru"; countries[168] = "Philippines"; countries[169] = "Pitcairn"; countries[170] = "Poland"; countries[171] = "Portugal"; countries[172] = "Puerto Rico"; countries[173] = "Qatar"; countries[174] = "Reunion"; countries[175] = "Romania"; countries[176] = "Russian Federation"; countries[177] = "Rwanda"; countries[178] = "Saint K Itts And Nevis"; countries[179] = "Saint Lucia"; countries[180] = "Saint Vincent, The Grenadines"; countries[181] = "Samoa"; countries[182] = "San Marino"; countries[183] = "Sao Tome And Principe"; countries[184] = "Saudi Arabia"; countries[185] = "Senegal"; countries[186] = "Seychelles"; countries[187] = "Sierra Leone"; countries[188] = "Singapore"; countries[189] = "Slovakia (Slovak Republic)"; countries[190] = "Slovenia"; countries[191] = "Solomon Islands"; countries[192] = "Somalia"; countries[193] = "South Africa"; countries[194] = "South Georgia , S Sandwich Is."; countries[195] = "Spain"; countries[196] = "Sri Lanka"; countries[197] = "St. Helena"; countries[198] = "St. Pierre And Miquelon"; countries[199] = "Sudan"; countries[200] = "Suriname"; countries[201] = "Svalbard, Jan Mayen Islands"; countries[202] = "Sw Aziland"; countries[203] = "Sweden"; countries[204] = "Switzerland"; countries[205] = "Syrian Arab Republic"; countries[206] = "Taiwan"; countries[207] = "Tajikistan"; countries[208] = "Tanzania, United Republic Of"; countries[209] = "Thailand"; countries[210] = "Togo"; countries[211] = "Tokelau"; countries[212] = "Tonga"; countries[213] = "Trinidad And Tobago"; countries[214] = "Tunisia"; countries[215] = "Turkey"; countries[216] = "Turkmenistan"; countries[217] = "Turks And Caicos Islands"; countries[218] = "Tuvalu"; countries[219] = "Uganda"; countries[220] = "Ukraine"; countries[221] = "United Arab Emirates"; countries[222] = "United Kingdom"; countries[223] = "United States"; countries[224] = "United States Minor Is."; countries[225] = "Uruguay"; countries[226] = "Uzbekistan"; countries[227] = "Vanuatu"; countries[228] = "Venezuela"; countries[229] = "Viet Nam"; countries[230] = "Virgin Islands (British)"; countries[231] = "Virgin Islands (U.S.)"; countries[232] = "Wallis And Futuna Islands"; countries[233] = "Western Sahara"; countries[234] = "Yemen"; countries[235] = "Yugoslavia"; countries[236] = "Zaire"; countries[237] = "Zambia"; countries[238] = "Zimbabwe"; var countryArrLength = 238; var details = new Array() details[0]='chkOutName1Bill'; details[1]='chkOutName2Bill'; details[2]='chkOutCompanyBill'; details[3]='chkOutStreetAddressBill'; details[4]='chkOutSuburbBill'; details[5]='chkOutCityBill'; details[6]='chkOutStBill'; details[7]='chkOutPostCodeBill'; details[8]='chkOutCountryBill'; var values = new Array() values[0]=''; values[1]=''; values[2]=''; values[3]=''; values[4]=''; values[5]=''; values[6]=''; values[7]=''; values[8]=''; var valuesBill = new Array() valuesBill[0]=''; valuesBill[1]=''; valuesBill[2]=''; valuesBill[3]=''; valuesBill[4]=''; valuesBill[5]=''; valuesBill[6]=''; valuesBill[7]=''; valuesBill[8]=''; var i=0 while(i <= 8){ var curParentName = details[i] + "Td" var curParent = document.getElementById(curParentName) if ( curParent.hasChildNodes() ){ while ( curParent.childNodes.length >= 1 ){ curParent.removeChild( curParent.firstChild ); } } i++ } if(document.forms['curForm'].elements['billShipSame'].checked==1){ //shipping + billing = same var i=0 while(i <= 7){ var curParentName = details[i] + "Td" var curParent = document.getElementById(curParentName) var curElemDesc = document.createElement('span') curElemDesc.innerHTML = values[i] curParent.appendChild(curElemDesc) var curElem = document.createElement('input') curElem.setAttribute('type','hidden') curElem.setAttribute('name',details[i]) curElem.setAttribute('id',details[i]) curElem.setAttribute('value',values[i]) curParent.appendChild(curElem) i++ } var curParentName = details[i] + "Td" var curParent = document.getElementById(curParentName) var curElemDesc = document.createElement('span') curElemDesc.innerHTML = values[8] curParent.appendChild(curElemDesc) var curElem = document.createElement('input') curElem.setAttribute('type','hidden') curElem.setAttribute('name',details[8]) curElem.setAttribute('id',details[8]) curElem.setAttribute('value',values[8]) curParent.appendChild(curElem) }else{ //shipping + billing = different var i=0 while(i <= 7){ var curParentName = details[i] + "Td" var curParent = document.getElementById(curParentName) if(i==6){ var curElem = document.createElement('span') var x = ""; x+=""; x+="
"; curElem.innerHTML = x; curParent.appendChild(curElem) var curElem = document.createElement('span') curElem.setAttribute('id','otherTarget') curParent.appendChild(curElem) otherbox('otherTarget','chkOutStOtherBill','curForm','chkOutStBill','') }else{ var curElem = document.createElement('input') curElem.setAttribute('type','text') curElem.setAttribute('name',details[i]) curElem.setAttribute('id',details[i]) curElem.setAttribute('value',valuesBill[i]) curParent.appendChild(curElem) } i++ } var curParentName = details[8] + "Td" var curParent = document.getElementById(curParentName) var curElem = document.createElement('select') curElem.setAttribute('name',details[8]) curElem.setAttribute('id',details[8]) curElem.selectedIndex = values[8] curParent.appendChild(curElem) var curParent = document.getElementById(details[8]) var i=0 while(i <= countryArrLength){ var curElem = document.createElement('option') if(countries[i] == valuesBill[8]){ curElem.setAttribute('selected','selected') } curElem.innerHTML = countries[i] curParent.appendChild(curElem) i++ } } } //END //START function showSubCats(currentSubCatId){ /* Vars */ var filtSelect = document.forms["filterFormProducts"].elements["productsFilter"] var filtSubSelect = document.forms["filterFormProducts"].elements["productsSubFilter"] var xtraSelect = document.getElementById('xtraSelect'); /* Clear Xtra Select Span */ if ( xtraSelect.hasChildNodes() ){ while ( xtraSelect.childNodes.length >= 1 ){ xtraSelect.removeChild( xtraSelect.firstChild ); } } /* If manufacturer is selected... */ if(filtSelect.selectedIndex==2){ var SubCatFiltOn = document.createElement('input'); SubCatFiltOn.setAttribute('name','subCatFiltOn'); SubCatFiltOn.setAttribute('type','hidden'); SubCatFiltOn.setAttribute('value','0'); xtraSelect.appendChild( SubCatFiltOn ); } /* If Category is selected... */ if(filtSelect.selectedIndex==1){ /* generate New Selectah and set other page vars */ var SubCatFiltOn = document.createElement('input'); SubCatFiltOn.setAttribute('name','subCatFiltOn'); SubCatFiltOn.setAttribute('type','hidden'); SubCatFiltOn.setAttribute('value','1'); xtraSelect.appendChild( SubCatFiltOn ); var subCatDesc = document.createElement('span'); subCatDesc.innerHTML = 'Sub-Cat: ' xtraSelect.appendChild( subCatDesc ); var newSelectSpan = document.createElement('span'); newSelectSpan.innerHTML=""; xtraSelect.appendChild( newSelectSpan ); var newSelectah = document.forms['filterFormProducts'].elements['productsSubCatFilter']; /* If Category is selected and current selection = Please select: spit first option: 'Select a category first' */ if(filtSubSelect.selectedIndex == 0){ var newOption = document.createElement('option'); newOption.innerHTML = 'Select a category first' newOption.setAttribute('value',''); newSelectah.appendChild( newOption ); /* If Category is selected and current selection = actual entry: spit first option: 'Select selectedSubCatParentName Sub-Cat' */ }else{ var selectedSubCatParentName = cats[filtSubSelect.selectedIndex][2] var newOption = document.createElement('option'); newOption.innerHTML = 'Select ' + selectedSubCatParentName + ' Sub-Cat' newOption.setAttribute('value',''); newSelectah.appendChild( newOption ); var selectedSubCatParentName = cats[filtSubSelect.selectedIndex][2] var newOption = document.createElement('option'); newOption.innerHTML = 'All Sub-Cats' newOption.setAttribute('value','all'); if(currentSubCatId == 'all'){newOption.setAttribute('selected','selected');} newSelectah.appendChild( newOption ); /* Get Selected Cat Id and get sub cat entries with correspoding parent ids then spit them as options */ i=0 while(i <= intPreIncrement){ /* cats array should be organised in the same way as the select drop box meaning the selected index should correspond to entry number in the cats array */ var subParentId = sub_cats[i][4] var subCatName = sub_cats[i][2] var subCatId = sub_cats[i][1] var selectedSubCatParentId = cats[filtSubSelect.selectedIndex][1] if(subParentId == selectedSubCatParentId){ var newOption = document.createElement('option'); newOption.innerHTML = subCatName newOption.setAttribute('value',subCatId); if(currentSubCatId == subCatId){ newOption.setAttribute('selected','selected'); } newSelectah.appendChild( newOption ); } i++ } var newOption = document.createElement('option'); newOption.innerHTML = 'Miscellaneous' newOption.setAttribute('value',''); if(currentSubCatId == '' || currentSubCatId == null){newOption.setAttribute('selected','selected');} newSelectah.appendChild( newOption ); } } /* if the current filter is either 'no filter' or 'manufacturer' fill the space left by no drop down */ if(filtSelect.selectedIndex!=1){ var spaceFilla = document.createElement('span'); spaceFilla.innerHTML = 'Select from "filter by" menu first.'; spaceFilla.setAttribute('id','spaceFilla') xtraSelect.appendChild( spaceFilla ); var SubCatFiltOn = document.createElement('input'); SubCatFiltOn.setAttribute('name','subCatFiltOn'); SubCatFiltOn.setAttribute('type','hidden'); SubCatFiltOn.setAttribute('value',''); xtraSelect.appendChild( SubCatFiltOn ); var productsSubCatFilter = document.createElement('input'); productsSubCatFilter.setAttribute('name','productsSubCatFilter'); productsSubCatFilter.setAttribute('type','hidden'); productsSubCatFilter.setAttribute('value',''); xtraSelect.appendChild( productsSubCatFilter ); } } //END //START function emptyConfirmation() { var answer = confirm("Are you sure you want to empty the shoping cart?") if (answer){ document.forms['emptyCart'].submit() } else{} } //END //START function removeConfirmation() { var answer = confirm("Are you sure you want to remove this item?") if (answer){ document.forms['removeCart'].submit() } else{} } //END //START function menuOn(obj){ obj.style.backgroundImage='url(imgs/buttonOn.gif)' obj.style.color='#550000' obj.firstChild.style.color='#550000' } //END //START function menuOut(obj){ obj.style.backgroundImage='url(imgs/buttonOff.gif)' obj.style.color='#ffffff' obj.firstChild.style.color='#ffffff' } //END //START function getChildEntriesA(currentSubCatId){ var filterSelect = document.forms["filterFormProducts"].elements["productsFilter"] var filtSubSelect = document.forms["filterFormProducts"].elements["productsSubFilter"] var preViewed = document.forms["filterFormProducts"].elements["preViewed"] if(preViewed.value==1){ filtSubSelect.selectedIndex=0 } submitFormA(currentSubCatId) if ( filtSubSelect.hasChildNodes() ) { while ( filtSubSelect.childNodes.length >= 1 ) { filtSubSelect.removeChild( filtSubSelect.firstChild ); } } if(filterSelect.selectedIndex==0){ //Default var filtSubSelect_content = document.createElement('option'); filtSubSelect_content.setAttribute('value',''); filtSubSelect_content.innerHTML = "Select Filter Type First"; filtSubSelect.appendChild( filtSubSelect_content ); if(filterOn >= 1){ document.forms['filterFormProducts'].submit() } } if(filterSelect.selectedIndex==1){ //Categories var filtSubSelect_content = document.createElement('option'); filtSubSelect_content.setAttribute('value',''); filtSubSelect_content.innerHTML = "Please Select"; //if the current page comes from a previously unfiltered page or manufacturers so "please select" is selected if (filterOn==0 || filterOn==2){ filtSubSelect_content.setAttribute('selected','selected'); } filtSubSelect.appendChild( filtSubSelect_content ); var i=1 while (i<=intPreIncrementB){ var filtSubSelect_content = document.createElement('option'); //if the current page comes from a page filtered by category so relevant cat is selected if (filterOn==1){ if(currentSubItem==cats[i][1]){ filtSubSelect_content.setAttribute('selected','selected'); } } filtSubSelect_content.setAttribute('value',cats[i][1]); filtSubSelect_content.innerHTML = cats[i][2]; filtSubSelect.appendChild( filtSubSelect_content ); i=i+1 } } if(filterSelect.selectedIndex==2){ //Manufacturers //set Default var filtSubSelect_content = document.createElement('option'); filtSubSelect_content.setAttribute('value',''); filtSubSelect_content.innerHTML = "Please Select"; //if the current page comes from a previously unfiltered page or categories so "please select" is selected if (filterOn==0 || filterOn==1){ filtSubSelect_content.setAttribute('selected','selected'); } //append filtSubSelect.appendChild( filtSubSelect_content ); //iterate through manufacturers var i=0 while (i<=intPreIncrementC){ //each loop make a new option element var filtSubSelect_content = document.createElement('option'); filtSubSelect_content.setAttribute('value',manufacturers[i][1]); filtSubSelect_content.innerHTML = manufacturers[i][2]; //if the current page comes from a page filtered by manufacturer then that manufacturer is selected if (filterOn==2){ if(currentSubItem==manufacturers[i][1]){ filtSubSelect_content.setAttribute('selected','selected'); } } //append filtSubSelect.appendChild( filtSubSelect_content ); i=i+1 } } preViewed.setAttribute('value', 1) } //END //START function submitFormA(currentSubCatId){ //may need to get getChildEntriesA(currentSubCatId) to write to an hidden input to tell the script wheather or not there has been a previous view => reset the dropdown selectedIndex=0 var filtSubSelect = document.forms["filterFormProducts"].elements["productsSubFilter"] var filtSelect = document.forms["filterFormProducts"].elements["productsFilter"] if(filtSelect.selectedIndex==2 && filtSubSelect.selectedIndex!=0){ document.forms['filterFormProducts'].submit() } if(filtSelect.selectedIndex==1){ showSubCats(currentSubCatId) } if(filtSubSelect.selectedIndex==0){ showSubCats(currentSubCatId) } } //END //START function submitFormB(){ if(document.getElementById("productsSubCatFilter").selectedIndex==0){ }else{ document.getElementById('filterFormProducts').submit() } } //END //START /* Input restricter v2 */ //onkeypress="return restrict(event,name1);" //Illegal characters var emailExpr = /[=+!#$%\^&;:*()_\\|{}\[\]?<>\"~`�����������������������������]/ var alpha1 = /[0-9=+!@#$%\^&;:*()_\\|{}\[\]?\/.,<>\"\'~`�����������������������������-]/ var name1 = /[0-9=+!@#$%\^&;:*()_\\|{}\[\]?\/.,<>\"~`�����������������������������]/ var nameC = /[=+!@#$%\^&;:*()_\\|{}\[\]?\/,<>\"~`�����������������������������]/ var address1 = /[=+!@#$%\^&;:*()_\\|{}\[\]?<>\"~`�����������������������������]/ var number1 = /[a-zA-Z=+!@#$%\^&;:*()_\\|{}\[\]?\/.,<>\"\'~`�����������������������������-]/ var price1 = /[a-zA-Z=+!@#$%\^&;:*()_\\|{}\[\]?\/,<>\"\'~`�����������������������������-]/ function restrict(e,v){ var keynum var keychar if(window.event){// IE keynum = e.keyCode }else if(e.which){// Netscape/Firefox/Opera keynum = e.which } keychar = String.fromCharCode(keynum) return !v.test(keychar) } //END //START function batchShip(itemShipId){ if(document.forms['curForm'].elements['groupShip'][3].checked==false){ //if "I want to choose different options for each product" ISN'T selected -> Find Selection var i=0 while(i<=3){ if(document.forms['curForm'].elements['groupShip'][i].checked==true){ var shipSelected = i; } i++; }//end find selection //set selection of child radios to groupShip radio + disable all child radios var i=0 while(i < itemShipId.length){ var currentRadioGroup = document.forms['curForm'].elements['itemShip' + itemShipId[i][1]] var i2=0 while(i2 < currentRadioGroup.length){ if(i2==shipSelected){ currentRadioGroup[i2].checked=true; }else{ currentRadioGroup[i2].checked=false; } currentRadioGroup[i2].disabled=true; i2++; }//end set selection i++; }//end i while 2 }else{ //if "I want to choose different options for each product" IS selected // enable all child radios var i=0 while(i < itemShipId.length){ var currentRadioGroup = document.forms['curForm'].elements['itemShip' + itemShipId[i][1]] var i2 = 0 while(i2 < currentRadioGroup.length){ currentRadioGroup[i2].disabled = false; i2++ } i++; }//end enable all child radios }//end if else }//end function //END //START function validate(step){ if(step=='1L'){ var f0 = fieldValidate(document.forms['curFormL'].elements['chkOutEmail'],"Email Address"); var f1 = fieldValidate(document.forms['curFormL'].elements['chkOutPw'],"Pass Phrase"); //Check if email is in valid format if(f0==1){ var validEmail = validate_email( document.forms['curFormL'].elements['chkOutEmail'].value ); if(validEmail==0){ document.forms['curFormL'].elements['chkOutEmail'].style.backgroundColor="#ffaaaa"; alert('Email Address is Invalid'); }else{ document.forms['curFormL'].elements['chkOutEmail'].style.backgroundColor="#ffffff"; } } if(f0==0 || f1==0 || validEmail==0){ return false; }else{ return true; } } if(step=='1LQ'){ var f0 = fieldValidate(document.forms['curFormLQ'].elements['chkOutEmail'],"Email Address"); var f1 = fieldValidate(document.forms['curFormLQ'].elements['chkOutPw'],"Pass Phrase"); //Check if email is in valid format if(f0==1){ var validEmail = validate_email( document.forms['curFormLQ'].elements['chkOutEmail'].value ); if(validEmail==0){ document.forms['curFormLQ'].elements['chkOutEmail'].style.backgroundColor="#ffaaaa"; alert('Email Address is Invalid'); }else{ document.forms['curFormLQ'].elements['chkOutEmail'].style.backgroundColor="#ffffff"; } } if(f0==0 || f1==0 || validEmail==0){ return false; }else{ return true; } } if(step=='1N'){ var f0 = fieldValidate(document.forms['curFormN'].elements['chkOutEmail'],"Email Address"); var f0b = fieldValidate(document.forms['curFormN'].elements['chkOutEmail_conf'],"Email Address Confirmation"); //Check that email fields match if(f0==1 && f0b==1){ if(document.forms['curFormN'].elements['chkOutEmail'].value == document.forms['curFormN'].elements['chkOutEmail_conf'].value){ var validCombo_e = 1 document.forms['curFormN'].elements['chkOutEmail'].style.backgroundColor="#ffffff"; document.forms['curFormN'].elements['chkOutEmail_conf'].style.backgroundColor="#ffffff"; }else{ var validCombo_e = 0 document.forms['curFormN'].elements['chkOutEmail'].style.backgroundColor="#ffaaaa"; document.forms['curFormN'].elements['chkOutEmail_conf'].style.backgroundColor="#ffaaaa"; alert('Email Addresses do not match'); } } //Check if email is in valid format if(f0==1){ var validEmail = validate_email( document.forms['curFormN'].elements['chkOutEmail'].value ); if(validEmail==0){ document.forms['curFormN'].elements['chkOutEmail'].style.backgroundColor="#ffaaaa"; alert('Email Address is Invalid'); }else{ document.forms['curFormN'].elements['chkOutEmail'].style.backgroundColor="#ffffff"; } } if(f0==0 || f0b==0 || validEmail==0 || validCombo_e==0){ return false; }else{ return true; } } if(step=='1R'){ var f0 = fieldValidate(document.forms['curFormR'].elements['chkOutEmail'],"Email Address"); var f0b = fieldValidate(document.forms['curFormR'].elements['chkOutEmail_conf'],"Email Address Confirmation"); var f1 = fieldValidate(document.forms['curFormR'].elements['chkOutPw'],"Pass Phrase"); var f2 = fieldValidate(document.forms['curFormR'].elements['chkOutPw2'],"Pass Phrase Again"); //Check that password fields match if(f1==1 && f2==1){ if(document.forms['curFormR'].elements['chkOutPw2'].value == document.forms['curFormR'].elements['chkOutPw'].value){ var validCombo = 1 document.forms['curFormR'].elements['chkOutPw'].style.backgroundColor="#ffffff"; document.forms['curFormR'].elements['chkOutPw2'].style.backgroundColor="#ffffff"; }else{ var validCombo = 0 document.forms['curFormR'].elements['chkOutPw'].style.backgroundColor="#ffaaaa"; document.forms['curFormR'].elements['chkOutPw2'].style.backgroundColor="#ffaaaa"; alert('Pass phrases do not match'); } } //Check that email fields match if(f0==1 && f0b==1){ if(document.forms['curFormR'].elements['chkOutEmail'].value == document.forms['curFormR'].elements['chkOutEmail_conf'].value){ var validCombo_e = 1 document.forms['curFormR'].elements['chkOutEmail'].style.backgroundColor="#ffffff"; document.forms['curFormR'].elements['chkOutEmail_conf'].style.backgroundColor="#ffffff"; }else{ var validCombo_e = 0 document.forms['curFormR'].elements['chkOutEmail'].style.backgroundColor="#ffaaaa"; document.forms['curFormR'].elements['chkOutEmail_conf'].style.backgroundColor="#ffaaaa"; alert('Email Addresses do not match'); } } //Check if email is in valid format if(f0==1){ var validEmail = validate_email( document.forms['curFormR'].elements['chkOutEmail'].value ); if(validEmail==0){ document.forms['curFormR'].elements['chkOutEmail'].style.backgroundColor="#ffaaaa"; alert('Email Address is Invalid'); }else{ document.forms['curFormR'].elements['chkOutEmail'].style.backgroundColor="#ffffff"; } } if(f0==0 || f0b==0 || f1==0 || f2==0 || validEmail==0 || validCombo==0 || validCombo_e==0){ return false; }else{ return true; } } if(step=='1U'){ var f0 = fieldValidate(document.forms['curFormN'].elements['chkOutEmail'],"Email Address"); //Check if email is in valid format if(f0==1){ var validEmail = validate_email( document.forms['curFormN'].elements['chkOutEmail'].value ); if(validEmail==0){ document.forms['curFormN'].elements['chkOutEmail'].style.backgroundColor="#ffaaaa"; alert('Email Address is Invalid'); }else{ document.forms['curFormN'].elements['chkOutEmail'].style.backgroundColor="#ffffff"; } } if(f0==0 || validEmail==0){ return false; }else{ return true; } } if(step==2){ //Shipping Details var f1 = fieldValidate(document.forms['curForm'].elements['chkOutName1'],"First Name"); var f2 = fieldValidate(document.forms['curForm'].elements['chkOutName2'],"Last Name"); //var f3 = fieldValidate(document.forms['curForm'].elements['chkOutCompany'],"Company Name"); var f4 = fieldValidate(document.forms['curForm'].elements['chkOutStreetAddress'],"Street Address"); // var f5 = fieldValidate(document.forms['curForm'].elements['chkOutSuburb'],"Suburb"); var f6 = fieldValidate(document.forms['curForm'].elements['chkOutCity'],"City"); var f7 = fieldValidate(document.forms['curForm'].elements['chkOutSt'],"State / Province"); var f8 = fieldValidate(document.forms['curForm'].elements['chkOutPostCode'],"Post Code"); var f9 = fieldValidate(document.forms['curForm'].elements['chkOutCountry'],"Country"); //if other box is present replace f7 var with other box validation result if(document.forms['curForm'].elements['chkOutSt'].selectedIndex==18){ var f7 = fieldValidate(document.forms['curForm'].elements['chkOutStOther'],"State / Province"); } //Check that country and state / province are congruent. chkOutSt[18]=other & chkOutCountry[153]=NZ if(f7==1 && f9==1){ if( (document.forms['curForm'].elements['chkOutSt'].selectedIndex==18 && document.forms['curForm'].elements['chkOutCountry'].selectedIndex==153) || (document.forms['curForm'].elements['chkOutSt'].selectedIndex!=18 && document.forms['curForm'].elements['chkOutCountry'].selectedIndex!=153) ){ var f10 = 0 alert('Invalid Country / Province Combination'); document.forms['curForm'].elements['chkOutSt'].style.backgroundColor="#ffaaaa"; document.forms['curForm'].elements['chkOutCountry'].style.backgroundColor="#ffaaaa"; }else{ var f10 = 1 document.forms['curForm'].elements['chkOutSt'].style.backgroundColor="#ffffff"; document.forms['curForm'].elements['chkOutCountry'].style.backgroundColor="#ffffff"; } } if(f0==0 || f1==0 || f2==0 || f4==0 || f6==0 || f7==0 || f8==0 || f9==0 || f10==0){ return false; }else{ return true; } } if(step=='p3'){ //Billing Details - payment var f11 = fieldValidate(document.forms['curForm'].elements['chkOutPayMethod'],"Payment Method"); //cedit card info if( document.forms['curForm'].elements['chkOutPayMethod'].selectedIndex == 4 ){ var cc1 = fieldValidate(document.forms['curForm'].elements['ccName'],"Card Holder Name"); var cc2 = fieldValidate(document.forms['curForm'].elements['ccNumber'],"Card Number"); var cc3 = fieldValidate(document.forms['curForm'].elements['ccVCode'],"Card VCode"); var cc4 = fieldValidate(document.forms['curForm'].elements['ccExpDateM'],"Card Expiry Month"); var cc5 = fieldValidate(document.forms['curForm'].elements['ccExpDateY'],"Card Expiry Year"); var xMnth = document.forms['curForm'].elements['ccExpDateM']; var xYear = document.forms['curForm'].elements['ccExpDateY']; //Check if exp date was in the past if(cc4==1 && cc5==1){ if( (xYear.value*1 == 10 && xMnth.value*1 > 7) || (xYear.value*1 > 10) ){ xMnth.style.backgroundColor="#ffffff"; xYear.style.backgroundColor="#ffffff"; var cc4Valid = 1; var cc5Valid = 1; }else{ alert('Card Expired'); xMnth.style.backgroundColor="#ffaaaa"; xYear.style.backgroundColor="#ffaaaa"; var cc4Valid = 0; var cc5Valid = 0; } } //Check if Date is valid if(cc4==1 && cc5==1){ if( xMnth.value*1 > 12){ alert('Invalid expiry date'); xMnth.style.backgroundColor="#ffaaaa"; xYear.style.backgroundColor="#ffaaaa"; var cc4Valid = 0; var cc5Valid = 0; }else{ xMnth.style.backgroundColor="#ffffff"; xYear.style.backgroundColor="#ffffff"; var cc4Valid = 1; var cc5Valid = 1; } } if(cc2==1){ var cc2Valid = validateCc(); if(cc2Valid==0){ alert('Invalid credit card number supplied'); document.forms['curForm'].elements['ccNumber'].style.backgroundColor="#ffaaaa"; }else{ document.forms['curForm'].elements['ccNumber'].style.backgroundColor="#ffffff"; } } if(f11==0 || cc1==0 || cc2==0 || cc3==0 || cc4==0 || cc5==0 || cc2Valid==0 || cc4Valid==0 || cc5Valid==0){ return false; }else{ return true; } }else{ if(f11==0){ return false; }else{ return true; } } } if(step=='3b'){ //Billing Details - address var f1 = fieldValidate(document.forms['curForm'].elements['chkOutName1Bill'],"First Name"); var f2 = fieldValidate(document.forms['curForm'].elements['chkOutName2Bill'],"Last Name"); //var f3 = fieldValidate(document.forms['curForm'].elements['chkOutCompanyBill'],"Company Name"); var f4 = fieldValidate(document.forms['curForm'].elements['chkOutStreetAddressBill'],"Street Address"); //var f5 = fieldValidate(document.forms['curForm'].elements['chkOutSuburbBill'],"Suburb"); var f6 = fieldValidate(document.forms['curForm'].elements['chkOutCityBill'],"City"); var f7 = fieldValidate(document.forms['curForm'].elements['chkOutStBill'],"State / Province"); var f8 = fieldValidate(document.forms['curForm'].elements['chkOutPostCodeBill'],"Post Code"); var f9 = fieldValidate(document.forms['curForm'].elements['chkOutCountryBill'],"Country"); //if other box is present replace f7 var with other box validation result if(document.forms['curForm'].elements['chkOutStBill'].selectedIndex==18){ var f7 = fieldValidate(document.forms['curForm'].elements['chkOutStOtherBill'],"State / Province"); } //Check that country and state / province are congruent. chkOutStBill[18]=other & chkOutCountryBill[153]=NZ if(f7==1 && f9==1){ if(document.forms['curForm'].elements['chkOutStBill'].type == "select-one"){ if( (document.forms['curForm'].elements['chkOutStBill'].selectedIndex==18 && document.forms['curForm'].elements['chkOutCountryBill'].selectedIndex==153) || (document.forms['curForm'].elements['chkOutStBill'].selectedIndex!=18 && document.forms['curForm'].elements['chkOutCountryBill'].selectedIndex!=153) ){ var f10 = 0 alert('Invalid Country / Province Combination'); document.forms['curForm'].elements['chkOutStBill'].style.backgroundColor="#ffaaaa"; document.forms['curForm'].elements['chkOutCountryBill'].style.backgroundColor="#ffaaaa"; }else{ var f10 = 1 document.forms['curForm'].elements['chkOutStBill'].style.backgroundColor="#ffffff"; document.forms['curForm'].elements['chkOutCountryBill'].style.backgroundColor="#ffffff"; } } } if(f1==0 || f2==0 || f4==0 || f6==0 || f7==0 || f8==0 || f9==0){ return false; }else{ return true; } } if(step==4){ var f1 = fieldValidate(document.forms['curForm'].elements['tosAgree'],"Terms of service"); if(f1==0){ return false; }else{ return true; } } } //END //START function fieldValidate(obj,fieldName){ //need support for text areas switch(obj.type){ case "select-one": if(obj.selectedIndex == 0){ alert('You need to make a selection from the '+fieldName+' drop down selector'); obj.style.backgroundColor="#ffaaaa"; return 0; }else{ obj.style.backgroundColor="#ffffff"; return 1; } break; case "checkbox": if(obj.checked == false){ alert('You need to check the '+fieldName+' check box to continue'); obj.style.backgroundColor="#ffaaaa"; return 0; }else{ obj.style.backgroundColor="#ffffff"; return 1; } break; default: if(obj.value == null || obj.value == 0 || obj.value == ""){ alert('you need to fill in the '+fieldName+' field'); obj.style.backgroundColor="#ffaaaa"; return 0; }else{ obj.style.backgroundColor="#ffffff"; return 1; } break; } } //END //START function validate_email(e){ // Create the syntactical validation regular expression var regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"; // Presume that the email is invalid var valid = 0; // Validate the syntax if (e.match(regexp)) { var valid = 1; } else { var valid = 0; } return valid; } //END //START function getTotal(shipOpt,itemShipId,pLoc,cartTotal){ if(document.forms['curForm'].elements['groupShip'][3].checked==false){ //if "I want to choose different options for each product" ISN'T selected //Find Shipping Method Selection var i=0 while(i<=3){ if(document.forms['curForm'].elements['groupShip'][i].checked==true){ var shipSelected = i; } i++; }//End Find Shipping Method Selection //Go through each item in the cart => find its shipping classification => Find the Prices based on the Shipping Method Selection => multiply by the quantity => Add to total var totalNI = 0; var totalSI = 0; var totalOS = 0; var i=0; while(i < itemShipId.length){//iterate through items in cart var curClass = document.forms['curForm'].elements['itemClass' + itemShipId[i][1]].value //get shipping classification for current cart entry var qty = itemShipId[i][2] //get qty of the current cart entry var i2=0 while(i2 < shipOpt.length){//iterate though shipping classifications if(curClass == shipOpt[i2][1]){// if the current classification's name is equivalent to the current cart entry's shipping classification if(shipSelected==0){ //Option A var pni = shipOpt[i2][3] var psi = shipOpt[i2][4] var pos = shipOpt[i2][12] } if(shipSelected==1){ //Option B var pni = shipOpt[i2][6] var psi = shipOpt[i2][7] var pos = shipOpt[i2][14] } if(shipSelected==2){ //Option C var pni = shipOpt[i2][9] var psi = shipOpt[i2][10] var pos = shipOpt[i2][16] } if(pni==null || pni==''){ pni = 0; } if(psi==null || psi==''){ psi = 0; } if(pos==null || pos==''){ pos = 0; } totalNI = totalNI + (qty * pni) totalSI = totalSI + (qty * psi) totalOS = totalOS + (qty * pos) } i2++; } i++; } if(pLoc=="ni"){ displayTot( "$" + pF((totalNI*1) + (cartTotal*1)) + " NZD inc. GST" ) } if(pLoc=="si"){ displayTot( "$" + pF((totalSI*1) + (cartTotal*1)) + " NZD inc. GST" ) } if(pLoc=="outside"){ displayTot( "$" + pF((totalOS*1) + (cartTotal*1)) + " NZD inc. GST" ) } }else{ //if "I want to choose different options for each product" IS selected //Go through each item in cart => find its shipping class => Find its shipping selection => Find Prices based on the Shipping Selection => multiply by the quantity => Add to total var totalNI = 0; var totalSI = 0; var totalOS = 0; var i=0; while(i < itemShipId.length){//iterate through items in cart //Find Shipping Method Selection var currentRadioGroup = document.forms['curForm'].elements['itemShip' + itemShipId[i][1]] // get current shipping option's radio group var i2 = 0 while(i2 < currentRadioGroup.length){ if(currentRadioGroup[i2].checked == true){ //if the radio group's current button is checked var shipSelected = i2; } i2++ } var curClass = document.forms['curForm'].elements['itemClass' + itemShipId[i][1]].value //get shipping classification for current cart entry var qty = itemShipId[i][2] //get qty of the current cart entry var i2=0 while(i2 < shipOpt.length){//iterate though shipping classifications if(curClass == shipOpt[i2][1]){// if the current classification's name is equivalent to the current cart entry's shipping classification if(shipSelected==0){ //Option A var pni = shipOpt[i2][3] var psi = shipOpt[i2][4] var pos = shipOpt[i2][12] } if(shipSelected==1){ //Option B var pni = shipOpt[i2][6] var psi = shipOpt[i2][7] var pos = shipOpt[i2][14] } if(shipSelected==2){ //Option C var pni = shipOpt[i2][9] var psi = shipOpt[i2][10] var pos = shipOpt[i2][16] } if(pni==null || pni==''){ pni = 0; } if(psi==null || psi==''){ psi = 0; } if(pos==null || pos==''){ pos = 0; } totalNI = totalNI + (qty * pni) totalSI = totalSI + (qty * psi) totalOS = totalOS + (qty * pos) } i2++; } i++; } if(pLoc=="ni"){ displayTot( "$" + pF((totalNI*1) + (cartTotal*1)) + " NZD inc. GST" ) } if(pLoc=="si"){ displayTot( "$" + pF((totalSI*1) + (cartTotal*1)) + " NZD inc. GST" ) } if(pLoc=="outside"){ displayTot( "$" + pF((totalOS*1) + (cartTotal*1)) + " NZD inc. GST" ) } } } //END //START function pF(price){ //shipping value is a decimal between 0 and 1 var priceS = String(price); var decpos = priceS.indexOf(".") //gets position of the decimal var sfx = priceS.substring(decpos) //gets value afer decimal if (decpos == -1) { var pInt = priceS + ".00" }else{ if (sfx.length==2) { var pInt = priceS + "0" } if (sfx.length==3) { var pInt = priceS } if (sfx.length > 3) { var pInt = Math.round(price*100)/100; } } return pInt; } //END //START function displayTot(msg){ t = document.getElementById('totTarget') e = document.createElement('span') e.innerHTML = msg; if ( t.hasChildNodes() ){ while ( t.childNodes.length >= 1 ){ t.removeChild( t.firstChild ); } } t.appendChild ( e ) } //END