            jQuery(document).ready(
                function() {
                    jQuery("#registration_form_provider").submit(function(){return false;});
                    jQuery("#registration_submit_btn_1").click(function(){checkForm1();});
                }
            );

            function checkForm1()
            {
                var stp = false;
                var requiredFields = ["provider_id","password","email1","specialty1"];

                jQuery.each(requiredFields, function() {
                    if (jQuery("#" + this).val() == '') {jQuery("#" + this).addClass("errorInput"); stp = true; }
                    else {jQuery("#" + this).removeClass("errorInput");}
                });

                if (jQuery('#terms1').is(':checked')) {
                    jQuery("#terms_wrapper1").removeClass("errorInput");

                } else {
                    jQuery("#terms_wrapper1").addClass("errorInput");
                    stp = true;
                }

                var email = jQuery("#email1").val();
                var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;

                if (!email.match(re)) { jQuery("#email1").addClass("errorInput"); stp = true; }
                else { jQuery("#email1").removeClass("errorInput"); }

                if (stp == true) {
                    alert("Please correct the highlighted fields.");
                    return false;

                } else {
                    jQuery("#registration_submit_btn_1").css({display:"none"});
                    jQuery.ajax({
                        type: "POST",
                        url: "/register",
                        dataType: "html",
                        data: jQuery("#registration_form_provider").serialize(),
                        success: function(response){
                            if (response == 'mail_sent')
                            {
                                var text = "Thank you for your interest in the AdvanceCommunity.\n";
                                text += "Your contact information has been forwarded to our coordinator.\n";
                                text += "If you would like to speak to someone now, please call 1-888-388-7633.\n";
                                text += "Otherwise, a ChaseHealthAdvance Practice Consultant will be in touch with you soon.";
                                alert(text);
                                window.location = 'http://www.advancecommunity.com/';
                            } else
                            {
                                alert(response);
                            }
                        },
                        error: function(){
                            alert("An error occured. Please try again.");
                        },
                        complete: function(){
                            jQuery("#registration_submit_btn_1").css({display:"block"});
                        }
                    });
                    return false;
                }
            }

            
            jQuery(document).ready(
                function() {
                    jQuery("#registration_form_not_provider").submit(function(){return false;});
                    jQuery("#registration_submit_btn_2").click(function(){checkForm2();});
                }
            );

            function checkForm2()
            {
                var stp = false;
                var requiredFields = ["terms2","specialty2","email2","phone1","phone2","phone3","name", "zip"];

                jQuery.each(requiredFields, function() {
                    if (jQuery("#" + this).val() == '') {jQuery("#" + this).addClass("errorInput"); stp = true; }
                    else {jQuery("#" + this).removeClass("errorInput");}
                });

                if (jQuery('#terms2').is(':checked')) {
                    jQuery("#terms_wrapper2").removeClass("errorInput");

                } else {
                    jQuery("#terms_wrapper2").addClass("errorInput");
                    stp = true;
                }

                var email = jQuery("#email2").val();
                var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;

                if (!email.match(re)) { jQuery("#email2").addClass("errorInput"); stp = true; }
                else { jQuery("#email1").removeClass("errorInput"); }

                if (stp == true) {
                    alert("Please correct the highlighted fields.");
                    return false;

                } else {
                    jQuery("#registration_submit_btn_2").css({display:"none"});
                    jQuery.ajax({
                        type: "POST",
                        url: "/register",
                        dataType: "html",
                        data: jQuery("#registration_form_not_provider").serialize(),
                        success: function(response){
                            if (response == 'mail_sent')
                            {
                                var text = "Thank you for your interest in the AdvanceCommunity.\n";
                                text += "Your contact information has been forwarded to our coordinator.\n";
                                text += "If you would like to speak to someone now, please call 1-888-388-7633.\n";
                                text += "Otherwise, a ChaseHealthAdvance Practice Consultant will be in touch with you soon.";
                                alert(text);
                                window.location = 'http://www.advancecommunity.com/';
                            } else
                            {
                                alert(response);
                            }
                        },
                        error: function(){
                            alert("An error occured. Please try again.");
                        },
                        complete: function(){
                            jQuery("#registration_submit_btn_2").css({display:"block"});
                        }
                    });
                    return false;
                }
            }