function fSumHeights(height, element){return height+$(element).outerHeight(true);} $(window).on("load", function(){ // when the page first loads, load the main pic tag set in the website manager $(".zoomPic").on("click", function(){ $(".subImageLink").eq(0).click(); }); $('.lightGallery').lightGallery({ thumbnail : true }); // Are we going to truncate the description/read more it? nTotalHeight = $(".desc").children().toArray().reduce(fSumHeights, 0); if(nTotalHeight > 145 && window.innerWidth > 768) { // If the height is at least higher than 250, truncate, if not, resize if(nTotalHeight > 250) { // Add a Read More button $(".desc-container").append('
') } else { // Make the description container have no fixed max height $(".desc").css("max-height", "9999px"); } } }); function fReadMore() { $(".read-more-container").remove(); $(".desc").css("max-height", "999px"); } function fItemEnquiry() { var sErr = ""; if (document.fSalesEnquiryForm.sName.value=="") { sErr += "\n - Name"; } // email validation var x = document.fSalesEnquiryForm.sEmail.value; var atpos = x.indexOf("@"); var dotpos = x.lastIndexOf("."); if (atpos< 1 || dotpos=x.length) { sErr += "\n - Not a valid e-mail address"; } // phone number validation val1 = document.fSalesEnquiryForm.sTel.value; if(/^\d+$/.test(val1)) { } else { sErr += "\n - Invalid telephone number ( must only contain numbers and must not contain spaces. )"; } if (document.fSalesEnquiryForm.sEnquiry.value=="") { sErr += "\n - Enquiry"; } if(!$("#enquiryPrivacyPolicy").is(":checked")) { sErr += "\n - Please tick the box to show you agree to our Privacy Policy"; } if (sErr!="") { alert("Please complete the following fields:\n" + sErr); return false; } else { /* update button to say "Sending" */ $('#salesSubmit').attr('disabled', 'disabled'); $('#salesSubmit').css('background', '#B3B3B3'); $('#salesSubmit').val('Sending...'); /* submit the form (by calling google recaptcha) */ grecaptcha.execute(); /* put button back to normal again (pretty pointless though isn't it if we are submitting the form, but hey ho, this code was already here so leaving it here in case there was a logical reason for it) */ // time out for removing disabled atribute on submit button setInterval(function(){ $('#salesSubmit').removeAttr('disabled'); $('#salesSubmit').css('background', '#8EB469'); $('#salesSubmit').val('Send Enquiry'); },10000); // after X seconds } } function fItemEnquiry_Send() { document.fSalesEnquiryForm.action='catalogue_enquiry-send.php?nShopProd_ID=28634'; document.fSalesEnquiryForm.submit(); }