$(document).ready(function(){let error_line_height=16;let $recaptcha_error=$('#recaptcha_error');let url='https://www.lightology.com/index.php?module=contact#form-single';const fields={first_name:{label:'First Name'},last_name:{label:'Last Name'},email_address:{label:'Email'},phone_number:{label:'Phone Number'},contact_message:{}};const fields_count=Object.keys(fields).length;let background_height,overlay_height;if(window.matchMedia("(max-width: 479px)").matches){background_height=580;overlay_height=580;} else if(window.matchMedia("(max-width: 768px)").matches){background_height=580;overlay_height=580;} else{background_height=650;overlay_height=650;} if($('#recaptcha-placeholder').length){background_height+=90;$('#form-single-contact').css({'height':background_height+'px'});overlay_height+=90;$('#static-display-form').css({'height':overlay_height+'px'});} $('#submit-contact').on('click',function(){for(let field in fields){if(fields[field].hasOwnProperty('label')){$('#'+field+'_error').html('');}} if($recaptcha_error.length){$recaptcha_error.html('');} let data='submit=true';for(let field in fields){data+='&'+field+'='+encodeURIComponent($('#'+field).val());} let form_data=$('#form-contact-us').serializeArray();if(form_data.length>fields_count){data+='&g-recaptcha-response='+form_data[form_data.length-1].value;} $.ajax({type:'POST',url:url,data:data,dataType:'json',success:function(data){let height_adjustment=0;if(data.hasOwnProperty('submit_errors')){let error_count=data.submit_errors.length;if(error_count===0){$('#success').addClass('isOpen');$('#form-single-contact').css({'height':'420px'});$('#static-display-form').css({'height':'370px'});$('#recaptcha-placeholder').remove();$('#submit-contact').remove();} else{for(let idx=0;idx'+fields[error].label+'';} $('#'+error+'_error').html(message);height_adjustment+=error_line_height;} $('#form-single-contact').css({'height':(background_height+height_adjustment)+'px'});$('#static-display-form').css({'height':(overlay_height+height_adjustment)+'px'});}}},error:function(){}});});$('body').on('keydown','#last_link_before_form',function(event){let key=event.which;if(key===9){$('#first_name').focus();return false;}}).on('keydown','#first_name',function(event){let key=event.which;if(key===9&&event.shiftKey){$('#submit-contact').focus();return false;}}).on('keydown','#submit-contact',function(event){let key=event.which;if(key===9&&!event.shiftKey){$('#first_name').focus();return false;}});});