// function to prevent user typing in non numeric characters in the dimensions boxes // ================================================================================== function fValidDimensions(sInputName) { // work out if imperial is selected (if so don't allow decimal places, only numbers, otherwise allow numbers and decimal places) if (document.getElementById('bImperial').checked==true) { // imperial (allow only numbers) // ============================= var box = document.getElementById(sInputName); re=/^[0-9]*$/; if(!re.exec(box.value)) { alert("Only numbers are allowed in this box. To choose fractions of an inch, use the box to the right of the one you're typing in"); // remove the offending characters (only allow numeric characters by using a regular expression) var sBoxValue = box.value; sBoxValue = sBoxValue.replace(/[^0-9]+/g,''); document.getElementById(sInputName).value=sBoxValue; }//end name if } else { // metric (allow only numbers and decmial places) // ================================================ var box = document.getElementById(sInputName); re=/^[0-9\.]*$/; if(!re.exec(box.value)) { alert("Only numbers (including decimal places) are allowed in this box"); // remove the offending characters (only allow numeric characters by using a regular expression) var sBoxValue = box.value; sBoxValue = sBoxValue.replace(/[^0-9\.]+/g,''); document.getElementById(sInputName).value=sBoxValue; }//end name if } } // not sure we need the below function anymore after I have taken the search out of AJAX and put on the page in order to allow pagination (note by RW) function fDoorSearchNoResults() { $( "#divSearchNoResults" ).dialog({ resizable: false, height:170, width:300, modal: true, buttons: { "OK": function() { $( this ).dialog( "close" ); } } }); } // the function that is called when you press the search button function fSearchDoors() { // check to see if we are in the main doors category, or if the expanded search has been pressed // if yes = dont display a dialog box about asking to search all doors // if no = display a dialog box about asking to search in all doors if ((document.getElementById('nShopProdCat_ID').value=="1042") || (document.getElementById('bDoorExpandedSearch').value=="yes")) { // we are in the main doors category, so no need to ask to search for all doors or not fSearchDoors_DoSearch(); } else { // we are in a sub category of doors, so ask if theyd like to search for all doors $( "#divSearchAllDoors" ).dialog({ resizable: false, height:170, width:300, modal: true, buttons: { "Just this category": function() { // hide the dialog box $( this ).dialog( "close" ); // perform the search fSearchDoors_DoSearch(); }, "All doors": function() { // uncheck the box for this category // see if a tickbox for this category exists first if ($('#cat_'+document.getElementById('nShopProdCat_ID').value).length > 0) { document.getElementById('cat_'+document.getElementById('nShopProdCat_ID').value).checked=false; } // uncheck and un-disable everything $('.internalCheck').attr("checked", false); $('.internalCheck').attr("disabled", false); $('.glazedCheck').attr("checked", false); $('.glazedCheck').attr("disabled", false); $('.externalCheck').attr("checked", false); $('.externalCheck').attr("disabled", false); $('.woodtypeCheck').attr("checked", false); $('.woodtypeCheck').attr("disabled", false); // hide the dialog box $( this ).dialog( "close" ); // perform the search fSearchDoors_DoSearch(); } } }); } } // the function that performs the search. This is called by fSearchDoors function fSearchDoors_DoSearch() { // set a cookie to say we are on the door search $.cookie('catalogue_list_bDoorSearch', 1); // save all the elements in the form to cookies var els = document.forms.fDoorSearch.elements; $formWrapper = $('#fDoorSearch'); $.ajax({ url : 'ajax/door_cookie.php', type : $formWrapper.attr('method'), data : $formWrapper.serialize(), success : function( data ) { // reload the page location.href='#results'; fPageChange(1,true); } }); } // the function that clears the search if you press the CLEAR FORM button function fSearchDoors_ClearSearch() { if (confirm("This will clear the form and reset your door search")) { location.href='#'; $.cookie('catalogue_list_cleardoorsearch', 'yes'); fPageChange(1,true); } } // if they click the change to Inches button, this will change all of the option values for the CM select boxes into Inches option values function fChangeToInches() { $('.measurementChange').text('in'); $('.tinyText').text('default ΒΌ"'); // populate the dimensions boxes with inch measurements $('#heightTolerance').html(''); $('#widthTolerance').html(''); $('#depthTolerance').html(''); // populate and show the decimal boxes $('#heightToleranceDecimal').html(''); $('#widthToleranceDecimal').html(''); $('#depthToleranceDecimal').html(''); $('#heightToleranceDecimal').show(); $('#widthToleranceDecimal').show(); $('#depthToleranceDecimal').show(); // empty values document.getElementById('nDWidth').value=""; document.getElementById('nDHeight').value=""; document.getElementById('nDDepth').value=""; } // if they click the change to CM button, this will change all of the option values for the Inches select boxes into CM option values function fChangeToCM() { $('.measurementChange').text('cm'); $('.tinyText').text('default 1cm'); $('#heightTolerance').html(''); $('#widthTolerance').html(''); $('#depthTolerance').html(''); // hide decimal boxes $('#heightToleranceDecimal').hide(); $('#widthToleranceDecimal').hide(); $('#depthToleranceDecimal').hide(); // empty values document.getElementById('nDWidth').value=""; document.getElementById('nDHeight').value=""; document.getElementById('nDDepth').value=""; } function fShowExpandedSearch() { document.getElementById('bDoorExpandedSearch').value="yes"; $('#expandedDoors').slideDown(); $('#expandForMore').slideUp(); $('#doorSearchContainer').css('height', 'auto'); } // check to see if all interior is checked function fCheckAllInterior() { // if all is checked, disabled the sub checks if($('#cat_2032').is(':checked')){ $('.internalCheck').prop('checked', true); $('.internalCheck').attr("disabled", true); }else{ $('.internalCheck').attr("checked", false); $('.internalCheck').attr("disabled", false); } } // check to see if all glazed is checked function fCheckAllGlazed() { // if all is checked, disabled the sub checks if($('#cat_2034').is(':checked')){ $('.glazedCheck').prop('checked', true); $('.glazedCheck').attr("disabled", true); }else{ $('.glazedCheck').attr("checked", false); $('.glazedCheck').attr("disabled", false); } } // check to see if all external is checked function fCheckAllExternal() { // if all is checked, disabled the sub checks if($('#cat_2033').is(':checked')){ $('.externalCheck').prop('checked', true); $('.externalCheck').attr("disabled", true); }else{ $('.externalCheck').attr("checked", false); $('.externalCheck').attr("disabled", false); } } // check to see if all external is checked function fCheckAllWoodtype() { // if all is checked, disabled the sub checks if($('#cat_3059').is(':checked')){ $('.woodtypeCheck').prop('checked', true); $('.woodtypeCheck').attr("disabled", true); }else{ $('.woodtypeCheck').attr("checked", false); $('.woodtypeCheck').attr("disabled", false); } }