﻿var dr=window.dr||{}; $(function(){dr.contactPopup=function(){function j(){b=$("#tbFirstName");e=$("#tbLastName");f=$("#tbEmail");g=$("#tbCell");h=$("#tbOffice");i=$("#taMessage");a=$("#contact-popup-status")}function k(){$(".contact-trigger").click(function(l){var c=$("#contact-popup").dialog({buttons:{Cancel:function(){c.dialog("close")},Submit:function(){$("#contact-popup :input").disable();$(".ui-dialog-buttonpane :button").disable().addClass("ui-state-disabled");$(".contact-popup-validator").validator(function(d){if(d){a.html("").text("Submitting...").removeClass("status-error");d= JSON.stringify({firstName:b.val(),lastName:e.val(),email:f.val(),cell:g.val(),office:h.val(),message:i.val()});dr.util.ajax("/WebServices/wsContact.asmx/sendContactemail",d,function(m){if(m){a.text("Success! Your message has been sent!");setTimeout(function(){c.dialog("close")},2E3)}else{a.html("").text("An error has occured. Please try again or reload the page.").addClass("status-error");$("#contact-popup :input").enable();$(".ui-dialog-buttonpane :button").enable().removeClass("ui-state-disabled")}}, function(){a.html("").text("An error has occured. Please try again or reload the page.").addClass("status-error");$("#contact-popup :input").enable();$(".ui-dialog-buttonpane :button").enable().removeClass("ui-state-disabled")})}else{$("#contact-popup :input").enable();$(".ui-dialog-buttonpane :button").enable().removeClass("ui-state-disabled");$("#contact-popup :input").bind("blur",function(){$(".contact-popup-validator").validator(function(){},{status:"contact-popup-status"})});$("#contact-popup .error:first").focus()}}, {status:"contact-popup-status"})}},close:function(){c.dialog("destroy");$("#contact-popup :input").val("").removeClass("error");a.html("").text("").removeClass("status-error")},open:function(){$("#contact-popup :input").enable().unbind("blur");b.focus()},draggable:false,modal:true,resizable:false,title:"Email Dr. Ewin",width:440});l.preventDefault()})}var b,e,f,g,h,i,a;j();k()}()});
