jQuery(document).ready( function($) { $('input[type=text]').focus(function() { if($(this).val() === objectL10n.search) { $(this).val(''); } }); $('input[type=text]').blur(function() { if($(this).val() === '') { $(this).val(objectL10n.search) } }); $(".trigger span").click(function() { $(".gallerynav").find(".subnav").slideDown('fast'); $(".gallerynav").find(".subnav").mouseleave( function() { $(".gallerynav").find(".subnav").slideUp('slow'); }); }).hover(function() { $(this).addClass("subhover"); }, function() { $(this).removeClass("subhover"); }); $('#contact_form').submit( function(e) { e.preventDefault(); $('form#contact_form .error').remove(); var hasError = false; $('.required-field').each(function() { if($.trim($(this).val()) == '') { var labelText = $(this).prev('label').text(); $(this).parent().append('You forgot to fill this field.'); hasError = true; } else if($(this).hasClass('email')) { var emailReg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; if(!emailReg.test(jQuery.trim($(this).val()))) { var labelText = $(this).prev('label').text(); $(this).parent().append('You entered an invalid address.'); hasError = true; } } }); if(!hasError) { $('#contact_form li.buttons button').fadeOut('normal', function() { $(this).parent().append('Loading…'); }); var formInput = $('#contact_form').serialize(); $.post($('#contact_form').attr('action'),formInput, function(data){ $('#contact_form').slideUp("fast", function() { $(this).before('

Thanks! Your email was successfully sent. We should be in touch with you soon.

'); }); }); } return false; }); });