jQuery(document).ready(function(){jQuery('#form-content .left, #form-content input, #form-content textarea, #form-content select').focus(function(){jQuery(this).parents('.row').addClass('over');}).blur(function(){jQuery(this).parents('.row').removeClass('over');});var ScheduleAppointment=window.ScheduleAppointment=new Object;ScheduleAppointment.initialize=function(){jQuery('input#name').bind('blur',ScheduleAppointment.verify.name);jQuery('input#email').bind('blur',ScheduleAppointment.verify.email);jQuery('input#formsubmitbutton').bind('click',ScheduleAppointment.submit);};ScheduleAppointment.submit=function(){if(ScheduleAppointment.verify())
ScheduleAppointment.sendAjax();return false;};ScheduleAppointment.verify=function(){var verifies=ScheduleAppointment.verify.name();verifies=ScheduleAppointment.verify.email()&&verifies;return verifies;};ScheduleAppointment.verify.name=function(){var failed=jQuery.trim(jQuery('input#name').val()).length==0;jQuery('label[for="name"]').css('color',(failed?'red':''));return!failed;};ScheduleAppointment.verify.email=function(){var failed=!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(jQuery('input#email').val());jQuery('label[for="email"]').css('color',(failed?'red':''));return!failed;};ScheduleAppointment.sendAjax=function(){function getBestDay(){var bestday='';jQuery('input[id="bestday"]:checked').each(function(){bestday+=(bestday==''?'':'|')+this.value;});return bestday;};function getBestTime(){var besttime=jQuery('select#besttime').val();besttime=besttime&&besttime.length>0?besttime.join('|'):'';return besttime;}
jQuery.post('/ajax/schedule-appointment/',{name:jQuery('input#name').val(),email:jQuery('input#email').val(),phone:jQuery('input#phone').val(),contactby:jQuery('input[id="contactby"]:checked').val(),phonebesttime:jQuery('input#phonebesttime').val(),returningpatient:jQuery('input[id="returningpatient"]').val(),visitingfor:jQuery('select#visitingfor').val(),bestday:getBestDay(),besttime:getBestTime()},ScheduleAppointment.sendAjax.callback,'json');};ScheduleAppointment.sendAjax.callback=function(json){if(!json)
alert('There was an issue while processing your request.\n\nPlease try again later.');else if(json.success)
ScheduleAppointment.sendAjax.success();else if(json.fields){if(json.fields.name)
jQuery('label[for="name"]').css('color','red');if(json.fields.email)
jQuery('label[for="email"]').css('color','red');}else
alert('There was an issue while processing your request.\n\nPlease try again later.');};ScheduleAppointment.sendAjax.success=function(){jQuery('div#schedule-appointment-container').css('height',jQuery('div#schedule-appointment-container').height()+'px');jQuery('div.general-content, div#form-content, input#formsubmitbutton').fadeOut('slow',function(){jQuery('div.thank-you-content').fadeIn('slow');});};ScheduleAppointment.initialize();});