var Contact={_sending:false,initialize:function(){jQuery('#email').bind('blur',Contact.verifyEmail);jQuery('#comments').bind('blur',Contact.verifyComments);jQuery('#btnSend').bind('click',Contact.btnSend_onclick);jQuery('#btnReset').bind('click',Contact.btnReset_onclick);jQuery(document).bind('unload',Contact.deinitialize);jQuery('#firstname')[0].focus()},deinitialize:function(){jQuery('#email').unbind('blur');jQuery('#comments').unbind('blur');jQuery('#btnSend').unbind('click');jQuery('#btnReset').unbind('click')},btnSend_onclick:function(){if(Contact._sending||!Contact.verifyAll())return;Contact._sending=true;Contact._updateForm();Contact._transmit()},btnReset_onclick:function(){jQuery('#firstname').val('');jQuery('#lastname').val('');jQuery('#company').val('');jQuery('#zipcode').val('');jQuery('#email').val('');jQuery('#comments').val('');jQuery('#firstname')[0].focus()},verifyAll:function(){if(Contact._sending)return;var a=!Contact.verifyEmail();a=!Contact.verifyComments()||a;return!a},verifyEmail:function(){if(Contact._sending)return;jQuery('#email').val(jQuery('#email').val());var a=(!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(jQuery('#email').val()));jQuery('#v_email').css('color',(a?'red':''));return!a},verifyComments:function(){if(Contact._sending)return;jQuery('#comments').val(jQuery('#comments').val());var a=(jQuery('#comments').val().length==0);jQuery('#v_comments').css('color',(a?'red':''));return!a},_transmit:function(){jQuery.ajax({type:'POST',url:'/ajax/contact.php',data:{'firstname':jQuery('#firstname').val(),'lastname':jQuery('#lastname').val(),'company':jQuery('#company').val(),'zipcode':jQuery('#zipcode').val(),'email':jQuery('#email').val(),'comments':jQuery('#comments').val(),'emailupdates':(jQuery('#emailupdates')[0].checked?'on':'')},dataType:'json',success:function(a,b){if(a.success)Contact._success();else{Contact.verifyAll();alert(a.message?a.message:'There was an issue while processing your request.\n\nPlease try again later.')}},error:function(a,b,c){alert('There was an issue while processing your request.\n\nPlease try again later.');Contact._sending=false;Contact._updateForm()}})},_updateForm:function(){jQuery('#firstname').attr('readonly',Contact._sending).fadeTo('fast',(Contact._sending?0.5:1));jQuery('#lastname').attr('readonly',Contact._sending).fadeTo('fast',(Contact._sending?0.5:1));jQuery('#company').attr('readonly',Contact._sending).fadeTo('fast',(Contact._sending?0.5:1));jQuery('#zipcode').attr('readonly',Contact._sending).fadeTo('fast',(Contact._sending?0.5:1));jQuery('#email').attr('readonly',Contact._sending).fadeTo('fast',(Contact._sending?0.5:1));jQuery('#comments').attr('readonly',Contact._sending).fadeTo('fast',(Contact._sending?0.5:1));jQuery('#emailupdates').attr('readonly',Contact._sending).fadeTo('fast',(Contact._sending?0.5:1));jQuery('#btnSend').css('cursor',(Contact._sending?'default':'pointer')).fadeTo('fast',(Contact._sending?0.5:1))},_success:function(){jQuery('#contactform-thankyou').html(jQuery('#contactform-thankyou').html().replace(/{#firstname}/,Contact._escapeHTML(jQuery('#firstname').val())).replace(/{#lastname}/,Contact._escapeHTML(jQuery('#lastname').val())).replace(/{#company}/,Contact._escapeHTML(jQuery('#company').val())).replace(/{#zipcode}/,Contact._escapeHTML(jQuery('#zipcode').val())).replace(/{#email}/,Contact._escapeHTML(jQuery('#email').val())).replace(/{#comments}/,Contact._escapeHTML(jQuery('#comments').val())).replace(/{#emailupdates}/,(jQuery('#emailupdates')[0].checked?'Yes':'No')));jQuery('#contactform-container').css('height',(jQuery('#contactform-contents').height()>jQuery('#contactform-thankyou').height()?jQuery('#contactform-contents').height():jQuery('#contactform-thankyou').height())+'px');jQuery('#contactform-contents').fadeOut('slow',function(){jQuery('#contactform-thankyou').fadeIn('slow')})},_escapeHTML:function(a){return jQuery('<div/>').text(a).html()}};jQuery(document).ready(function(){Contact.initialize()});
