if(!String.prototype.startsWith){String.prototype.startsWith=function(searchString,position){position=position||0;return this.indexOf(searchString,position)===position;};}
jQuery(document).ready(function(){var forms=jQuery('form');var formBuilder=cmHipaaScript.formBuilder;var calderaEnabledForms;if(cmHipaaScript.calderaEnabledForms){calderaEnabledForms=JSON.parse(cmHipaaScript.calderaEnabledForms);}
var gravityEnabledForms;if(cmHipaaScript.gravityEnabledForms){gravityEnabledForms=JSON.parse(cmHipaaScript.gravityEnabledForms);}
var enabledFormsSettings;if(cmHipaaScript.enabledFormsSettings){enabledFormsSettings=JSON.parse(cmHipaaScript.enabledFormsSettings);}
formIds=[];for(var i=0;i<calderaEnabledForms.length;i++){if(calderaEnabledForms[i]){formIds.push(calderaEnabledForms[i]);}}
for(var i=0;i<gravityEnabledForms.length;i++){if(gravityEnabledForms[i]){formIds.push('gform_'+gravityEnabledForms[i]);}}
forms.each(function(){var form=jQuery(this);var formMainId=form.attr('id');var formId=form.attr('data-form-id');if(!formId){formId=formMainId;}
var newSubmitButton;if(formId&&formId.startsWith('gform_')){newSubmitButton='<div class="cm-hipaa-forms-submit gravity cm-hipaa-forms-button active" role="button" tabindex="0" ><i class="material-icons">lock</i> SUBMIT</div>';}else{newSubmitButton='<div class="cm-hipaa-forms-submit caldera cm-hipaa-forms-button active" role="button" tabindex="0" ><i class="material-icons">lock</i> SUBMIT</div>';}
var showSig;if(!enabledFormsSettings){showSig='yes';}
var formFound;if(cmHipaaScript.enabledFormsSettings){enabledFormsSettings.some(function(el){if(el.id===formId&&el.enabled==='yes'||el.form_builder==='gravity'&&'gform_'+el.id===formId&&el.enabled==='yes'){formFound=true;if(el.show_signature){showSig=el.show_signature;}
if(el.submit_btn_text){if(el.form_builder==='gravity'&&'gform_'+el.id===formId){newSubmitButton='<div class="cm-hipaa-forms-submit gravity cm-hipaa-forms-button active" role="button" tabindex="0" >'+el.submit_btn_text+'</div>';}else{newSubmitButton='<div class="cm-hipaa-forms-submit caldera cm-hipaa-forms-button active" role="button" tabindex="0" >'+el.submit_btn_text+'</div>';}}}});}
if(jQuery.inArray(formId,formIds)!==-1||formFound){var protocol=document.location.protocol;var submitButton=jQuery(this).find('input[type="submit"]');var gravityFileUploadEle=jQuery(this).find('.ginput_container_fileupload');var calderaFileUploadEle=jQuery(this).find('.file-prevent-overflow').parent();var calderaMultiFileUploadEle=jQuery(this).find('.cf-uploader-trigger').parent();var calderaAdvancedFileUploadEle=jQuery(this).find('.cf2-field-wrapper');if(calderaAdvancedFileUploadEle.length>0){jQuery.each(calderaAdvancedFileUploadEle,function(){calderaMultiFileUploadEle.push(this);})}
var gravitySflEle=jQuery(this).find('.gform_save_link');var calderaFormPages;var gravityFormPages;var appendEle;calderaFormPages=jQuery(this).find('[data-formpage]');gravityFormPages=jQuery(this).find('.gform_page');if(calderaFormPages.length){appendEle=calderaFormPages.last();}else if(gravityFormPages.length){appendEle=gravityFormPages.last();jQuery(this).find('.gform_next_button, .gform_previous_button').prop('onclick','').prop('onkeypress','').removeAttr('onclick').removeAttr('onkeypress');gravityFormPages.each(function(index){index=+index+1;var pageFooter=jQuery(this).find('.gform_page_footer');var inputIndex=jQuery(this).find('.gform_page_fields input[tabindex]').last().attr('tabindex');var previousButtonIndex;if(index>1&&index===gravityFormPages.length){previousButtonIndex=+inputIndex+1;pageFooter.prepend('<input type="button" id="gform_previous_button_12" class="gform_previous_button button" value="Previous" tabindex="'+previousButtonIndex+'">');}});}else{appendEle=form;}
jQuery(this).attr('action','');jQuery(document).on('click','#'+formMainId+' input[type="submit"], #'+formMainId+' button[type="submit"], #'+formMainId+' [id^=gform_submit_button], #'+formMainId+' input[type="submit"], #'+formMainId+' button[type="submit"] ',function(e){e.preventDefault();alert('ERROR:  This form submission is being overridden be the HIPAA Forms Plugin and was not submitted!');});appendEle.append('<div class="cm-hipaa-forms-loading"><img src="'+cmHipaaScript.pluginUrl+'/images/loading/loading16.gif" alt="Securing Form" /><br /><br />SECURING FORM</div>');if(protocol==='https:'&&cmHipaaScript.ssl==='1'){jQuery.ajax({method:'POST',type:'POST',url:cmHipaaScript.ajax_url,data:{'action':'cm_hipaa_validate_account','nononce':'1','nonce':cmHipaaScript.nonce},success:function(data){jQuery('.cm-hipaa-forms-loading').remove();var resultData;try{resultData=JSON.parse(data);}catch(e){console.log(data);appendEle.append('<div class="cm-hipaa-field-error">There was an Ajax Error!</div>');return false;}
if(resultData.success==='success'){var stagingMessage='';if(resultData.staging){stagingMessage=resultData.staging;}
var validatedAddOns=resultData.add_ons;var validatedAddOnsArray='';if(validatedAddOns&&validatedAddOns!==null&&validatedAddOns!=='null'&&validatedAddOns!==''){if(Array.isArray(validatedAddOns)){validatedAddOnsArray=validatedAddOns.split(',');}else{validatedAddOnsArray=validatedAddOns;}}
var fileUploadEnabled='no';if(Array.isArray(validatedAddOnsArray)&&validatedAddOnsArray.indexOf('fileupload')!==-1){fileUploadEnabled='yes';}else if(validatedAddOns==='fileupload'){fileUploadEnabled='yes';}
var basicBadge='';if(resultData.product==='basic'||resultData.license_status==='expired'){basicBadge='<div class="cm-hipaa-powered-by-badge">POWERED BY <a href="https://www.hipaaforms.online" target="_blank">HIPAA FORMS</a> <i>for Wordpress</i></div>';}
var maxSubmissionsMessage;if(resultData.product==='basic'&&resultData.this_months_submissions>=25){maxSubmissionsMessage='<div class="cm-hipaa-field-error">The maximum number of forms have been submitted for this month, please try again next month.</div>'+basicBadge;}
if(submitButton.length>0){submitButton.attr('disabled','disabled').remove();}
if(gravityFileUploadEle&&fileUploadEnabled!=='yes'){gravityFileUploadEle.html('<div class="cm-hipaa-field-error">Default file upload functionality is not HIPAA compliant & has been disabled, please upgrade HIPAA Forms for file upload capability.</div>');}else if(gravityFileUploadEle&&fileUploadEnabled==='yes'){jQuery.each(gravityFileUploadEle,function(){var gfMultiFile=jQuery(this).find('.gform_fileupload_multifile');var fieldId=jQuery(this).parent().attr('id');var fileInputId=fieldId.replace('field','input');var fileInputEnd=fieldId.split('_').pop();var fileInputName='input_'+fileInputEnd;var fileInputDescribed=fieldId.replace('field','extensions_message');var tabIndex=jQuery(this).find('.gform_button_select_files').attr('tabindex');var gfAcceptAttr=jQuery(this).find('.gform_fileupload_multifile input[type="file"]').attr('accept');var gfMaxFileSize=0;var gfDisallowedExtensions="php,asp,aspx,cmd,csh,bat,html,htm,hta,jar,exe,com,js,lnk,htaccess,phtml,ps1,ps2,php3,php4,php5,php6,py,rb,tmp";var gfFileMimeTypesExtensions="*";var gfMaxFiles=0;var gfFileInputSettings="";if(gfMultiFile&&gfMultiFile.data('settings')){var gfFileDataSettings=gfMultiFile.data('settings');if(gfFileDataSettings.filters.max_file_size){gfMaxFileSize=gfFileDataSettings.filters.max_file_size}
var gfFileMimeTypesTitle="";if(gfFileDataSettings.filters.mime_types[0]){var gfFileMimeTypes=gfFileDataSettings.filters.mime_types[0];if(gfFileMimeTypes.title){gfFileMimeTypesTitle=gfFileMimeTypes.title}
if(gfFileMimeTypes.extensions){gfFileMimeTypesExtensions=gfFileMimeTypes.extensions}}
if(gfFileDataSettings.gf_vars.disallowed_extensions){gfDisallowedExtensions=gfFileDataSettings.gf_vars.disallowed_extensions}
if(gfFileDataSettings.gf_vars.max_files){gfMaxFiles=gfFileDataSettings.gf_vars.max_files}
gfFileInputSettings='{"maxfilesize":"'+gfMaxFileSize+'","allowedextensions":"'+gfFileMimeTypesExtensions+'","disallowedextensions":"'+gfDisallowedExtensions+'","maxfiles":"'+gfMaxFiles+'"}';}else if(gfMultiFile.length===0){gfMaxFileSize=jQuery(this).find("input[type='hidden'][name='MAX_FILE_SIZE']").first().val();var uploadRulesTxt=jQuery(this).find(".gform_fileupload_rules").first().text();var start=uploadRulesTxt.indexOf("Accepted file types: ");var end=uploadRulesTxt.lastIndexOf(',');if(start>-1&&end>-1){gfFileMimeTypesExtensions=uploadRulesTxt.substring(21,end).replaceAll(' ','').split(',');}
gfFileInputSettings='{"maxfilesize":"'+gfMaxFileSize+'","allowedextensions":"'+gfFileMimeTypesExtensions+'","disallowedextensions":"'+gfDisallowedExtensions+'","maxfiles":"'+gfMaxFiles+'"}';}
isRequired=jQuery(this).parent().hasClass('gfield_contains_required');if(gfMultiFile.length>0&&gfMaxFiles==="1"){gfMultiFile.replaceWith('<input name="'+fileInputName+'" id="'+fileInputId+'" type="file" class="medium cm-hipaa-multifile-upload-input" aria-describedby="'+fileInputDescribed+'" aria-required="'+isRequired+'" data-settings='+gfFileInputSettings+' accept="'+gfAcceptAttr+'"  tabindex="'+tabIndex+'">');}else if(gfMultiFile.length>0){gfMultiFile.replaceWith('<input name="'+fileInputName+'" id="'+fileInputId+'" type="file" class="medium cm-hipaa-multifile-upload-input" aria-describedby="'+fileInputDescribed+'" aria-required="'+isRequired+'" data-settings='+gfFileInputSettings+' accept="'+gfAcceptAttr+'"  tabindex="'+tabIndex+'"><div id="assocd_id_'+fileInputId+'" class="cm-hipaa-gf-multifile-upload-button">Add Another File</div>');}else if(gfMultiFile.length===0&&gfMaxFiles===0){jQuery('#'+fileInputId).replaceWith('<input name="'+fileInputName+'" id="'+fileInputId+'" type="file" class="medium cm-hipaa-multifile-upload-input" aria-describedby="'+fileInputDescribed+'"  aria-required="'+isRequired+'" data-settings='+gfFileInputSettings+' tabindex="'+tabIndex+'">');}});}
if((calderaFileUploadEle||calderaMultiFileUploadEle)&&fileUploadEnabled!=='yes'){calderaFileUploadEle.html('<div class="cm-hipaa-field-error">Default file upload functionality is not HIPAA compliant & has been disabled, please upgrade HIPAA Forms for file upload capability.</div>');}else if(calderaMultiFileUploadEle&&fileUploadEnabled==='yes'){jQuery.each(calderaMultiFileUploadEle,function(){var fieldId=jQuery(this).parent().attr('data-field-wrapper');if(!fieldId){fieldId=jQuery(this).attr('data-field-id');}
var cfInputField=jQuery("#"+fieldId);var cfAcceptAttr=cfInputField.attr('accept');var cfMaxFileSize=0;var cfDisallowedExtensions="php,asp,aspx,cmd,csh,bat,html,htm,hta,jar,exe,com,js,lnk,htaccess,phtml,ps1,ps2,php3,php4,php5,php6,py,rb,tmp";var cfFileMimeTypesExtensions="*";var cfMaxFiles=cfInputField.attr('multiple');var cfFileInputSettings='{"maxfilesize":"'+cfMaxFileSize+'","allowedextensions":"'+cfFileMimeTypesExtensions+'","disallowedextensions":"'+cfDisallowedExtensions+'","maxfiles":"'+cfMaxFiles+'"}';if(cfMaxFiles==='multiple'){jQuery(this).replaceWith('<div class="file-prevent-overflow"><div id="'+fieldId+'_1_file_list" class="cf-multi-uploader-list"></div><input type="file" data-settings='+cfFileInputSettings+' accept="'+cfAcceptAttr+'" name="'+fieldId+'" value="" data-field="'+fieldId+'" class="" id="'+fieldId+'_1" aria-labelledby="'+fieldId+'Label"><input type="hidden" name="'+fieldId+'"></div><div id="assocd_id_'+fieldId+'" class="cm-hipaa-cf-multifile-upload-button">Add Another File</div>');}else{jQuery(this).replaceWith('<div class="file-prevent-overflow"><div id="'+fieldId+'_1_file_list" class="cf-multi-uploader-list"></div><input type="file" data-settings='+cfFileInputSettings+' accept="'+cfAcceptAttr+'" name="'+fieldId+'" value="" data-field="'+fieldId+'" class="" id="'+fieldId+'_1" aria-labelledby="'+fieldId+'Label"><input type="hidden" name="'+fieldId+'">');}});}
if(gravitySflEle){gravitySflEle.replaceWith('<div class="cm-hipaa-field-error">"Save For Later" has been disabled due to HIPAA non-compliance</div>');}
var sigField='';if(showSig==='yes'){sigField='<div class="cm-hipaa-form-signature-wrapper"><div class="cm-hipaa-form-signature-inner"><div class="cm-hipaa-form-signature" style="min-height:150px;"></div><div class="cm-hipaa-form-signature-label"><span class="cm-hipaa-form-signature-label-text">To sign left click and drag mouse or use your finger or stylus if touch screen</span> <span class="cm-hipaa-form-signature-reset cm-ghost-button" class="cm-hipaa-forms-button">RESET</span><span style="clear:both;"></span></div></div></div>';}
var cmPrivacyNoticeMethod=cmHipaaScript.privacyNoticeMethod;var cmPrivacyNoticeLabel=cmHipaaScript.privacyNoticeLabel;var cmPrivacyNoticeCopy=cmHipaaScript.privacyNoticeCopy;var cmPrivacyNoticeLink=cmHipaaScript.privacyNoticeLink;var privacyStatement;if(!cmPrivacyNoticeLabel){cmPrivacyNoticeLabel='I agree to the HIPAA Privacy Statement';}
if(!cmPrivacyNoticeCopy){cmPrivacyNoticeCopy='<p>\n'+'This "Notice of Information/Privacy Practices" is used to inform website visitors regarding our policies with the collection, use, and disclosure of Personal Information if anyone decided to use our Service.\n'+'</p>\n'+'<p>\n'+'If you choose to use our Service, then you agree to the collection and use of information in relation with this policy. The Personal Information that we collect are used for providing and improving the Service. We will not use or share your information with anyone except as described in this Privacy Policy.\n'+'</p>\n'+'<p>\n'+'<h3>Information Collection and Use</h3>\n'+'For a better experience while using our Service, we may require you to provide us with certain personally identifiable information, including but not limited to your name, phone number, and postal address. The information that we collect will be used to contact or identify you.\n'+'</p>\n'+'<p>\n'+'<h3>Log Data</h3>\n'+'We want to inform you that whenever you visit our Service, we collect information that your browser sends to us that is called Log Data. This Log Data may include information such as your computer’s Internet Protocol ("IP") address, browser version, pages of our Service that you visit, the time and date of your visit, the time spent on those pages, and other statistics.\n'+'</p>\n'+'<p>\n'+'<h3>Cookies</h3>\n'+'Cookies are files with small amount of data that is commonly used an anonymous unique identifier. These are sent to your browser from the website that you visit and are stored on your computer’s hard drive.\n'+'</p>\n'+'<p>\n'+'Our website uses these "cookies" to collection information and to improve our Service. You have the option to either accept or refuse these cookies, and know when a cookie is being sent to your computer. If you choose to refuse our cookies, you may not be able to use some portions of our Service.\n'+'</p>\n'+'<p>\n'+'<h3>Service Providers</h3>\n'+'We may employ third-party companies and individuals due to the following reasons:\n'+'<ul>\n'+'<li>To facilitate our Service;</li>\n'+'<li>To provide the Service on our behalf;</li>\n'+'<li>To perform Service-related services; or</li>\n'+'<li>To assist us in analyzing how our Service is used.</li>\n'+'<p>\n'+'We want to inform our Service users that these third parties have access to your Personal Information. The reason is to perform the tasks assigned to them on our behalf. However, they are obligated not to disclose or use the information for any other purpose.\n'+'</p>\n'+'</p>\n'+'<p>\n'+'<h3>Security</h3>\n'+'We value your trust in providing us your Personal Information, thus we are striving to use commercially acceptable means of protecting it. But remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, and we cannot guarantee its absolute security.\n'+'</p>\n'+'<p>\n'+'<h3>Links to Other Sites</h3>\n'+'Our Service may contain links to other sites. If you click on a third-party link, you will be directed to that site. Note that these external sites are not operated by us. Therefore, we strongly advise you to review the Privacy Policy of these websites. We have no control over, and assume no responsibility for the content, privacy policies, or practices of any third-party sites or services.\n'+'</p>\n'+'<p>\n'+'<h3>Changes to This Privacy Policy</h3>\n'+'We may update our Privacy Policy from time to time. Thus, we advise you to review this page periodically for any changes. We will notify you of any changes by posting the new Privacy Policy on this page. These changes are effective immediately, after they are posted on this page.\n'+'</p>';}
var modalHTML;if(cmPrivacyNoticeLink&&cmPrivacyNoticeMethod==='link'){privacyStatement='<span class="cm-hipaa-privacy-statement-link"><a href="'+cmPrivacyNoticeLink+'" target="_blank" >'+cmPrivacyNoticeLabel+'</a></span>';modalHTML='';}else{modalHTML='<div class="cmprivacy-modal closed"><div class="cmprivacy-modal-inner"><div class="cmprivacy-modal-inner-top"><h2 class="cmprivacy-title">Notice of Information/Privacy Practices</h2><i class="cmprivacy-close-btn material-icons">cancel</i></div><div class="cmprivacy-content">'+cmPrivacyNoticeCopy+'</div></div></div>';privacyStatement='<span class="cm-hipaa-privacy-statement"><a href="#" >'+cmPrivacyNoticeLabel+'</a></span>';}
var honeyPot='<input type="hidden" class="cm-hipaa-required-extra" value="" />';if(maxSubmissionsMessage){form.prepend('<div class="cm-hipaa-forms-prepend">'+maxSubmissionsMessage+'</div>');appendEle.append('<div class="cm-hipaa-forms-prepend">'+maxSubmissionsMessage+'</div>');form.find('input, textarea').attr('readonly','readonly');form.find('select').attr('disabled','disabled');form.find('input[type="checkbox"], input[type="radio"]').prop('disabled',true);}else{appendEle.append('<div class="cm-hipaa-forms-prepend">'+modalHTML+'<div class="cm-hipaa-forms-privacy-statement"><label for="cm-hipaa-forms-privacy-agree" class="sr-only"> '+cmPrivacyNoticeLabel+'</label><input type="checkbox" id="cm-hipaa-forms-privacy-agree" class="cm-hipaa-forms-privacy-agree" name="cm-hipaa-forms-privacy-agree" aria-label="HIPAA Forms Privacy Statment" value="Yes" /> '+privacyStatement+'</div><div class="cm-hipaa-forms-prepend-bottom"><div class="cm-hipaa-forms-ssl-notice"></div>'+sigField+'<div class="cm-hipaa-forms-submit-wrapper">'+honeyPot+newSubmitButton+'</div><div class="cm-hipaa-notice"></div>'+stagingMessage+'<div class="cm-hipaa-form-badge-wrapper"><img src="'+cmHipaaScript.pluginUrl+'/images/hipaa-compliant-badge.png" alt="HIPAA COMPLIANT FORM" /></div>'+basicBadge+'</div></div>').promise().done(function(){if(showSig==='yes'){var signature=appendEle.find(".cm-hipaa-form-signature");if(signature.is(':visible')){signature.jSignature({'background-color':'transparent'});}}});}}else{submitButton.attr('disabled','disabled').remove();appendEle.append(resultData.error);}},error:function(errorThrown){jQuery('.cm-hipaa-forms-loading').remove();console.log(errorThrown);}});}else{form.append('<div class="cm-hipaa-forms-ssl-notice">This form is designated as a HIPAA compliant form however SSL (https) is not enabled so the form has been disabled.<br />Please ask the website administrators to fix this issue.</div>');submitButton.attr('disabled','disabled').remove();}}});jQuery(document).on('click','.cf-page-btn-next, .gform_next_button, .gf_step, .caldera_forms_form .breadcrumb a',function(){var signature=jQuery(this).closest('form').find('.cm-hipaa-form-signature');setTimeout(function(){if(signature.is(':visible')&&signature.find('canvas').length===0){signature.jSignature({'background-color':'transparent'});}},500);});jQuery(document).on('click','.jSignature',function(){if(!jQuery(this).hasClass('cm-valid-sig')){jQuery(this).addClass('cm-valid-sig');}});jQuery(document).on('touchstart','.jSignature',function(){if(!jQuery(this).hasClass('cm-valid-sig')){jQuery(this).addClass('cm-valid-sig');}});jQuery(document).on('click','.cm-hipaa-form-signature-reset',function(){jQuery(this).parent().parent().find('.jSignature').removeClass('cm-valid-sig');});jQuery(document).on('click','.gform_previous_button, .gform_next_button',function(e){var form=jQuery(this).closest('form');var formId=form.attr('id');var thisPage=jQuery(this).parent().parent();var pages=form.find('.gform_page');var pbPercent=Math.floor(100/pages.length);var progressBarTitle=form.find('.gf_progressbar_title');var progressBar=form.find('.gf_progressbar_percentage');var stepsWrapper=form.find('.gf_page_steps');var direction;form.find('.gfield_error').removeClass('gfield_error');form.find('.validation_error, .validation_message').remove();if(jQuery(this).hasClass('gform_previous_button')){direction='previous';}else if(jQuery(this).hasClass('gform_next_button')){direction='next';}
pages.each(function(index){index=index+1;if(jQuery(this).attr('id')===thisPage.attr('id')&&direction==='next'){var inputs=thisPage.find('input, select, textarea');var errors=[];inputs.each(function(){var fieldWrapper=jQuery(this).closest('.gfield');var fieldType=jQuery(this).attr('type');var value=jQuery(this).val();var visibleSelect;var optionText;var fieldId=jQuery(this).attr('id');if(!fieldType){if(jQuery(this).is('select')){fieldType='select';visibleSelect=form.find('#'+fieldId);optionText=visibleSelect.find('option:selected').text();value=visibleSelect.val();}else if(jQuery(this).is('textarea')){fieldType='textarea';var visibleTextArea=form.find('#'+fieldId);value=visibleTextArea.attr('value');if(!value||value==='undefined'){value=visibleTextArea.val();}}}
var checkOrRadio=false;var cbOptionChecked;if(fieldType==='checkbox'||fieldType==='radio'){checkOrRadio=true;cbOptionChecked=jQuery(this).prop('checked');}
var isVisible=jQuery(this).is(':visible');var isDisabled=jQuery(this).prop('disabled');if(fieldType==='number'){var val=jQuery(this).val();var num=parseFloat(val);if(val!==''){if(jQuery.isNumeric(num)){var min=parseFloat(jQuery(this).attr('min'));var max=parseFloat(jQuery(this).attr('max'));if(jQuery.isNumeric(min)&&jQuery.isNumeric(max)){if((Math.round(num*100000)<Math.round(min*100000))||(Math.round(max*100000)<Math.round(num*100000))){errors.push(jQuery(this).attr('id'));}}else if(jQuery.isNumeric(max)){if(Math.round(max*100000)<Math.round(num*100000)){errors.push(jQuery(this).attr('id'));}}else if(jQuery.isNumeric(min)){if(Math.round(num*100000)<Math.round(min*100000)){errors.push(jQuery(this).attr('id'));}}}else{errors.push(jQuery(this).attr('id'));}}}
if(fieldType==='email'){var emailVal=jQuery(this).val();var emailReg=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;if(emailVal!==''){if(!emailReg.test(emailVal)){errors.push(jQuery(this).attr('id'));}}}
var required=false;if(isDisabled!==true&&isVisible===true&&!jQuery(this).parent().hasClass('name_prefix_select')&&!jQuery(this).parent().hasClass('name_suffix')&&!jQuery(this).parent().hasClass('ginput_address_line_2')&&(jQuery(this).attr('required')==='true'||jQuery(this).attr('aria-required')==='true'||fieldWrapper.hasClass('gfield_contains_required')&&checkOrRadio!==true&&!jQuery(this).parent().hasClass('address_line_2'))){required=true;}
if(required&&(!value||value=="")||isDisabled!==true&&isVisible===true&&checkOrRadio===true&&fieldWrapper.hasClass('gfield_contains_required')&&cbOptionChecked===false){var invalidInputId;if(checkOrRadio===true){var cbIsValid=false;var cbInputs=fieldWrapper.find('input');cbInputs.each(function(){if(jQuery(this).prop('checked')===true){cbIsValid=true;}});if(cbIsValid!==true){invalidInputId=fieldWrapper.attr('id');}}else if(jQuery(this).attr('id')===undefined){invalidInputId=fieldWrapper.attr('id');}else if(fieldType==='select'){invalidInputId=fieldWrapper.attr('id');}else{invalidInputId=jQuery(this).attr('id');}
if(invalidInputId&&errors.indexOf(invalidInputId)===-1){errors.push(invalidInputId);}}});if(errors.length>0){var firstErrorId=errors[0];var firstInvalidInput=jQuery('#'+firstErrorId);var firstInvalidInputWrapper=firstInvalidInput.closest('.gfield');form.find('.gform_body').before('<div class="validation_error">There was a problem with your submission. Errors have been highlighted below.</div>');for(i=0;i<errors.length;i++){var invalidInput=jQuery('#'+errors[i]);var invalidFieldType=invalidInput.attr('type');var invalidInputWrapper;if(invalidFieldType==='checkbox'||invalidFieldType==='radio'){invalidInputWrapper=invalidInput.parent().parent().parent().parent();invalidInputWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">This field is required.</div>');}else{invalidInputWrapper=invalidInput.closest('.gfield');invalidInputWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">This field is required.</div>');}}
jQuery('html, body').animate({scrollTop:firstInvalidInputWrapper.offset().top},500,'linear');}else{jQuery(this).fadeOut().promise().done(function(){var nextPageEle=jQuery(this).next('.gform_page');nextPageEle.fadeIn();var nextIndex=index+1;if(progressBar){var nextPercent;if(index+1===pages.length){nextPercent=100;}else{nextPercent=(pbPercent*index)+pbPercent;}
progressBar.css('width',nextPercent+'%').find('span').html(nextPercent+'%');progressBarTitle.html('Step '+nextIndex+' of '+pages.length);}
if(stepsWrapper){var stepLinks=stepsWrapper.find('.gf_step');var pageId=nextPageEle.attr('id');var pageIdArr=pageId.split('_');var stepLinkId='gf_step_'+pageIdArr[2]+'_'+pageIdArr[3];jQuery.each(stepLinks,function(){if(jQuery(this).attr('id')===stepLinkId){jQuery(this).addClass('gf_step_active gpmpn-step-current');}else{jQuery(this).removeClass('gf_step_active gpmpn-step-current');}});}
jQuery('html, body').animate({scrollTop:form.offset().top},300,'linear');});}}else if(jQuery(this).attr('id')===thisPage.attr('id')&&direction==='previous'){jQuery(this).fadeOut().promise().done(function(){var prevPageEle=jQuery(this).prev('.gform_page');prevPageEle.fadeIn();var previousIndex=index-1;if(progressBar){prevPercent=(pbPercent*index)-pbPercent;progressBar.css('width',prevPercent+'%').find('span').html(prevPercent+'%');progressBarTitle.html('Step '+previousIndex+' of '+pages.length);}
if(stepsWrapper){var stepLinks=stepsWrapper.find('.gf_step');var pageId=prevPageEle.attr('id');var pageIdArr=pageId.split('_');var stepLinkId='gf_step_'+pageIdArr[2]+'_'+pageIdArr[3];jQuery.each(stepLinks,function(){if(jQuery(this).attr('id')===stepLinkId){jQuery(this).addClass('gf_step_active gpmpn-step-current');}else{jQuery(this).removeClass('gf_step_active gpmpn-step-current');}});}
jQuery('html, body').animate({scrollTop:form.offset().top},300,'linear');});}});});jQuery(document).on('click','.gf_step',function(){var form=jQuery(this).closest('form');var stepsWrapper=form.find('.gf_page_steps');var stepLinks=stepsWrapper.find('.gf_step');var stepId=jQuery(this).attr('id');var stepIdArr=stepId.split('_');var pageId='gform_page_'+stepIdArr[2]+'_'+stepIdArr[3];var curPage=form.find('.gform_page:visible');var curPageIdArr=curPage.attr('id').split('_');if(curPage.attr('id')!==pageId){if(stepIdArr[3]>curPageIdArr[3]){form.find('.gfield_error').removeClass('gfield_error');form.find('.validation_error, .validation_message').remove();var inputs=[];jQuery.each(form.find('.gform_page'),function(){if(jQuery(this).attr('id').split('_')[3]<stepIdArr[3]){var pageInputs=jQuery(this).find('input');pageInputs.each(function(){inputs.push(jQuery(this).attr('id'));});}else{return false;}});var errors=[];for(i=0;i<inputs.length;i++){var curInput=jQuery('#'+inputs[i]);var fieldWrapper=curInput.closest('.gfield');var fieldType=curInput.attr('type');var value=curInput.val();var checkOrRadio=false;var cbOptionChecked;if(fieldType==='checkbox'||fieldType==='radio'){checkOrRadio=true;cbOptionChecked=curInput.prop('checked');}
var isVisible=curInput.is(':visible');var isDisabled=curInput.prop('disabled');if(fieldType==='number'){var val=jQuery(this).val();var num=parseFloat(val);if(val!==''){if(jQuery.isNumeric(num)){var min=parseFloat(jQuery(this).attr('min'));var max=parseFloat(jQuery(this).attr('max'));if(jQuery.isNumeric(min)&&jQuery.isNumeric(max)){if((Math.round(num*100000)<Math.round(min*100000))||(Math.round(max*100000)<Math.round(num*100000))){errors.push(jQuery(this).attr('id'));}}else if(jQuery.isNumeric(max)){if(Math.round(max*100000)<Math.round(num*100000)){errors.push(jQuery(this).attr('id'));}}else if(jQuery.isNumeric(min)){if(Math.round(num*100000)<Math.round(min*100000)){errors.push(jQuery(this).attr('id'));}}}else{errors.push(jQuery(this).attr('id'));}}}
if(fieldType==='email'){var emailVal=jQuery(this).val();var emailReg=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;if(emailVal!==''){if(!emailReg.test(emailVal)){errors.push(jQuery(this).attr('id'));}}}
var required=false;if(isDisabled!==true&&isVisible===true&&(curInput.attr('required')||curInput.attr('aria-required')||fieldWrapper.hasClass('gfield_contains_required')&&checkOrRadio!==true&&!curInput.parent().hasClass('address_line_2'))){required=true;}
if(required===true&&!value||isDisabled!==true&&isVisible===true&&checkOrRadio===true&&fieldWrapper.hasClass('gfield_contains_required')&&cbOptionChecked===false){var invalidInputId;if(fieldType==='checkbox'||fieldType==='radio'){var cbIsValid;var cbInputWrapper=curInput.parent().parent().parent().parent();var cbInputs=cbInputWrapper.find('input');cbInputs.each(function(){cbIsValid=false;if(jQuery(this).prop('checked')===true){cbIsValid=true;return false;}});if(cbIsValid!==true){invalidInputId=cbInputWrapper.attr('id');}}else{invalidInputId=curInput.attr('id');}
if(invalidInputId&&errors.indexOf(invalidInputId)===-1){errors.push(invalidInputId);}}}
if(errors.length>0){var firstErrorId=errors[0];var firstInvalidInput=jQuery('#'+firstErrorId);var errorPage=firstInvalidInput.closest('.gform_page');var errorPageIdArr=errorPage.attr('id').split('_');var firstInvalidInputWrapper=firstInvalidInput.closest('.gfield');form.find('.gform_body').before('<div class="validation_error">There was a problem with your submission. Errors have been highlighted below.</div>');for(i=0;i<errors.length;i++){var invalidInput=jQuery('#'+errors[i]);var invalidFieldType=invalidInput.attr('type');var invalidInputWrapper;if(invalidFieldType==='checkbox'||invalidFieldType==='radio'){invalidInputWrapper=invalidInput.parent().parent().parent().parent();invalidInputWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">This field is required.</div>');}else{invalidInputWrapper=invalidInput.closest('li');invalidInputWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">This field is required.</div>');}}
if(errorPage.attr('id')!==curPage.attr('id')){curPage.fadeOut().promise().done(function(){errorPage.fadeIn();jQuery.each(stepLinks,function(){if(jQuery(this).attr('id')==='gf_step_'+errorPageIdArr[2]+'_'+errorPageIdArr[3]){jQuery(this).addClass('gf_step_active gpmpn-step-current');}else{jQuery(this).removeClass('gf_step_active gpmpn-step-current');}});});}
jQuery('html, body').animate({scrollTop:firstInvalidInputWrapper.offset().top},500,'linear');}else{curPage.fadeOut().promise().done(function(){jQuery('#'+pageId).fadeIn();jQuery.each(stepLinks,function(){if(jQuery(this).attr('id')===stepId){jQuery(this).addClass('gf_step_active gpmpn-step-current');}else{jQuery(this).removeClass('gf_step_active gpmpn-step-current');}});});}}else{curPage.fadeOut().promise().done(function(){jQuery('#'+pageId).fadeIn();jQuery.each(stepLinks,function(){if(jQuery(this).attr('id')===stepId){jQuery(this).addClass('gf_step_active gpmpn-step-current');}else{jQuery(this).removeClass('gf_step_active gpmpn-step-current');}});});}}});jQuery(document).on('change','.cm-hipaa-multifile-upload-input',function(){jQuery('body .cm-hipaa-multifile-errors').remove();var settings=jQuery(this).data('settings');var uploadPath=jQuery(this).val();var uploadExtension=uploadPath.substring(uploadPath.lastIndexOf(".")+1,uploadPath.length);var uploadValidationErrors=[];var maxFileSize="";var isMaxFileSize=true;var isAllowedExtention=null;var isDisallowedExtention=null;if(settings.maxfilesize){maxFileSize=settings.maxfilesize;var fileSize=jQuery(this).prop('files')[0].size;if(fileSize>parseInt(maxFileSize)){uploadValidationErrors.push("<div class='cm-hipaa-field-error cm-hipaa-multifile-errors'>This file is too large.</div>");}}
var allowedExtentions="";if(settings.allowedextensions){allowedExtentions=settings.allowedextensions;}
var disallowedExtentions="";if(settings.disallowedextentions){disallowedExtentions=settings.disallowedextentions;}
if(allowedExtentions!=="*"){var allowedExtentionsArray=allowedExtentions.split(',');if(!allowedExtentionsArray.includes(uploadExtension)){uploadValidationErrors.push("<div class='cm-hipaa-field-error cm-hipaa-multifile-errors'>This file type is not allowed.</div>")}}else{var disallowedExtentionsArray=disallowedExtentions.split(',');if(disallowedExtentionsArray.includes(uploadExtension)){uploadValidationErrors.push("<div class='cm-hipaa-field-error cm-hipaa-multifile-errors'>This file type is not allowed.</div>")}}
var maxFiles=0;if(settings.maxfiles){maxFiles=settings.maxfiles;}
if(uploadValidationErrors.length){jQuery(this).val("");for(i=0;i<uploadValidationErrors.length;i++){jQuery(this).before(uploadValidationErrors[i]);}}})
jQuery(document).on('click','.cm-hipaa-gf-multifile-upload-button',function(){var fileUploadInputCount=jQuery(this).parent().find('input[type="file"]').length+1;var fieldId=jQuery(this).parent().parent().attr('id');var fileInputId=fieldId.replace('field','input');var fileInputEnd=fieldId.split('_').pop();var fileInputName='input_'+fileInputEnd;var fileInputDescribed=fieldId.replace('field','extensions_message');var gfFileInputSettings=JSON.stringify(jQuery('#'+fileInputId).data('settings'));var gfAcceptAttr=jQuery('#'+fileInputId).attr('accept');jQuery(this).before('<div class="multi-file-input-spacer"></div><input name="'+fileInputName+'_'+fileUploadInputCount+'" id="'+fileInputId+'_'+fileUploadInputCount+'" type="file" class="medium cm-hipaa-multifile-upload-input" data-settings='+gfFileInputSettings+' accept="'+gfAcceptAttr+'" aria-describedby="'+fileInputDescribed+'"><div class="cm-hipaa-gf-delete-file"><i class="material-icons">delete_forever</i></div>');gfAddAnotherFileBtn(fileInputId);});function gfAddAnotherFileBtn(assocdInputId){var fileInputId=jQuery('#'+assocdInputId);var count=0;count=fileInputId.parent().find('input[type="file"]').length;var fileInputSetting=fileInputId.data('settings');var max=parseInt(fileInputSetting.maxfiles);var addAnotherBtn=jQuery('#assocd_id_'+assocdInputId);var btnFound=false;if(addAnotherBtn.length>0){btnFound=true;}
if((!btnFound&&max===0)||(!btnFound&&max>count)){fileInputId.parent().find('span.gform_fileupload_rules').before('<div id="assocd_id_'+assocdInputId+'" class="cm-hipaa-gf-multifile-upload-button">Add Another File</div>')}else if(btnFound&&max<=count&&max!==0){addAnotherBtn.remove();}}
jQuery(document).on('click','.cm-hipaa-cf-multifile-upload-button',function(){var fileUploadInputCount=0;fileUploadInputCount=jQuery(this).parent().find('input[type="file"]').length+1;var fieldId=jQuery(this).attr('id').replace('assocd_id_','');var firstFileUploadInput=jQuery('#'+fieldId+'_1');var cfFileInputSettings=firstFileUploadInput.data('settings');var cfAcceptAttr=firstFileUploadInput.attr('accept');jQuery(this).before('<div class="multi-file-input-spacer"></div><div class="file-prevent-overflow"><div id="'+fieldId+'_'+fileUploadInputCount+'_file_list" class="cf-multi-uploader-list"></div><input type="file" data-settings='+cfFileInputSettings+' accept="'+cfAcceptAttr+'" name="'+fieldId+'_'+fileUploadInputCount+'" value="" data-field="'+fieldId+'" class="" id="'+fieldId+'_'+fileUploadInputCount+'" aria-labelledby="'+fieldId+'Label"><input type="hidden" name="'+fieldId+'"></div><div class="cm-hipaa-cf-delete-file"><i class="material-icons">delete_forever</i></div>');});jQuery(document).on('click','.cm-hipaa-gf-delete-file',function(){var fileInputId=jQuery(this).parent().find('input[type="file"]').first().attr('id')
jQuery(this).prev().prev().remove();jQuery(this).prev().remove();jQuery(this).remove();gfAddAnotherFileBtn(fileInputId);});jQuery(document).on('click','.cm-hipaa-cf-delete-file',function(){jQuery(this).prev().prev().remove();jQuery(this).prev().remove();jQuery(this).remove();});jQuery(document).on('keydown','form .cm-hipaa-forms-submit.caldera.active',function(e){if(e.keyCode===13){jQuery('form .cm-hipaa-forms-submit.caldera.active').trigger('click');}});jQuery(document).on('click','form .cm-hipaa-forms-submit.caldera.active',function(e){var submitButton=jQuery(this);var form=jQuery(this).parents('form:first');var formHtml=form.html();var noticeEle=form.find('.cm-hipaa-notice');var formMainId=form.attr('id');var formId=form.attr('data-form-id');if(!formId){formId=formMainId;}
submitButton.removeClass('active').addClass('inactive');var calderaEnabledForms=JSON.parse(cmHipaaScript.calderaEnabledForms);formIds=[];for(var i=0;i<calderaEnabledForms.length;i++){if(calderaEnabledForms[i]){formIds.push(calderaEnabledForms[i]);}}
var enabledFormsSettings;if(cmHipaaScript.enabledFormsSettings){enabledFormsSettings=JSON.parse(cmHipaaScript.enabledFormsSettings);}
var formFound=false;var successHandler;var successMessage;var successHideForm;var successRedirect;var successCallback;var successCallbackParams;var selectedUserSlug='';var showSignature;var notificationOption='';if(cmHipaaScript.enabledFormsSettings){enabledFormsSettings.some(function(el){if(el.id===formId&&el.enabled==='yes'){formFound=true;successHandler=el.success_handler;successMessage=el.success_message;successHideForm=el.success_hide_form;successRedirect=el.success_redirect;successCallback=el.success_callback;successCallbackParams=el.success_callback_params;selectedUserSlug=el.selected_user_slug;showSignature=el.show_signature;notificationOption=el.notification_option;}});}
if(!successMessage){successMessage='Thank you, your form has been encrypted to protect your privacy and submitted successfully!';}
if(jQuery.inArray(formId,formIds)!==-1||formFound){e.preventDefault();var defaultBorder;var fileInputs=form.find('input[type=file]');form.after('<div class="cm-hipaa-forms-hidden-form" style="display:none;"></div>');form.clone().appendTo('.cm-hipaa-forms-hidden-form');var hiddenForm=jQuery('.cm-hipaa-forms-hidden-form form');var hiddenFormInputs=jQuery('.cm-hipaa-forms-hidden-form form :input');hiddenForm.find('.cm-hipaa-forms-prepend-bottom, .cmprivacy-modal, .cmprivacy-modal-overlay').remove();hiddenForm.find('.breadcrumb').remove();var formFields=[];var validationErrors=[];var inputs=jQuery('#'+formMainId+' :input');hiddenFormInputs.each(function(){var label=form.find('label[for="'+jQuery(this).attr('id')+'"]').text().trim();var value=jQuery(this).val();var dataField=jQuery(this).attr('data-field');var fieldId=jQuery(this).attr('id');var fieldName=jQuery(this).attr('name');var fieldType=jQuery(this).attr('type');defaultBorder=jQuery(this).css('border');var required=jQuery(this).attr('required');var formGroup=jQuery(this).closest('.form-group');var checkboxParentLabel='';var checkboxLabel='';var radioValue='';var checkboxValue='';var fieldValue='';var optionLabel='';var optionValue='';if(fieldName!=='_cf_verify'&&fieldName!=='_wp_http_referer'&&fieldName!=='_cf_frm_id'&&fieldName!=='_cf_frm_ct'&&fieldName!=='cfajax'&&fieldName!=='_cf_cr_pst'&&fieldType!=='button'&&!jQuery(this).hasClass('button_trigger_1')&&!jQuery(this).hasClass('button_trigger_2')&&fieldName!=='pum_form_popup_id'){if(!fieldType){if(jQuery(this).is('select')){fieldType='select';var visibleSelect=form.find('#'+fieldId);var optionText=visibleSelect.find('option:selected').text();value=visibleSelect.val();fieldValue=value;}else if(jQuery(this).is('textarea')){fieldType='textarea';var visibleTextArea=form.find('#'+fieldId);value=visibleTextArea.attr('value');fieldValue=value;if(!value||value==='undefined'){value=visibleTextArea.val();fieldValue=value;}}}
if(required&&!value&&form.find('#'+fieldId).is(':visible')||(fieldType==='checkbox'||fieldType==='radio')&&(required||jQuery(this).attr('data-parsley-required')==='true')&&jQuery(this).prop('checked')===false&&form.find('#'+fieldId).is(':visible')){var errorExists;if(fieldType==='checkbox'||fieldType==='radio'){var optionsGroup;var visibleOptionsGroup;if(fieldType==='checkbox'){optionsGroup=jQuery(this).data('parsley-group');visibleOptionsGroup=form.find('input[data-parsley-group="'+optionsGroup+'"]');}else if(fieldType==='radio'){optionsGroup=jQuery(this).data('radio-field');visibleOptionsGroup=form.find('input[data-radio-field="'+optionsGroup+'"]');}
var cbIgnore;visibleOptionsGroup.each(function(){if(jQuery(this).prop('checked')===true){cbIgnore=true;return false;}});if(validationErrors.length>0){validationErrors.some(function(el){if(el.fieldId===fieldId||el.fieldGroup===optionsGroup){errorExists=true;}});}
if(!errorExists&&!cbIgnore){validationErrors.push({'fieldId':fieldId,'label':form.find('label[for="'+optionsGroup+'"]').text(),'fieldType':fieldType,'fieldGroup':optionsGroup});}}else{validationErrors.push({'fieldId':fieldId,'label':form.find('label[for="'+jQuery(this).attr('id')+'"]').text(),'fieldType':fieldType,'fieldGroup':''});}}
if(fieldType==='checkbox'||fieldType==='radio'){if(jQuery(this).prop('checked')===true){checkboxLabel=jQuery(this).parent().text().trim();if(jQuery(this).hasClass('cm-hipaa-forms-privacy-agree')){label='Privacy Agreement';}else{label=jQuery(this).parent().parent().parent().find('.control-label').text().trim();if(!label){label=jQuery(this).parent().parent().parent().parent().find('.control-label').text().trim();if(!label){label=checkboxLabel;}}}
checkboxParentLabel=label;optionLabel=checkboxLabel;optionValue=value;}}
if(fieldType==='select'){jQuery(this).replaceWith(optionText);}else if(fieldType==='checkbox'){if(value!==checkboxLabel){checkboxValue=value;}
if(jQuery(this).prop('checked')===true){value='<span class="cm-hipaa-forms-checkbox-value cm-hipaa-forms-checkbox-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/checkbox.png" alt="Checked" style="height: 16px; padding-right: 5px; vertical-align: middle;" />'+checkboxValue+'</span>';jQuery(this).parent().addClass('cm-hipaa-forms-checkbox-checked-wrapper');if(checkboxParentLabel){fieldValue='checked';}}else{value='<span class="cm-hipaa-forms-checkbox-value  cm-hipaa-forms-checkbox-not-checked"><img src="https://www.hipaaforms.online/api-assets/checkbox-unchecked.png" alt="Not Checked" style="height: 16px; padding-right: 5px; vertical-align: middle;" /></span>';jQuery(this).parent().addClass('cm-hipaa-forms-checkbox-not-checked-wrapper');}
jQuery(this).replaceWith(value);}else if(fieldType==='radio'){if(value!==checkboxLabel){radioValue=value;}
if(jQuery(this).prop('checked')===true){value='<span class="cm-hipaa-forms-radio-value cm-hipaa-forms-radio-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/radio-checked.png" alt="Selected" style="height: 16px; padding-right: 5px; vertical-align: middle;" />'+radioValue+'</span>';jQuery(this).parent().addClass('cm-hipaa-forms-radio-checked-wrapper');if(checkboxParentLabel){fieldValue='checked';}}else{value='<span class="cm-hipaa-forms-radio-value cm-hipaa-forms-radio-not-checked"><img src="https://www.hipaaforms.online/api-assets/radio-unchecked.png" alt="Not Selected" style="height: 16px; padding-right: 5px; vertical-align: middle;" /></span>';jQuery(this).parent().addClass('cm-hipaa-forms-radio-not-checked-wrapper');}
jQuery(this).replaceWith(value);}else if(fieldType==='hidden'){jQuery(this).replaceWith('<div data-field="'+jQuery(this).attr('data-field')+'" class="form-group '+jQuery(this).attr('class')+'" id="'+jQuery(this).attr('id')+'">'+value+'</div>');}else{fieldValue=value;jQuery(this).replaceWith(value);}
if(formGroup.hasClass('cm_hipaa_forms_field_not_empty')===false&&(!fieldValue||fieldValue.length===0)){formGroup.addClass('cm_hipaa_forms_field_empty');}else{formGroup.removeClass('cm_hipaa_forms_field_empty');formGroup.addClass('cm_hipaa_forms_field_not_empty');}
if(label&&fieldValue){formFields.push({'label':label,'option_label':optionLabel,'option_value':optionValue,'value':fieldValue,'data_field':dataField,'field_id':fieldId,'field_type':fieldType,'option_text':optionText});}}});var signatureEle=form.find('.cm-hipaa-form-signature');var datapair=signatureEle.jSignature("getData","svgbase64");var signature;if(datapair){signature="data:"+datapair[0]+","+datapair[1];formFields.push({'label':'Signature','option_label':'data:','option_value':datapair[0],'value':datapair[1],'data_field':'','field_id':'','field_type':'signature','option_text':''});}
var privacyAgreementEle=form.find('.cm-hipaa-forms-privacy-agree');jQuery('.form-group').removeClass('has-error');jQuery('input, select, textarea').removeAttr('aria-invalid').removeClass('parsley-error');jQuery('.caldera_ajax_error_block').remove();privacyAgreementEle.parent().css('border','0');if(signatureEle){signatureEle.find('.jSignature').css('border','0');}
noticeEle.html('');var calderaFormPages=hiddenForm.find('[data-formpage]');calderaFormPages.each(function(index){jQuery(this).css({'visibility':'visible','display':'block'});jQuery(this).find('input[type="button"]').closest('.form-group').remove();jQuery(this).find('button').remove();if(index!==(calderaFormPages.length-1)){jQuery(this).append('<pagebreak />');}});var nonce=cmHipaaScript.nonce;if(!jQuery.isEmptyObject(validationErrors)&&validationErrors.length>0){jQuery.each(validationErrors,function(key,val){var invalidFieldId=val.fieldId;var invalidFieldType=val.fieldType;var invalidFieldGroup=val.fieldGroup;var invalidInput=jQuery('#'+invalidFieldId);var invalidFieldWrapper;if(invalidFieldGroup){invalidFieldWrapper=jQuery('#'+invalidFieldGroup+'-wrap');}else{invalidFieldWrapper=jQuery('#'+invalidFieldId+'-wrap');}
invalidFieldWrapper.addClass('has-error');invalidInput.attr('aria-invalid','true').addClass('parsley-error');jQuery('label[for="'+invalidFieldId+'"]').addClass('parsley-error');invalidFieldWrapper.append('<span class="help-block caldera_ajax_error_block filled" aria-live="polite"><span class="parsley-required">This value is required.</span></span>');noticeEle.append('<p>'+val.label+' is a required field!</p>');});jQuery('.cm-hipaa-forms-hidden-form').remove();var scrollTopEle;if(validationErrors[0].fieldGroup){scrollTopEle='#'+validationErrors[0].fieldGroup+'-wrap';}else{scrollTopEle='#'+validationErrors[0].fieldId+'-wrap';}
jQuery('html, body').animate({scrollTop:jQuery(scrollTopEle).offset().top},500,'linear');submitButton.removeClass('inactive').addClass('active');}else if(privacyAgreementEle.prop('checked')!==true){privacyAgreementEle.parent().css('border','1px solid red');noticeEle.html('You must agree to the HIPAA Privacy Agreement');jQuery('.cm-hipaa-forms-hidden-form').remove();submitButton.removeClass('inactive').addClass('active');}else if(showSignature==='yes'&&!signatureEle.find('.jSignature').hasClass('cm-valid-sig')){signatureEle.find('.jSignature').css('border','1px solid red');noticeEle.html('You must sign the form');jQuery('.cm-hipaa-forms-hidden-form').remove();submitButton.removeClass('inactive').addClass('active');}else{jQuery.ajax({method:'POST',type:'POST',url:cmHipaaScript.ajax_url,data:{'action':'cm_hipaa_validate_account','nononce':'1','nonce':cmHipaaScript.nonce},success:function(data){jQuery('.cm-hipaa-forms-loading').remove();var resultData;try{resultData=JSON.parse(data);}catch(e){console.log(data);noticeEle.append(data);return false;}
if(resultData.success==='success'){var validatedAddOns=resultData.add_ons;var validatedAddOnsArray;if(validatedAddOns){validatedAddOnsArray=validatedAddOns.split(',');}
var fileUploadEnabled='no';if(Array.isArray(validatedAddOnsArray)&&validatedAddOnsArray.indexOf('fileupload')!==-1){fileUploadEnabled='yes';}else if(validatedAddOns==='fileupload'){fileUploadEnabled='yes';}
if(fileInputs.length>0&&fileUploadEnabled==='yes'){noticeEle.html('<div class="cm-hipaa-forms-file-upload-status">Uploading Files...</div><div class="cm-hipaa-forms-progress-wrapper"><div class="cm-hipaa-forms-progress"><div class="cm-hipaa-forms-progress-bar"><!--    <div class="cm-hipaa-forms-progress-label">10%</div>--></div></div></div>');cmHipaaFormsProgress();var fileInputsLength=fileInputs.length;var iterations=0;var fileKeys=[];fileInputs.each(function(index){var fileInputParentId=jQuery(this).parent().parent().attr('id');var fileLabel=jQuery(this).parent().parent().find('label').text();fileLabel=fileLabel.replace(/[^a-z0-9\s]/gi,'').replace(/[_\s]/g,'-');var theFormFile=jQuery(this).get()[0].files[0];if(theFormFile){var fileType=theFormFile.type;var fileName=theFormFile.name;jQuery.ajax({method:'POST',type:'POST',url:cmHipaaScript.ajax_url,data:{'action':'cm_hipaa_get_file_upload_url','file_name':fileName,'nononce':'1','nonce':cmHipaaScript.nonce},success:function(data){var resultData;try{resultData=JSON.parse(data);}catch(e){console.log(data);noticeEle.append(data);return false;}
var fileUploadUrl=resultData.file_upload_url;var fileKey=resultData.file_key;fileKeys.push(fileKey);jQuery.ajax({url:fileUploadUrl,type:'PUT',processData:false,contentType:fileType,data:theFormFile,success:function(){var hiddenFileUploadContainer=hiddenForm.find('#'+fileInputParentId);var existingFiles=hiddenFileUploadContainer.find('.cm_hipaa_file_input');hiddenFileUploadContainer.html('');hiddenFileUploadContainer.prepend('<label>'+fileLabel+'</label>');jQuery.each(existingFiles,function(){hiddenFileUploadContainer.append(jQuery(this));});hiddenFileUploadContainer.append('<div class="cm_hipaa_file_input" data-file-key="'+fileKey+'">'+fileKey+'</div>');iterations=iterations+1;if(iterations===fileInputsLength){jQuery('.cm-hipaa-forms-file-upload-status').html('Submitting Form...');setTimeout(function(){jQuery.ajax({method:'POST',type:'POST',url:cmHipaaScript.ajax_url,data:{'action':'cm_hipaa_submit_caldera_form','formId':formId,'formFields':formFields,'formHtml':hiddenForm.html(),'signature':signature,'nononce':'1','nonce':nonce,'selectedUserSlug':selectedUserSlug,'notification_option':notificationOption,'files':fileKeys.join(','),'formFound':formFound},success:function(data){var resultData;try{resultData=JSON.parse(data);}catch(e){console.log(data);noticeEle.append(data);return false;}
var formError='';if(resultData.error){formError=resultData.error;}
if(resultData.success==='success'){if(successHandler==='message'){if(successHideForm==='hide'){form.fadeOut().promise().done(function(){form.after('<div class="cm-hipaa-notice cm-hidden-form-message">'+successMessage+' '+formError+'</div>');jQuery('.cm-hidden-form-message').fadeIn();submitButton.removeClass('inactive').addClass('active');});}else{noticeEle.html(successMessage+' '+formError);submitButton.removeClass('inactive').addClass('active');}}else if(successHandler==='redirect'){window.location=successRedirect;}else if(successHandler==='callback'){fnExists=typeof window[successCallback]==='function';if(fnExists){if(successCallbackParams){window[successCallback].apply(null,successCallbackParams.split(','));}else{window[successCallback]();}}else{console.log(successCallback+' is not an existing function!');}
if(successMessage){noticeEle.html(successMessage+' '+formError);}else{noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!');}
submitButton.removeClass('inactive').addClass('active');}else{noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!');submitButton.removeClass('inactive').addClass('active');}
form[0].reset();if(signature){signatureEle.jSignature("reset");}}else{noticeEle.html(formError);}
hiddenForm.remove();jQuery('.cm-hipaa-forms-hidden-form').remove();},error:function(errorThrown){console.log(errorThrown);noticeEle.html(errorThrown);hiddenForm.remove();jQuery('.cm-hipaa-forms-hidden-form').remove();}});},1000);}}});},error:function(errorThrown){console.log(errorThrown);}});}else{hiddenForm.find('#'+fileInputParentId).find('.file-prevent-overflow').html('<div class="cm_hipaa_file_input" data-file-key="">No File Attached</div>');iterations=iterations+1;if(iterations===fileInputsLength){jQuery('.cm-hipaa-forms-file-upload-status').html('Submitting Form...');setTimeout(function(){jQuery.ajax({method:'POST',type:'POST',url:cmHipaaScript.ajax_url,data:{'action':'cm_hipaa_submit_caldera_form','formId':formId,'formFields':formFields,'formHtml':hiddenForm.html(),'signature':signature,'nononce':'1','nonce':nonce,'selectedUserSlug':selectedUserSlug,'notification_option':notificationOption,'files':fileKeys.join(','),'formFound':formFound},success:function(data){var resultData;try{resultData=JSON.parse(data);}catch(e){console.log(data);noticeEle.append(data);return false;}
var formError='';if(resultData.error){formError=resultData.error;}
if(resultData.success==='success'){if(successHandler==='message'){if(successHideForm==='hide'){form.fadeOut().promise().done(function(){form.after('<div class="cm-hipaa-notice cm-hidden-form-message">'+successMessage+' '+formError+'</div>');jQuery('.cm-hidden-form-message').fadeIn();});submitButton.removeClass('inactive').addClass('active');}else{noticeEle.html(successMessage+' '+formError);submitButton.removeClass('inactive').addClass('active');}}else if(successHandler==='redirect'){window.location=successRedirect;}else if(successHandler==='callback'){fnExists=typeof window[successCallback]==='function';if(fnExists){if(successCallbackParams){window[successCallback].apply(null,successCallbackParams.split(','));}else{window[successCallback]();}}else{console.log(successCallback+' is not an existing function!');}
if(successMessage){noticeEle.html(successMessage+' '+formError);}else{noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!');}
submitButton.removeClass('inactive').addClass('active');}else{noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!');submitButton.removeClass('inactive').addClass('active');}
form[0].reset();if(signature){signatureEle.jSignature("reset");}}else{noticeEle.html(formError);}
hiddenForm.remove();jQuery('.cm-hipaa-forms-hidden-form').remove();submitButton.removeClass('inactive').addClass('active');},error:function(errorThrown){console.log(errorThrown);noticeEle.html(errorThrown);hiddenForm.remove();jQuery('.cm-hipaa-forms-hidden-form').remove();submitButton.removeClass('inactive').addClass('active');}});},1000);}}});}else{noticeEle.html('<div class="cm-hipaa-forms-progress-wrapper"><div class="cm-hipaa-forms-progress"><div class="cm-hipaa-forms-progress-bar"><!--    <div class="cm-hipaa-forms-progress-label">10%</div>--></div></div></div>');cmHipaaFormsProgress();jQuery.ajax({method:'POST',type:'POST',url:cmHipaaScript.ajax_url,data:{'action':'cm_hipaa_submit_caldera_form','formId':formId,'formFields':formFields,'formHtml':hiddenForm.html(),'signature':signature,'nononce':'1','nonce':nonce,'selectedUserSlug':selectedUserSlug,'notification_option':notificationOption,'formFound':formFound},success:function(data){var resultData;try{resultData=JSON.parse(data);}catch(e){console.log(data);noticeEle.append(data);return false;}
var formError='';if(resultData.error){formError=resultData.error;}
if(resultData.success==='success'){if(successHandler==='message'){if(successHideForm==='hide'){form.fadeOut().promise().done(function(){form.after('<div class="cm-hipaa-notice cm-hidden-form-message">'+successMessage+' '+formError+'</div>');jQuery('.cm-hidden-form-message').fadeIn();});}else{noticeEle.html(successMessage+' '+formError);}}else if(successHandler==='redirect'){window.location=successRedirect;}else if(successHandler==='callback'){fnExists=typeof window[successCallback]==='function';if(fnExists){if(successCallbackParams){window[successCallback].apply(null,successCallbackParams.split(','));}else{window[successCallback]();}}else{console.log(successCallback+' is not an existing function!');}
if(successMessage){noticeEle.html(successMessage+' '+formError);}else{noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!');}
submitButton.removeClass('inactive').addClass('active');}else{noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!');submitButton.removeClass('inactive').addClass('active');}
form[0].reset();if(signature){signatureEle.jSignature("reset");}}else{noticeEle.html(formError);submitButton.removeClass('inactive').addClass('active');}
hiddenForm.remove();jQuery('.cm-hipaa-forms-hidden-form').remove();},error:function(errorThrown){console.log(errorThrown);noticeEle.html(errorThrown);hiddenForm.remove();jQuery('.cm-hipaa-forms-hidden-form').remove();submitButton.removeClass('inactive').addClass('active');}});}}else{console.log('Error validating Account...');}},error:function(errorThrown){console.log(errorThrown);}});}}});jQuery(document).on('keyup','form .cm-hipaa-forms-submit.gravity.active',function(e){if(e.keyCode===13){jQuery('body form .cm-hipaa-forms-submit.gravity.active').trigger('click');}});jQuery(document).on('click','form .cm-hipaa-forms-submit.gravity.active',function(e){var gravityVersion=cmHipaaScript.gravityVersion;var submitButton=jQuery(this);var form=jQuery(this).parents('form:first');var noticeEle=form.find('.cm-hipaa-notice');var formMainId=form.attr('id');var formId=form.attr('data-form-id');var newFormat=false;var legacyMarkup=false;if(!formId){formId=formMainId;}
var rawInputs=form.find('textarea, '+'input[type=text], '+'input[type=textarea], '+'input[type=email], '+'input[type=hidden], '+'input[type=password], '+'input[type=search], '+'input[type=url], '+'input[type=month], '+'input[type=day], '+'input[type=year]');jQuery.each(rawInputs,function(index){var rawValue=jQuery(this).val();if(rawValue){var newValue=rawValue.replaceAll('onerror','').replaceAll('img','').replaceAll('onload','').replaceAll('<','&lt;').replaceAll('>','&gt;');jQuery(this).val(newValue);}});if(gravityVersion>=2.5){newFormat=true;if(form.parent().hasClass('gform_legacy_markup_wrapper')){legacyMarkup=true;}}
submitButton.removeClass('active').addClass('inactive');jQuery('.validation_error').remove();var gravityEnabledForms=JSON.parse(cmHipaaScript.gravityEnabledForms);formIds=[];for(var i=0;i<gravityEnabledForms.length;i++){if(gravityEnabledForms[i]){formIds.push('gform_'+gravityEnabledForms[i]);}}
var enabledFormsSettings;if(cmHipaaScript.enabledFormsSettings){enabledFormsSettings=JSON.parse(cmHipaaScript.enabledFormsSettings);}
var formFound;var successHandler;var successMessage;var successHideForm;var successRedirect;var successCallback;var successCallbackParams;var selectedUserSlug='';var showSignature;var notificationOption='';if(cmHipaaScript.enabledFormsSettings){enabledFormsSettings.some(function(el){if(el.form_builder==='gravity'&&'gform_'+el.id===formId&&el.enabled==='yes'){formFound=true;successHandler=el.success_handler;successMessage=el.success_message;successHideForm=el.success_hide_form;successRedirect=el.success_redirect;successCallback=el.success_callback;successCallbackParams=el.success_callback_params;selectedUserSlug=el.selected_user_slug;showSignature=el.show_signature;notificationOption=el.notification_option;}});}
if(!successMessage){successMessage='Thank you, your form has been encrypted to protect your privacy and submitted successfully!';}
if(jQuery.inArray(formId,formIds)!==-1||formFound){e.preventDefault();var location;var locationEmail;var firstName;var lastName;var email;var phone;var selectedUser;var defaultBorder;var fileInputs=form.find('input[type=file]');form.after('<div class="cm-hipaa-forms-hidden-form" style="display:none;"></div>');form.clone().appendTo('.cm-hipaa-forms-hidden-form');var hiddenForm=jQuery('.cm-hipaa-forms-hidden-form form');var hiddenFormInputs=jQuery('.cm-hipaa-forms-hidden-form form :input');if(newFormat===true&&legacyMarkup===false){hiddenForm.find('.gform_body').addClass('gform_wrapper gravity-theme');}
hiddenForm.find('.cm-hipaa-forms-prepend-bottom, .cmprivacy-modal, .cmprivacy-modal-overlay').remove();hiddenForm.find('.gform_footer .gform_hidden').remove();hiddenForm.find('.gfield_list_container').each(function(){var headerItems=jQuery(this).find('.gfield_header_item');var headerCount=headerItems.length;if(headerItems.last().hasClass('gfield_header_item--icons')){headerCount=headerCount-1;}
var widthClass;switch(headerCount){case 1:widthClass='cm-hipaa-gfield--width-1-col';break;case 2:widthClass='cm-hipaa-gfield--width-2-col';break;case 3:widthClass='cm-hipaa-gfield--width-3-col';break;case 4:widthClass='cm-hipaa-gfield--width-4-col';break;case 5:widthClass='cm-hipaa-gfield--width-5-col';break;case 6:widthClass='cm-hipaa-gfield--width-6-col';break;case 7:widthClass='cm-hipaa-gfield--width-7-col';break;case 8:widthClass='cm-hipaa-gfield--width-8-col';break;case 9:widthClass='cm-hipaa-gfield--width-9-col'
break;default:widthClass='';}
headerItems.each(function(){jQuery(this).addClass(widthClass);});jQuery(this).find('.gfield_list_group_item').each(function(){jQuery(this).removeAttr('data-label');jQuery(this).addClass(widthClass);})})
var dateContainers=hiddenForm.find('.ginput_container_date');var dateInputId='';dateContainers.each(function(){dateInputId=jQuery(this).find('.datepicker').attr('id');jQuery(this).find('.ui-datepicker-trigger').remove();jQuery(this).find('.gform_hidden').remove();});hiddenForm.find('.ginput_container_date').next('.gform_hidden').remove();hiddenForm.find('.gf_page_steps').remove();hiddenForm.find("input[name^='gpps_page_progression_']").remove();hiddenForm.find('.add_list_item').remove();hiddenForm.find('.delete_list_item').remove();hiddenForm.find('.chosen-drop').remove();var formFields=[];var validationErrors=[];var inputs=jQuery('#'+formMainId+' :input');hiddenFormInputs.each(function(){var label=form.find('label[for="'+jQuery(this).attr('id')+'"]').text().trim();var value=jQuery(this).val();var fieldId=jQuery(this).attr('id');var fieldSetId;var fieldName=jQuery(this).attr('name');var fieldType=jQuery(this).attr('type');var gravityClassEle=jQuery(this).closest('.gfield');var gravityClass=gravityClassEle.attr('class');defaultBorder=jQuery(this).css('border');var locationSelect;var selectedUserSelect;var visibleSelect;var optionText='';var checkboxParentLabel='';var checkboxLabel;var radioValue='';var checkboxValue='';var fieldValue='';var optionLabel='';var optionValue='';var checkRadioEmpty=false;var required=false;var isVisible=form.find('#'+fieldId).is(':visible');var isDisabled=jQuery(this).prop('disabled');var message='';var isAdvancedField=false;var isAdvancedList=false;if(jQuery(this).closest('.ginput_container').hasClass('ginput_complex')||jQuery(this).closest('.ginput_container').hasClass('ginput_container_list')){isAdvancedField=true;if(newFormat===true&&legacyMarkup===false){fieldSetId=jQuery(this).closest('fieldset').attr('id');let currentItem=jQuery(this);jQuery('.gfield_list input').each(function(index){if(jQuery(this).attr('aria-label')===currentItem.attr('aria-label')){fieldId=fieldSetId+'_'+index;return false;}});isVisible=form.find('#'+fieldSetId).is(':visible');}
if(jQuery(this).closest('.ginput_container').hasClass('ginput_container_list')){isAdvancedList=true;}}
if(fieldName!=='is_submit_10'&&fieldName!=='gform_submit'&&fieldName!=='gform_unique_id'&&fieldName!=='state_10'&&fieldName!=='gform_target_page_number_10'&&fieldName!=='gform_source_page_number_10'&&fieldName!=='gform_field_values'&&!jQuery(this).hasClass('gforms-pum')&&!(jQuery(this).hasClass('gform_hidden')&&jQuery(this).parent().hasClass('ginput_container_consent'))){if(gravityClassEle.hasClass('hipaa_forms_office_location')){locationSelect=form.find('#'+fieldId);location=locationSelect.find('option:selected').text();locationEmail=locationSelect.val();}else if(gravityClassEle.hasClass('hipaa_forms_first_name')&&jQuery(this).val()){firstName=jQuery(this).val();}else if(gravityClassEle.hasClass('hipaa_forms_last_name')&&jQuery(this).val()){lastName=jQuery(this).val();}else if(gravityClassEle.hasClass('hipaa_forms_name')){if(jQuery(this).parent().hasClass('name_first')&&jQuery(this).val()){firstName=jQuery(this).val();}else if(jQuery(this).parent().hasClass('name_last')&&jQuery(this).val()){lastName=jQuery(this).val();}}else if(gravityClassEle.hasClass('hipaa_forms_email')){email=jQuery(this).val();}else if(gravityClassEle.hasClass('hipaa_forms_phone')){phone=jQuery(this).val();}else if(selectedUserSlug&&gravityClassEle.hasClass(selectedUserSlug)){selectedUserSelect=form.find('#'+fieldId);selectedUser=selectedUserSelect.val();}
if(!fieldType){if(jQuery(this).is('select')){fieldType='select';visibleSelect=form.find('#'+fieldId);optionText=visibleSelect.find('option:selected').text();value=visibleSelect.val();fieldValue=value;}else if(jQuery(this).is('textarea')){fieldType='textarea';var visibleTextArea=form.find('#'+fieldId);value=visibleTextArea.attr('value');fieldValue=value;if(!value||value==='undefined'){value=visibleTextArea.val();fieldValue=value;}}}
var cbOptionsWrapper;var checkOrRadio=false;var cbOptionChecked;if(fieldType==='checkbox'||fieldType==='radio'){checkOrRadio=true;cbOptionsWrapperId=gravityClassEle.attr('id');cbOptionsWrapper=form.find('#'+cbOptionsWrapperId);cbOptionChecked=form.find('#'+fieldId).prop('checked');}
if(fieldType==='file'){value=form.find('#'+fieldId).val().replace(/C:\\fakepath\\/i,'');if(!label){label='File Upload';}}
if(fieldType==='number'){var val=jQuery(this).val();var num=parseFloat(val);if(val!==''){if(jQuery.isNumeric(num)){var min=parseFloat(jQuery(this).attr('min'));var max=parseFloat(jQuery(this).attr('max'));if(jQuery.isNumeric(min)&&jQuery.isNumeric(max)){if((Math.round(num*100000)<Math.round(min*100000))||(Math.round(max*100000)<Math.round(num*100000))){validationErrors.push({'fieldId':fieldId,'label':label,'name':fieldName,'visible':isVisible,'message':'The number must be between '+min+' and '+max});}}else if(jQuery.isNumeric(max)){if(Math.round(max*100000)<Math.round(num*100000)){validationErrors.push({'fieldId':fieldId,'label':label,'name':fieldName,'visible':isVisible,'message':'The number must be less than or equal to '+max});}}else if(jQuery.isNumeric(min)){if(Math.round(num*100000)<Math.round(min*100000)){validationErrors.push({'fieldId':fieldId,'label':label,'name':fieldName,'visible':isVisible,'message':'The number must be greater than or equal to '+min});}}}else{validationErrors.push({'fieldId':fieldId,'label':label,'name':fieldName,'visible':isVisible,'message':'You must enter a number'});}}}
if(fieldType==='email'){var emailVal=jQuery(this).val();var emailReg=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;if(emailVal!==''){if(!emailReg.test(emailVal)){validationErrors.push({'fieldId':fieldId,'label':label,'name':fieldName,'visible':isVisible,'message':'The email address entered is invalid, please check the formatting (e.g. email@domain.com)',});}}}
if(isDisabled!==true&&isVisible===true&&(jQuery(this).attr('required')==='true'||jQuery(this).attr('aria-required')==='true'||gravityClassEle.hasClass('gfield_contains_required')==='true'&&checkOrRadio!==true&&!jQuery(this).parent().hasClass('address_line_2'))){required=true;jQuery(this).attr('required');}else if(isAdvancedField){if(isAdvancedList&&jQuery(this).attr('aria-required')==='true'&&isVisible===true){required=true;jQuery(this).attr('required');var fieldId=(jQuery(this).closest('fieldset.gfield_contains_required').attr('id'));jQuery(this).attr('id',fieldId+'_'+jQuery(this).attr('aria-label'));}}
if(required&&(!value||value=="")||isDisabled!==true&&isVisible===true&&checkOrRadio===true&&cbOptionsWrapper.hasClass('gfield_contains_required')&&cbOptionChecked===false){var errorFound;var cbIgnore;if(fieldType==='checkbox'&&!jQuery(this).parent().hasClass('gchoice_select_all')){fieldName=fieldName.split('.')[0];}
if(cbOptionsWrapper){var cbOptions=cbOptionsWrapper.find('input');cbOptions.each(function(){if(jQuery(this).prop('checked')){cbIgnore=true;return false;}});}
if(validationErrors.length>0){validationErrors.some(function(el){if(el.fieldId===fieldId||el.name===fieldName){errorFound=true;}});}
if(!errorFound&&!cbIgnore&&!jQuery(this).parent().hasClass('name_prefix_select')&&!jQuery(this).parent().hasClass('name_suffix')&&!jQuery(this).parent().hasClass('ginput_address_line_2')){validationErrors.push({'fieldId':fieldId,'label':label,'name':fieldName,'visible':isVisible,'message':message});}}
if(fieldType==='checkbox'||fieldType==='radio'){if(jQuery(this).prop('checked')===true){checkboxLabel=jQuery(this).parent().find('label').text().trim();if(jQuery(this).hasClass('cm-hipaa-forms-privacy-agree')){label='Privacy Agreement';}else{label=cbOptionsWrapper.find('.gfield_label').text().trim();}
checkboxParentLabel=label;optionLabel=checkboxLabel;optionValue=value;}}
if(isAdvancedField===true){if(newFormat===true&&legacyMarkup===false){var advancedFields=gravityClassEle.find('input, select');var lastAdvancedFieldId='';var lastAdvancedListField='';if(isAdvancedList===true){lastAdvancedListField=advancedFields.filter(':last');}else{lastAdvancedFieldId=advancedFields.filter(':last').attr('id');}
if(fieldId===lastAdvancedFieldId||isAdvancedList===true&&jQuery(this).is(lastAdvancedListField)){var advancedFieldValues=[];var advancedFieldHTML=[];advancedFields.each(function(index){var advancedFieldClass=jQuery(this).parent().attr('class');var listGroupsWrapper;var listRows;var listRow;var firstListRow;var lastListRow;var listRowFields;var listCell;var firstListCell;var lastListCell;var listCellLabel;if(isAdvancedList===true){listGroupsWrapper=jQuery(this).closest('.gfield_list_groups');listRows=listGroupsWrapper.find('.gfield_list_group');listRow=jQuery(this).closest('.gfield_list_group');firstListRow=listRows.filter(':first');lastListRow=listRows.filter(':last');listRowFields=listRow.find('input, select');listCell=jQuery(this).closest('.gfield_list_group_item');firstListCell=listRowFields.filter(':first');lastListCell=listRowFields.filter(':last');listCellLabel=jQuery(this).attr('aria-label');}
if(jQuery(this).is('select')&&isAdvancedList!==true){visibleSelect=form.find('#'+jQuery(this).attr('id'));optionText=visibleSelect.find('option:selected').text();advancedFieldHTML.push('<span class="'+advancedFieldClass+'">'+optionText+'</span> ');advancedFieldValues.push(optionText);}else{if(isAdvancedList===true&&jQuery(this).is(firstListCell)){advancedFieldHTML.push('<div class="'+listRow.attr('class')+'"><div class="'+listCell.attr('class')+'">');}
if(isAdvancedList===true){var listVal;if(jQuery(this).is('select')){var thisListField=jQuery(this);var thisFieldName=thisListField.attr('name');var thisFieldSelects=hiddenForm.find('select[name="'+thisFieldName+'"]');var visibleFieldSelects=form.find('select[name="'+thisFieldName+'"]');var listOptionValue;thisFieldSelects.each(function(index){if(jQuery(this).is(thisListField)){listOptionValue=visibleFieldSelects.eq(index).val();}});if(listCell.attr('data-label')){listCellLabel=listCell.attr('data-label');}
listVal=listOptionValue;}else{listVal=jQuery(this).val();}
var inputAttributes=[];jQuery(this).each(function(){jQuery.each(this.attributes,function(){if(this.specified){inputAttributes.push(this.name+'="'+this.value+'"');}});});jQuery(this).replaceWith('<span '+inputAttributes.join(' ')+'>'+listVal+'</span>');advancedFieldValues.push(listCellLabel+': '+listVal);}else{advancedFieldHTML.push('<span class="'+advancedFieldClass+'">'+jQuery(this).val()+'</span> ');advancedFieldValues.push(jQuery(this).val());}
if(isAdvancedList===true&&jQuery(this).is(lastListCell)){advancedFieldHTML.push('</div>');if(index!==advancedFields.length-1){advancedFieldValues.push('|');}}else if(isAdvancedList===true){advancedFieldValues.push(' - ');}}
if(isAdvancedList===true){value=advancedFieldHTML.join('');}else{value='<div class="'+jQuery(this).closest('div.ginput_complex').attr('class')+'" id="'+jQuery(this).closest('div.ginput_complex').attr('id')+'">'+advancedFieldHTML.join('')+'</div>';}
fieldValue=advancedFieldValues.join(' ');label=gravityClassEle.find('.gfield_label_before_complex').text();if(!label){label=gravityClassEle.find('.label').text();}
if(!label){label=gravityClassEle.find('.gfield_label').text();}});}else{value='';fieldValue='';label='';}
if(value&&isAdvancedList!==true){gravityClassEle.html('<label class="gfield_label gfield_label_before_complex">'+label+'</label>'+value);fieldId=gravityClassEle.attr('id');fieldType='advanced';}}else{var advancedFields=gravityClassEle.find('input, select');var lastAdvancedFieldId='';var lastAdvancedListField='';if(isAdvancedList===true){lastAdvancedListField=advancedFields.filter(':last');}else{lastAdvancedFieldId=advancedFields.filter(':last').attr('id');}
if(fieldId===lastAdvancedFieldId||isAdvancedList===true&&jQuery(this).is(lastAdvancedListField)){var listTable;var listTableHead;if(isAdvancedList===true){listTable=jQuery(this).closest('table');listTableHead=listTable.find('thead');}
var advancedFieldValues=[];var advancedFieldHTML=[];advancedFields.each(function(index){var advancedFieldClass=jQuery(this).parent().attr('class');var listRow;var firstListRow;var lastListRow;var listRowFields;var listCell;var firstListCell;var lastListCell;var listCellLabel;if(isAdvancedList===true){listRow=jQuery(this).closest('tr');firstListRow=jQuery(this).closest('table').find('tr').filter(':first');lastListRow=jQuery(this).closest('table').find('tr').filter(':last');listRowFields=listRow.find('input, select');listCell=jQuery(this).closest('td');firstListCell=listRowFields.filter(':first');lastListCell=listRowFields.filter(':last');listCellLabel=jQuery(this).attr('aria-label');}
if(jQuery(this).is('select')&&isAdvancedList!==true){visibleSelect=form.find('#'+jQuery(this).attr('id'));optionText=visibleSelect.find('option:selected').text();advancedFieldHTML.push('<span class="'+advancedFieldClass+'">'+optionText+'</span> ');advancedFieldValues.push(optionText);}else{if(isAdvancedList===true&&jQuery(this).is(firstListCell)){if(listRow.is(firstListRow)){}
advancedFieldHTML.push('<tr class="'+listRow.attr('class')+'">');}
if(isAdvancedList===true){var listVal;if(jQuery(this).is('select')){var thisListField=jQuery(this);var thisFieldName=thisListField.attr('name');var thisFieldSelects=hiddenForm.find('select[name="'+thisFieldName+'"]');var visibleFieldSelects=form.find('select[name="'+thisFieldName+'"]');var listOptionValue;thisFieldSelects.each(function(index){if(jQuery(this).is(thisListField)){listOptionValue=visibleFieldSelects.eq(index).val();}});if(jQuery(this).closest('td').attr('data-label')){listCellLabel=jQuery(this).closest('td').attr('data-label');}
listVal=listOptionValue;}else{listVal=jQuery(this).val();}
advancedFieldHTML.push('<td class="'+listCell.attr('class')+'">'+listVal+'</td>');advancedFieldValues.push(listCellLabel+': '+listVal);}else{advancedFieldHTML.push('<span class="'+advancedFieldClass+'">'+jQuery(this).val()+'</span> ');advancedFieldValues.push(jQuery(this).val());}
if(isAdvancedList===true&&jQuery(this).is(lastListCell)){advancedFieldHTML.push('</tr>');if(listRow.is(lastListRow)){}
if(index!==advancedFields.length-1){advancedFieldValues.push('|');}}else if(isAdvancedList===true){advancedFieldValues.push(' - ');}}
if(isAdvancedList===true){var listTableHeadHtml='';if(listTableHead.html()){listTableHeadHtml=listTableHead.html();}
value='<table class="'+jQuery(this).closest('table').attr('class')+'"><thead>'+listTableHeadHtml+'</thead>'+advancedFieldHTML.join('')+'</table>';}else{value='<div class="'+jQuery(this).closest('div.ginput_complex').attr('class')+'" id="'+jQuery(this).closest('div.ginput_complex').attr('id')+'">'+advancedFieldHTML.join('')+'</div>';}
fieldValue=advancedFieldValues.join(' ');label=gravityClassEle.find('.gfield_label_before_complex').text();if(!label){label=gravityClassEle.find('label').text();}
if(!label){label=gravityClassEle.find('.gfield_label').text();}});}else{value='';fieldValue='';label='';}
if(value){gravityClassEle.html('<label class="gfield_label gfield_label_before_complex">'+label+'</label>'+value);fieldId=gravityClassEle.attr('id');fieldType='advanced';}}}else if(fieldType==='select'){if(Array.isArray(value)){fieldValue=value.join(';');value=value.join('<br />');jQuery(this).replaceWith(value);}else if(jQuery(this).closest('.ginput_container_date').is('[class*="gfield_date_dropdown"]')){var fieldsetElm;var parentElm;if(newFormat===true&&legacyMarkup===false){fieldsetElm=jQuery(this).closest('fieldset');fieldSetId=fieldsetElm.attr('id');parentElm=jQuery(this).parent();}else{fieldsetElm=jQuery(this).closest('li.gfield');fieldSetId=fieldsetElm.attr('id');parentElm=jQuery(this).parent().parent();}
var dateSelect1=form.find('#'+fieldSetId).find('select:eq(0)').attr('id');var dateSelect2=form.find('#'+fieldSetId).find('select:eq(1)').attr('id');var dateSelect3=form.find('#'+fieldSetId).find('select:eq(2)').attr('id');var dateValue1=form.find('#'+dateSelect1+' option:selected').text();var dateValue2=form.find('#'+dateSelect2+' option:selected').text();var dateValue3=form.find('#'+dateSelect3+' option:selected').text();if(jQuery(this).attr('id')===dateSelect1){if(dateValue1&&dateValue1!==''&&dateValue1!=='Month'&&dateValue1!=='Day'&&dateValue1!=='Year'){value=dateValue1+'<span class="dateseparator">\/</span>'+dateValue2+'<span class="dateseparator">\/</span>'+dateValue3;parentElm.replaceWith(value);fieldId=fieldSetId;fieldValue=dateValue1+'/'+dateValue2+'/'+dateValue3;optionText='';label=fieldsetElm.find('.gfield_label').text();}else{label=fieldsetElm.find('.gfield_label').text();jQuery(this).replaceWith('');}}else{label='';jQuery(this).replaceWith('');}}else{jQuery(this).replaceWith(optionText);}}else if(fieldType==='checkbox'){if(value!==checkboxLabel&&!jQuery(this).parent().hasClass('ginput_container_consent')){checkboxValue=value;}
if(jQuery(this).prop('checked')===true){value='<span class="cm-hipaa-forms-checkbox-value cm-hipaa-forms-checkbox-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/checkbox.png" alt="Checked" style="height: 16px; padding-right: 5px; vertical-align: middle;" />'+checkboxValue+'</span>';jQuery(this).parent().addClass('cm-hipaa-forms-checkbox-checked-wrapper');if(checkboxParentLabel){fieldValue='checked';}}else{value='<span class="cm-hipaa-forms-checkbox-value  cm-hipaa-forms-checkbox-not-checked"><img src="https://www.hipaaforms.online/api-assets/checkbox-unchecked.png" alt="Not Checked" style="height: 16px; padding-right: 5px; vertical-align: middle;" /></span>';jQuery(this).parent().addClass('cm-hipaa-forms-checkbox-not-checked-wrapper');}
jQuery(this).replaceWith(value);}else if(fieldType==='radio'){if(value!==checkboxLabel){radioValue=value;}
if(jQuery(this).prop('checked')===true){value='<span class="cm-hipaa-forms-radio-value cm-hipaa-forms-radio-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/radio-checked.png" alt="Selected" style="height: 16px; padding-right: 5px; vertical-align: middle;" />'+radioValue+'</span>';jQuery(this).parent().addClass('cm-hipaa-forms-radio-checked-wrapper');if(checkboxParentLabel){fieldValue='checked';}}else{value='<span class="cm-hipaa-forms-radio-value cm-hipaa-forms-radio-not-checked"><img src="https://www.hipaaforms.online/api-assets/radio-unchecked.png" alt="Not Selected" style="height: 16px; padding-right: 5px; vertical-align: middle;" /></span>';jQuery(this).parent().addClass('cm-hipaa-forms-radio-not-checked-wrapper');}
jQuery(this).replaceWith(value);}else if(fieldType==='url'){var rawUrl=jQuery(this).val();var formatedUrl='';if(rawUrl.indexOf("http://")===0){formatedUrl=rawUrl.replace('http://','https://');}else if(rawUrl.indexOf("https://")===0){formatedUrl=rawUrl;}else{formatedUrl='https://'+rawUrl;}
value='<span class="cm-hipaa-forms-url-value"><a target="_blank" href="'+formatedUrl+'">'+formatedUrl+'</a></span>';fieldValue=formatedUrl;jQuery(this).replaceWith(value);}else if(jQuery(this).parent().hasClass('ginput_container_time')){if(jQuery(this).parent().hasClass('gfield_time_hour')){var name=jQuery(this).attr('name');var hours=jQuery(this).val();var minutes=jQuery('.gfield_time_minute input[name="'+name+'"]').val();var ampm=jQuery('.gfield_time_ampm select[name="'+name+'"]').val();if(hours&&hours!==''){if(parseInt(minutes)<10){minutes='0'+minutes;}
if(ampm){fieldValue=hours+':'+minutes+' '+ampm;}else{fieldValue=hours+':'+minutes;}}else{fieldValue='';}
label=jQuery(this).closest('fieldset').find('.gfield_label').text();fieldId=jQuery(this).closest('.gfield_time_hour').attr('id');jQuery(this).closest('.ginput_complex').replaceWith('<div class="ginput_container ginput_container_time" id="'+fieldId+'">'+fieldValue+'</div>');}else{label=false;}}else if(jQuery(this).closest('.ginput_container_date').is('[class*="gfield_date"]')){var dateFieldsetElm;var dateFieldsetId;var parentElm;if(newFormat===true&&legacyMarkup===false){dateFieldsetElm=jQuery(this).closest('fieldset');dateFieldsetId=dateFieldsetElm.attr('id');parentElm=jQuery(this).parent();}else{dateFieldsetElm=jQuery(this).closest('li.gfield');dateFieldsetId=dateFieldsetElm.attr('id');parentElm=jQuery(this).parent().parent();}
var dateField1=form.find('#'+dateFieldsetId).find('.ginput_container_date:eq(0) input');var dateField2=form.find('#'+dateFieldsetId).find('.ginput_container_date:eq(1) input');var dateField3=form.find('#'+dateFieldsetId).find('.ginput_container_date:eq(2) input');var dateFieldValue1=jQuery(dateField1).val();var dateFieldValue2=jQuery(dateField2).val();var dateFieldValue3=jQuery(dateField3).val();if(jQuery(this).attr('id')===jQuery(dateField1).attr('id')){if(dateFieldValue1&&dateFieldValue1!==''&&dateFieldValue1!=='Month'&&dateFieldValue1!=='Day'&&dateFieldValue1!=='Year'){value=dateFieldValue1+'<span class="dateseparator">\/</span>'+dateFieldValue2+'<span class="dateseparator">\/</span>'+dateFieldValue3;parentElm.replaceWith(value);fieldValue=dateFieldValue1+'/'+dateFieldValue2+'/'+dateFieldValue3;label=dateFieldsetElm.find('.gfield_label').text();optionText='';}else{label=dateFieldsetElm.find('.gfield_label').text();jQuery(this).replaceWith('');}}else{label='';jQuery(this).replaceWith('');}}else{jQuery(this).replaceWith(value);}
if(typeof value==='string'||value instanceof String){value=value.trim();}
if(typeof fieldValue==='string'||fieldValue instanceof String){fieldValue=fieldValue.trim();}
if(!fieldValue&&fieldType!=='checkbox'&&fieldType!=='radio'&&fieldType!=='advanced'&&fieldType!=='url'){fieldValue=value;}
if(gravityClassEle.hasClass('cm_hipaa_forms_field_not_empty')===false&&(!fieldValue||fieldValue.length===0)){gravityClassEle.addClass('cm_hipaa_forms_field_empty');}else{gravityClassEle.removeClass('cm_hipaa_forms_field_empty');gravityClassEle.addClass('cm_hipaa_forms_field_not_empty');}
if(label){formFields.push({'label':label,'option_label':optionLabel,'option_value':optionValue,'value':fieldValue,'field_id':fieldId,'field_type':fieldType,'option_text':optionText});}}});var signature;var signatureEle;var datapair;if(showSignature==='yes'){signatureEle=form.find('.cm-hipaa-form-signature');datapair=signatureEle.jSignature("getData","svgbase64");if(datapair){signature="data:"+datapair[0]+","+datapair[1];formFields.push({'label':'Signature','option_label':'data','option_value':datapair[0],'value':datapair[1],'field_id':'','field_type':'signature','option_text':''});}}
var privacyAgreementEle=form.find('.cm-hipaa-forms-privacy-agree');jQuery('.gfield_error').removeClass('gfield_error');privacyAgreementEle.parent().css('border','0');if(signatureEle){signatureEle.find('.jSignature').css('border','0');}
noticeEle.html('');form.find('.gfield_error').removeClass('gfield_error');form.find('.validation_error, .validation_message').remove();var gravityFormPages=hiddenForm.find('.gform_page');if(gravityFormPages&&gravityFormPages.length>0){hiddenForm.find('.gf_progressbar_wrapper').remove();gravityFormPages.each(function(index){jQuery(this).css({'display':'block'});jQuery(this).find('.gform_page_footer').remove();if(index!==(gravityFormPages.length-1)){jQuery(this).append('<pagebreak />');}});}
var nonce=cmHipaaScript.nonce;var honeyPotInput=form.find('.cm-hipaa-required-extra');var honeyPot;if(honeyPotInput){honeyPot=honeyPotInput.val();}
if(honeyPot){jQuery('.cm-hipaa-forms-hidden-form').remove();noticeEle.html('<div><img src="https://media1.tenor.com/images/4945d2cd26ab7d38a6dce346a9c866e7/tenor.gif?itemid=14825791" alt="Angry Robot Upset GIF - AngryRobot Upset Furious GIFs" style="max-width: 250px;"></div><div>Oops, this appears to be an automated bot submission!  Please contact support@codemonkeysllc.com if this is an error.</div>');submitButton.removeClass('inactive').addClass('active');}else if(!jQuery.isEmptyObject(validationErrors)&&validationErrors.length>0){form.find('.gform_body').before('<div class="validation_error">There was a problem with your submission. Errors have been highlighted below.</div>');jQuery.each(validationErrors,function(key,val){var invalidFieldId=val.fieldId;var invalidField=jQuery('#'+invalidFieldId);var invalidFieldType=invalidField.attr('type');var requiredMessage=val.message;if(requiredMessage.length<1){if(invalidField.closest('li').hasClass('hipaa_forms_office_location')&&!locationEmail){requiredMessage='Location select options must have a value!  This should be an email address for the person at the specific location that should receive the form submission notice.';}else{requiredMessage='This field is required.';}}
var invalidFieldWrapper;if(newFormat===true&&legacyMarkup===false){invalidFieldWrapper=invalidField.closest('.gfield');var existingValidationMessage=invalidFieldWrapper.find('.validation_message');if(existingValidationMessage.length===0){invalidFieldWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">'+requiredMessage+'</div>');}}else{if(invalidFieldType==='checkbox'||invalidFieldType==='radio'){invalidFieldWrapper=invalidField.parent().parent().parent().parent();invalidFieldWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">'+requiredMessage+'</div>');}else{invalidFieldWrapper=invalidField.closest('li');invalidFieldWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">'+requiredMessage+'</div>');}}});jQuery('.cm-hipaa-forms-hidden-form').remove();if(jQuery('#'+validationErrors[0].fieldId).length){jQuery('html, body').animate({scrollTop:jQuery('#'+validationErrors[0].fieldId).offset().top-125},500,'linear');}else{jQuery('html, body').animate({scrollTop:jQuery('#'+formId).offset().top-125},500,'linear');}
submitButton.removeClass('inactive').addClass('active');}else if(privacyAgreementEle.prop('checked')!==true){privacyAgreementEle.parent().css('border','1px solid red');noticeEle.html('You must agree to the HIPAA Privacy Agreement');jQuery('.cm-hipaa-forms-hidden-form').remove();submitButton.removeClass('inactive').addClass('active');}else if(showSignature==='yes'&&!signatureEle.find('.jSignature').hasClass('cm-valid-sig')){signatureEle.find('.jSignature').css('border','1px solid red');noticeEle.html('You must sign the form');jQuery('.cm-hipaa-forms-hidden-form').remove();submitButton.removeClass('inactive').addClass('active');}else{jQuery.ajax({method:'POST',type:'POST',url:cmHipaaScript.ajax_url,data:{'action':'cm_hipaa_validate_account','nononce':'1','nonce':cmHipaaScript.nonce},success:function(data){jQuery('.cm-hipaa-forms-loading').remove();var resultData;try{resultData=JSON.parse(data);}catch(e){console.log(data);noticeEle.append(data);return false;}
if(resultData.success==='success'){var validatedAddOns=resultData.add_ons;var validatedAddOnsArray;if(validatedAddOns){validatedAddOnsArray=validatedAddOns.split(',');}
var fileUploadEnabled='no';if(Array.isArray(validatedAddOnsArray)&&validatedAddOnsArray.indexOf('fileupload')!==-1){fileUploadEnabled='yes';}else if(validatedAddOns==='fileupload'){fileUploadEnabled='yes';}
if(fileInputs.length>0&&fileUploadEnabled==='yes'){noticeEle.html('<div class="cm-hipaa-forms-file-upload-status">Uploading Files...</div><div class="cm-hipaa-forms-progress-wrapper"><div class="cm-hipaa-forms-progress"><div class="cm-hipaa-forms-progress-bar"><!--    <div class="cm-hipaa-forms-progress-label">10%</div>--></div></div></div>');cmHipaaFormsProgress();var fileInputsLength=fileInputs.length;var iterations=0;var fileKeys=[];fileInputs.each(function(index){var fileInputParentId=jQuery(this).parent().parent().attr('id');var fileLabel=jQuery(this).parent().parent().find('label').text();fileLabel=fileLabel.replace(/[^a-z0-9\s]/gi,'').replace(/[_\s]/g,'-');var theFormFile=jQuery(this).get()[0].files[0];if(theFormFile){var fileType=theFormFile.type;var fileName=index+'_'+theFormFile.name;jQuery.ajax({method:'POST',type:'POST',url:cmHipaaScript.ajax_url,data:{'action':'cm_hipaa_get_file_upload_url','file_name':fileName,'nononce':'1','nonce':cmHipaaScript.nonce},success:function(data){var resultData;try{resultData=JSON.parse(data);}catch(e){console.log(data);noticeEle.append(data);return false;}
var fileUploadUrl=resultData.file_upload_url;var fileKey=resultData.file_key;fileKeys.push(fileKey);jQuery.ajax({url:fileUploadUrl,type:'PUT',processData:false,contentType:fileType,data:theFormFile,success:function(){var hiddenFileUploadContainer=hiddenForm.find('#'+fileInputParentId).find('.ginput_container_fileupload');var existingFiles=hiddenForm.find('#'+fileInputParentId).find('.cm_hipaa_file_input');hiddenFileUploadContainer.html('');jQuery.each(existingFiles,function(){hiddenFileUploadContainer.append(jQuery(this));});hiddenFileUploadContainer.append('<div class="cm_hipaa_file_input" data-file-key="'+fileKey+'">'+fileKey+'</div>');iterations=iterations+1;if(iterations===fileInputsLength){jQuery('.cm-hipaa-forms-file-upload-status').html('Submitting Form...');setTimeout(function(){jQuery.ajax({method:'POST',type:'POST',url:cmHipaaScript.ajax_url,data:{'action':'cm_hipaa_submit_gravity_form','formId':formId,'formFields':formFields,'formHtml':hiddenForm.html(),'signature':signature,'nononce':'1','nonce':nonce,'selectedUser':selectedUser,'location':location,'locationEmail':locationEmail,'firstName':firstName,'lastName':lastName,'email':email,'phone':phone,'notification_option':notificationOption,'files':fileKeys.join(','),'formFound':formFound},success:function(data){var resultData=JSON.parse(data);var formError='';if(resultData.error){formError=resultData.error;}
if(resultData.success==='success'){if(successHandler==='message'){if(successHideForm==='hide'){form.fadeOut().promise().done(function(){form.after('<div class="cm-hipaa-notice cm-hidden-form-message">'+successMessage+' '+formError+'</div>');jQuery('.cm-hidden-form-message').fadeIn();});submitButton.removeClass('inactive').addClass('active');}else{noticeEle.html(successMessage+' '+formError);submitButton.removeClass('inactive').addClass('active');}}else if(successHandler==='redirect'){window.location=successRedirect;}else if(successHandler==='callback'){fnExists=typeof window[successCallback]==='function';if(fnExists){if(successCallbackParams){window[successCallback].apply(null,successCallbackParams.split(','));}else{window[successCallback]();}}else{console.log(successCallback+' is not an existing function!');}
if(successMessage){noticeEle.html(successMessage+' '+formError);}else{noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!');}}else{noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!');}
form[0].reset();if(signature){signatureEle.jSignature("reset");}
submitButton.removeClass('inactive').addClass('active');}else{noticeEle.html(formError);submitButton.removeClass('inactive').addClass('active');}
hiddenForm.remove();jQuery('.cm-hipaa-forms-hidden-form').remove();},error:function(errorThrown){console.log(errorThrown);noticeEle.html(errorThrown);hiddenForm.remove();jQuery('.cm-hipaa-forms-hidden-form').remove();submitButton.removeClass('inactive').addClass('active');}});},500);}}});},error:function(errorThrown){console.log(errorThrown);}});}else{hiddenForm.find('#'+fileInputParentId).find('.ginput_container_fileupload').html('<div class="cm_hipaa_file_input" data-file-key="">No File Attached</div>');iterations=iterations+1;if(iterations===fileInputsLength){jQuery('.cm-hipaa-forms-file-upload-status').html('Submitting Form...');setTimeout(function(){jQuery.ajax({method:'POST',type:'POST',url:cmHipaaScript.ajax_url,data:{'action':'cm_hipaa_submit_gravity_form','formId':formId,'formFields':formFields,'formHtml':hiddenForm.html(),'signature':signature,'nononce':'1','nonce':nonce,'selectedUser':selectedUser,'location':location,'locationEmail':locationEmail,'firstName':firstName,'lastName':lastName,'email':email,'phone':phone,'notification_option':notificationOption,'files':fileKeys.join(','),'formFound':formFound},success:function(data){var resultData;try{resultData=JSON.parse(data);}catch(e){console.log(data);noticeEle.append(data);return false;}
var formError='';if(resultData.error){formError=resultData.error;}
if(resultData.success==='success'){if(successHandler==='message'){if(successHideForm==='hide'){form.fadeOut().promise().done(function(){form.after('<div class="cm-hipaa-notice cm-hidden-form-message">'+successMessage+' '+formError+'</div>');jQuery('.cm-hidden-form-message').fadeIn();});submitButton.removeClass('inactive').addClass('active');}else{noticeEle.html(successMessage+' '+formError);submitButton.removeClass('inactive').addClass('active');}}else if(successHandler==='redirect'){window.location=successRedirect;}else if(successHandler==='callback'){fnExists=typeof window[successCallback]==='function';if(fnExists){if(successCallbackParams){window[successCallback].apply(null,successCallbackParams.split(','));}else{window[successCallback]();}}else{console.log(successCallback+' is not an existing function!');}
if(successMessage){noticeEle.html(successMessage+' '+formError);}else{noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!');}}else{noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!');}
form[0].reset();if(signature){signatureEle.jSignature("reset");}
submitButton.removeClass('inactive').addClass('active');}else{noticeEle.html(formError);submitButton.removeClass('inactive').addClass('active');}
hiddenForm.remove();jQuery('.cm-hipaa-forms-hidden-form').remove();},error:function(errorThrown){console.log(errorThrown);noticeEle.html(errorThrown);hiddenForm.remove();jQuery('.cm-hipaa-forms-hidden-form').remove();submitButton.removeClass('inactive').addClass('active');}});},500);}}});}else{noticeEle.html('<div class="cm-hipaa-forms-progress-wrapper"><div class="cm-hipaa-forms-progress"><div class="cm-hipaa-forms-progress-bar"><!--    <div class="cm-hipaa-forms-progress-label">10%</div>--></div></div></div>');cmHipaaFormsProgress();jQuery.ajax({method:'POST',type:'POST',url:cmHipaaScript.ajax_url,data:{'action':'cm_hipaa_submit_gravity_form','formId':formId,'formFields':formFields,'formHtml':hiddenForm.html(),'signature':signature,'nononce':'1','nonce':nonce,'selectedUser':selectedUser,'location':location,'locationEmail':locationEmail,'firstName':firstName,'lastName':lastName,'email':email,'phone':phone,'notification_option':notificationOption,'formFound':formFound},success:function(data){var resultData;try{resultData=JSON.parse(data);}catch(e){console.log(data);noticeEle.append(data);return false;}
var formError='';if(resultData.error){formError=resultData.error;}
if(resultData.success==='success'){if(successHandler==='message'){if(successHideForm==='hide'){form.fadeOut().promise().done(function(){form.after('<div class="cm-hipaa-notice cm-hidden-form-message">'+successMessage+' '+formError+'</div>');jQuery('.cm-hidden-form-message').fadeIn();submitButton.removeClass('inactive').addClass('active');});}else{noticeEle.html(successMessage+' '+formError);submitButton.removeClass('inactive').addClass('active');}}else if(successHandler==='redirect'){window.location=successRedirect;}else if(successHandler==='callback'){fnExists=typeof window[successCallback]==='function';if(fnExists){if(successCallbackParams){window[successCallback].apply(null,successCallbackParams.split(','));}else{window[successCallback]();}}else{console.log(successCallback+' is not an existing function!');}
if(successMessage){noticeEle.html(successMessage+' '+formError);}else{noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!');}
submitButton.removeClass('inactive').addClass('active');}else{noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!');submitButton.removeClass('inactive').addClass('active');}
form[0].reset();if(signature){signatureEle.jSignature("reset");}}else{noticeEle.html(formError);submitButton.removeClass('inactive').addClass('active');}
hiddenForm.remove();jQuery('.cm-hipaa-forms-hidden-form').remove();},error:function(errorThrown){console.log(errorThrown);noticeEle.html(errorThrown);hiddenForm.remove();jQuery('.cm-hipaa-forms-hidden-form').remove();submitButton.removeClass('inactive').addClass('active');}});}}else{console.log('Error validating Account...');}},error:function(errorThrown){console.log(errorThrown);}});}}});jQuery(document).on('click','.cm-hipaa-form-signature-reset',function(){jQuery(this).parent().parent().find('.cm-hipaa-form-signature').jSignature("reset");});jQuery(document).on('click','.cmprivacy-modal .cmprivacy-close-btn',function(){jQuery('.cmprivacy-modal').toggle('closed');jQuery('.cmprivacy-modal-overlay').toggle('closed');});jQuery(document).on('click','.cm-hipaa-privacy-statement a',function(e){e.preventDefault();jQuery('.cmprivacy-modal').toggle('closed');jQuery('.cmprivacy-modal-overlay').toggle('closed');});console.log('CM script.js finished');});function cmHipaaFormsProgress(){var elem=jQuery(".cm-hipaa-forms-progress-bar");var width=10;var id=setInterval(frame,25);function frame(){if(width>=100){width=10;}else{width++;elem.css('width',width+'%');jQuery(".cm-hipaa-forms-progress-label").html(width+'%');}}}
function removeTags(str){if((str===null)||(str===''))
return false;else
str=str.toString();var sanitizedString=str.replace(/(<([^>]+)>)/ig,'');var sanitizedString2=sanitizedString.replace(/<img[^>]*?>/g,'');return sanitizedString2;}