checkEmail = { status : true, form : 'form#form-checkEmail', formInput : 'form#form-checkEmail input', submit : '#checkEmail-submit', loader : 'http://www.glassinitstyle.com/templates/images/layout/loader-blu.gif', submitImage : 'http://www.glassinitstyle.com/templates/images/layout/round-ok.jpg', init:function (action){ if(checkEmail.status){ checkEmail.formAjax(action); } return false; }, formAjax:function (action) { $.ajax({ // AJAX-specified URL url: action, // JSON type: 'POST', data: $(checkEmail.form).formToArray(true), dataType : 'json', /* Handlers */ // Handle the beforeSend event beforeSend: function(){ checkEmail.status = false; return checkEmail.beforeSend(); }, // Handle the success event success: function(data, textStatus){ return php.success(data, textStatus); }, // Handle the error event error: function (xmlEr, typeEr, except) { return php.error(xmlEr, typeEr, except); }, // Handle the complete event complete: function (XMLHttpRequest, textStatus) { checkEmail.status = true; return checkEmail.complete(); } }); return false; }, beforeSend:function (){ $(checkEmail.submit).attr('disabled','true').attr('src',checkEmail.loader); return true; }, complete:function (){ $(checkEmail.submit).removeAttr('disabled').attr('src',checkEmail.submitImage ); return true; } } $(document).ready(function(){ /* $("#login form").hover(function(){ $("#email-checkEmail").focus(); $("#email-checkEmail").addClass("focus"); }, function(){ $("#email-checkEmail").removeClass("focus"); } );*/ //invio form con tasto enter $(checkEmail.formInput).keydown(function(e){ if (e.keyCode == 13) { setTimeout ( function(){ checkEmail.init($(checkEmail.form).attr('action')); }, 100 ); return false; } }); $(checkEmail.submit).removeAttr('disabled'); });