console.log("loading"); //(function(){ if (typeof jQuery == 'undefined'){ console.log("loading jQuery"); var nmxscript = document.createElement("script"); nmxscript.src = '//www.nutramax.biz/js/jquery.js'; document.head.appendChild(nmxscript); } //})(); function showPostStoryThankyou(formSelector){ jQuery(formSelector).hide(); jQuery("#thankyou, .thankyou").show(); document.location = "/#thankyou"; jQuery('html, body').scrollTo(jQuery('#thankyou'), 300); } function showPostStoryForm(formSelector){ jQuery(formSelector).show(); jQuery("#thankyou, .thankyou").hide(); document.location = "/#yourstory"; jQuery('html, body').scrollTo(jQuery('#yourstory'), 300); } // Phone number formatting function phoneFormatter() { jQuery('#phone').attr({ placeholder : '(___) ___-____' }); jQuery('#phone').on('input', function() { var number = jQuery(this).val().replace(/[^\d]/g, '') if (number.length == 7) { number = number.replace(/(\d{3})(\d{4})/, "$1-$2"); } else if (number.length == 10) { number = number.replace(/(\d{3})(\d{3})(\d{4})/, "($1) $2-$3"); } jQuery(this).val(number) jQuery(this).attr({ maxLength : 10 }); }); } if (!jQuery(".success-stories-submit-form").length){ if(jQuery("#success-stories-submit-form-script[button='true']").length && !jQuery(".success-stories-submit-form-btn").length){ console.log("added success stories submit form button"); jQuery("#success-stories-submit-form-script").after('
Submit Your Success Story
'); } else{ console.log("added success stories submit form"); } jQuery("#success-stories-submit-form-script").before(''); if (!jQuery("#success-stories-submit-form-script[button='true']").length){ jQuery(".success-stories-submit-form").removeAttr("style"); } if (jQuery(".success-stories-submit-form-btn").length){ jQuery(".success-stories-submit-form-btn").removeAttr("target").removeAttr("href").find("*").removeAttr("target").removeAttr("href"); } } var product = ""; jQuery(document).ready(function(){ jQuery(".success-stories-submit-form").addClass("nmx-bs"); if (jQuery(".success-stories-submit-form-btn").length){ jQuery(".success-stories-submit-form").prependTo("body").addClass("popup"); jQuery(".success-stories-submit-form-btn").click(function(){ OpenSubmitFormPopup(); }); } else{ console.log("no button"); } jQuery("head").append(''); jQuery("head").append(''); //jQuery("head").append(''); console.log("rating goes here"); } //jQuery("head").append(''); } function LoadSuccessStories(){ window.setInterval(function(){ jQuery("i").each(function() { jQuery("i[data-value='1']").hover(function(){ jQuery("#rating-class").css("color","#b43034").text("Poor"); jQuery(".rating-input i.glyphicon").css("color","#b43034"); }); jQuery("i[data-value='2']").hover(function(){ jQuery("#rating-class").css("color","#de9500").text("Fair"); jQuery(".rating-input i.glyphicon").css("color","#de9500"); }); jQuery("i[data-value='3']").hover(function(){ jQuery("#rating-class").css("color","#ffbf00").text("Average"); jQuery(".rating-input i.glyphicon").css("color","#ffbf00"); }); jQuery("i[data-value='4']").hover(function(){ jQuery("#rating-class").css("color","#8ac100").text("Good"); jQuery(".rating-input i.glyphicon").css("color","#8ac100"); }); jQuery("i[data-value='5']").hover(function(){ jQuery("#rating-class").css("color","#005320").text("Excellent"); jQuery(".rating-input i.glyphicon").css("color","#005320"); }); }); jQuery(".rating-input").mouseout(function(){ if(jQuery("#rating1").val() == "") { jQuery("#rating-class").text(""); jQuery(".rating-input i.glyphicon").css("color","#9c680e"); } if(jQuery("#rating1").val() == 1) { jQuery("#rating-class").css("color","#b43034").text("Poor"); jQuery(".rating-input i.glyphicon").css("color","#b43034"); } if(jQuery("#rating1").val() == 2) { jQuery("#rating-class").css("color","#de9500").text("Fair"); jQuery(".rating-input i.glyphicon").css("color","#de9500"); } if(jQuery("#rating1").val() == 3) { jQuery("#rating-class").css("color","#ffbf00").text("Average"); jQuery(".rating-input i.glyphicon").css("color","#ffbf00"); } if(jQuery("#rating1").val() == 4) { jQuery("#rating-class").css("color","#8ac100").text("Good"); jQuery(".rating-input i.glyphicon").css("color","#8ac100"); } if(jQuery("#rating1").val() == 5) { jQuery("#rating-class").css("color","#005320").text("Excellent"); jQuery(".rating-input i.glyphicon").css("color","#005320"); } }); },500); if (location.hash=="#thankyou"){ ShowSuccessStoriesThankyou(); } window.scrollBy(0,0); if(navigator.userAgent.indexOf("iPhone") == -1 && navigator.userAgent.indexOf("iPad") == -1){ jQuery(".legal-text").attr("scrolling","yes").attr("style","height:200px; width:100%; border:solid 1px #dddddd;").unwrap(); jQuery(".success-stories-submit-form iframe.legal-text-container").remove(); } //jQuery('#gotop').click(function(){ window.scrollTo(0,0); }); jQuery("head").append(''); jQuery(".col-md-2 p strong:contains('Testimonal Affidavit')").closest("div").removeClass("col-md-2").addClass("col-md-12"); jQuery("#submit-story-form #email").focus(function(){ jQuery("#submit-story-form #email").prop("type","email"); }); jQuery("#submit-story-form #phone").focus(function(){ jQuery("#submit-story-form #phone").prop("type","tel"); }); if(jQuery("#submit-story-form select#product option").length<3){ jQuery("#submit-story-form select#product").closest("div").hide(); } //jQuery(".scroll-to-view").prev("h4").css("margin-top","40px"); phoneFormatter(); window.setInterval(function(){ checkUploadFileSelection(); },1500); window.onresize= function(){ ResizeForm(); }; ResizeForm(); } function ResizeForm(){ if (jQuery("#submit-story-form input[type='submit']").parent().width()<736){ jQuery("#submit-story-form input[type='submit']").val("Submit"); //jQuery("div.trigger").css("font-size","12px"); } else { jQuery("#submit-story-form input[type='submit']").val("Submit"); //jQuery("div.trigger").css("font-size","16px"); } var winheight = jQuery(window).height()*.9; var topmargin = jQuery(window).height()*.05; winheight = (winheight-topmargin); jQuery(".success-stories-submit-form.popup form").height(winheight).css("margin-top",topmargin+"px"); } function CloseSuccessStoriesSubmitFormPopup(){ jQuery(".success-stories-submit-form.popup").removeClass("active").removeClass("done"); jQuery("body").removeClass("success-stories-submit-form-active"); submitAnotherStory(); } function submitAnotherStory(){ jQuery('#submit-story-form').trigger('reset'); jQuery('#submit-story-form fieldset').fadeIn(500); jQuery('#submit-story-form .form-notification').fadeOut(500); jQuery('.custom-file-input').html(jQuery('.custom-file-input').html()); jQuery("#submit-story-form input[type='submit']").val("Submit Your Story"); jQuery('.custom-file-input').html(jQuery('.custom-file-input').html()).removeClass("upload-ready").removeClass("upload-invalid"); jQuery('.custom-file-input div').html('
Click Here to Upload a Photo
'); } var allowedUploadTypes = ",.gif,.jpeg,.jpg,.png,.xbmp,"; function checkUploadFileSelection(e){ jQuery('.custom-file-input input[type="file"]').blur(); if (jQuery('.custom-file-input input[type="file"]').val() != "") { //if(!jQuery('.custom-file-input .select').length || jQuery('.custom-file-input .select').length){ //alert(jQuery('.custom-file-input input[type="file"]').val().substr(jQuery('.custom-file-input input[type="file"]').val().lastIndexOf("\\")+1)); if( allowedUploadTypes.indexOf(","+jQuery('.custom-file-input input[type="file"]').val().toLowerCase().substr(jQuery('.custom-file-input input[type="file"]').val().lastIndexOf("."))+",") == -1 ){ if(!jQuery('.custom-file-input').hasClass("upload-invalid")){ jQuery('.custom-file-input').addClass("upload-invalid").removeClass("upload-ready"); jQuery('.custom-file-input div').html("
Invalid file type (click to select another)
"); } } else if(!jQuery('.custom-file-input').hasClass("upload-ready")){ jQuery('.custom-file-input').addClass("upload-ready").removeClass("upload-invalid"); //jQuery('.custom-file-input div').html("
"+jQuery('.custom-file-input input[type="file"]').val().substr(jQuery('.custom-file-input input[type="file"]').val().lastIndexOf("\\")+1)+"
X
"); jQuery('.custom-file-input div').html("
Reset
Ready to upload (click to change)
"); } jQuery('.custom-file-input div .remove').mousedown(function(){ jQuery('.custom-file-input').html(jQuery('.custom-file-input').html()).removeClass("upload-ready").removeClass("upload-invalid"); jQuery('.custom-file-input div').html("Click Here to Upload a Photo"); return false; }); //} } } jQuery(document).ready(function(){ window.setTimeout(function(){ jQuery(".success-stories-submit-form form#submit-story-form").submit(function(e){ e.preventDefault(); SubmitSuccessStory(); //return false; }); },1400); }); function isValidEmail(emailAddress) { var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i); return pattern.test(emailAddress); } function IsValidPhone(p){ var phoneRe = /^[(]{0,1}[0-9]{3}[)]{0,1}[-\s\.]{0,1}[0-9]{3}[-\s\.]{0,1}[0-9]{4}$/; var digits = p.replace(/\D/g, ""); return phoneRe.test(digits); } function validateZipCode(zip) { var isValid = /^[0-9]{5}(?:-[0-9]{4})?$/.test(zip); if (!isValid) { return false; } else { return true; } } function emailsignupajax(iURL, formData){ console.log(iURL); jQuery.ajax({ type: "POST", url: iURL, data: formData, cache: false, dataType: "jsonp", jsonp: "c", // trigger MailChimp to return a JSONP response contentType: "application/json; charset=utf-8", error: function(error) { // According to jquery docs, this is never called for cross-domain JSONP requests // nmx added d20171511 /* ga('create', 'UA-741540-1', 'auto', {'name': 'nutramax'}); ga('nutramax.send', 'event', 'Conversion Popup', 'Join Our Mailing List', 'Subscribe failed');*/ }, success: function(data) { console.log(data); } }); } function SubmitSuccessStory(){ jQuery("head").append('