form, close; // Get contact form, add onsubmit event to it if (form = $$('#contactform form')[0]) { $('name').focus(); // Add success/failure events to form form.set('send', { onSuccess:this.sendSuccess.bind(this), onFailure:this.sendFailure.bind(this) }); form.addEvent('submit', function(){ // You could perform more checks here form.send(); return false; }); } // Check if closewindow exists. If not, create it if ( ! (close = $('closewindow'))) {
}, sendSuccess : function() { $('contactform').set('html', '<p>Huzzah! The form was sent!</p>'); setTimeout(this.close.bind(this), 1750); }, sendFailure : function() { $('contactform').set('html', '<p>FAIL! Try again later.</p>'); setTimeout(this.close.bind(this), 1750); }, close : function() { // dispose elements so we can re-‐use later this.container.dispose(); this.overlay.dispose(); return false; }