﻿var ups=window.ups||{}; ups.modalClientContact=function(){function p(){$(".contact-client-trigger").live("click",function(b){$("#page-wrapper").before($("<div/>").addClass("overlay").height($("#page-wrapper").height()));$.support.opacity?a.show(250):a.show();$(document).bind("keydown",function(d){if(d.keyCode==27){f.click();d.preventDefault()}});b.preventDefault()});f.live("click",function(b){$.support.opacity?a.hide(250,function(){$(this).find("select").val("-1").removeClass("error");$(this).find(":input:text, textarea").val("").removeClass("error");$(".overlay").remove()}): a.animate({height:"toggle",width:"toggle"},300,function(){$(this).find("select").val("-1").removeClass("error");$(this).find(":input:text, textarea").val("").removeClass("error");$(".overlay").remove()});$(document).unbind("keydown");b.preventDefault()});g.live("mouseenter",function(){$(this).addClass("submit-hover")}).live("mouseleave",function(){$(this).removeClass("submit-hover")}).live("click",q)}function q(b){if(!c){c=true;a.find(":input, button").attr("disabled","disabled");$(".client-validator").validator(function(d){if(d){e.text("").html("Sending...&nbsp;&nbsp;<img src='/images/loading.gif' style='display: inline; vertical-align: middle;' alt='' />"); d=JSON.stringify({city:h.val(),firstName:i.val(),lastName:j.val(),email:k.val(),cell:l.val(),workPhone:m.val(),company:n.val(),message:o.val()});ups.util.ajax("/WebServices/wsContact.asmx/sendClientContactEmail",d,function(r){if(r)setTimeout(function(){$("#contact-form").empty().append($("<p/>").text("Thank you for contacting United Protective Services. A representative will be in contact with you as soon as possible."))},1E3);else{e.html("").text("An error has occured. Please try again or reload the page.").addClass("status-error"); $("#contact-form :input").removeAttr("disabled");c=false}},function(){e.html("").text("An error has occured. Please try again or reload the page.").addClass("status-error");$("#contact-form :input, #contact-form button").removeAttr("disabled");c=false})}else{a.find(":input").removeAttr("disabled").blur(function(){$(".client-validator").validator(function(){})});a.find(".error:first").focus();c=false}})}b.preventDefault()}var c,a,f,h,i,j,k,l,m,n,o,g,e;return{init:function(){c=false;a=$("<div/>").attr("id", "modal-client").addClass("modal form").html($("#modal-client-html").html()).appendTo("body").hide();var b=$("body").width()/2-a.width()/2;a.css({left:b,top:100});$("#modal-client-html").remove();f=$("#modal-contact-close");h=$("#ddlCity");i=$("#tbFirstName");j=$("#tbLastName");k=$("#tbEmail");l=$("#tbCell");m=$("#tbWorkPhone");n=$("#tbCompany");o=$("#taMessage");g=$("#btnSubmit");e=$("#status");c=false;p();(new Image).src="/images/global-buttons/submit-hover.png"}}}();$(function(){ups.modalClientContact.init()});
