jQuery.fn.modalContactForm = function() { $(this).each(function(){ $(this).click(function () { $('object').css('visibility', 'hidden'); var i = new Image(); $(i).css({'opacity':'0','position':'absolute','z-index':'-1'}); $('body').prepend(i); $(i).bind("load", function(){ $('body').prepend('\ \ \ '); Recaptcha.create( '6Lee8wUAAAAAAKBSqdHrSRSK44-aoft73eOrf_n9', 'recaptcha_placeholder', { theme: 'white', callback: Recaptcha.focus_response_field } ); if ($f("movie") !== null) { $f("movie").stop(); } $f("movie_contact","/style/flowplayer/flowplayer-3.2.2.swf",{ plugins: { controls: null }, playlist: [ '/movies/contact.mp4' ] }); $('div#modal_contact_form').css('margin-top', ($('div#modal_contact_form').height() + 26) * -1 / 2 + 'px').fadeIn(); $('div#modal_contact_form form').submit(function () { $('input#modal_form_submit').attr({disabled: 'disabled', value: 'Please wait...'}); $.ajax({ type: 'POST', url: '/scripts/forms/contact.json.php', dataType: 'json', data: $(this).serialize(), success: function (json) { if (json.success) { $('div#modal_contact_form form').hide(); $('div#movie_contact').css({'top' : '256px', 'right' : '90px', 'width' : '384px', 'height' : '216px'}); $f("movie_contact").play('movies/thank-you.mp4'); $('div#modal_contact_form').prepend(json.message); } else { $('input#modal_form_submit').removeAttr('disabled').attr('value', 'Submit'); Recaptcha.reload(); alert('Error: ' + json.message); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert('There was an error sending your message.'); } }); return false; }); $('div#modal_mask').fadeTo(null, .75).click(function () { $('div#modal_contact_form').fadeOut(null, function () { $(this).remove(); $('object').css('visibility', 'visible'); }); $(this).fadeOut(null, function () { $(this).remove(); }); }); $('div#modal_close_button').click(function () { $('div#modal_contact_form').fadeOut(null, function () { $(this).remove(); }); $('div#modal_mask').fadeOut(null, function () { $(this).remove(); $('object').css('visibility', 'visible'); }); }); }).attr('src', '/style/images/contact-form-background.png'); }) }); }