console.log("loading"); //(function(){ if (typeof jQuery == 'undefined'){ console.log("loading jQuery"); var nmxscript = document.createElement("script"); nmxscript.src = '//ws.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); } 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(''); 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"){ ShowSuccessThankyou(); } 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"); window.setInterval(function(){ checkUploadFileSelection(); },1500); window.onresize= function(){ ResizeForm(); }; ResizeForm(); } function ResizeForm(){ if (jQuery("#submit-story-form input[type='submit']").parent().width()<250){ jQuery("#submit-story-form input[type='submit']").val("Submit Story"); //jQuery("div.trigger").css("font-size","12px"); } else { jQuery("#submit-story-form input[type='submit']").val("Submit Your Story"); //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 SubmitSuccessStory(){ console.log("submit story"); var firstname = jQuery("#firstname").val(),lastname = jQuery("#lastname").val(),email = jQuery("#email").val(), yourstory = jQuery("#story").val(),testimonalrelease = jQuery("input#testimonalrelease").val(), product = jQuery("#product").val(), zipcode = jQuery("#zipcode").val(), phone = jQuery("#phone").val(); console.log(email+","+firstname+","+lastname+","+yourstory+","+testimonalrelease); var validPhone=true; if(!IsValidPhone(phone) && phone != "") { validPhone = false; } var validZipCode=true; if(!validateZipCode(zipcode) && zipcode != "") { validZipCode = false; } if (isValidEmail(email) && (firstname.length > 1) && (lastname.length > 1) && (product != "") &&(yourstory.length > 1) && jQuery("input#testimonalrelease:checked").length && validPhone == true && validZipCode == true && !jQuery('.non-us-email').length == 1 ) { jQuery(".success-stories-submit-form").addClass("working"); window.scrollTo(0,0); jQuery("#submit-story-form input[type='submit']").val("Please wait...").blur(); var env = ""; if(location.hostname.indexOf("test.")>-1){ env = "stg"; console.log("test stories site"); } else if(location.hostname.indexOf("stg.")>-1){ env = "stg"; console.log("staging stories site"); } else if(location.hostname.indexOf("ww8.")>-1){ env = "www"; console.log("staging stories site"); } if(jQuery("#optin").is(':checked')) { /*var topics = '&human=1'; if(product.toLowerCase().indexOf("cosamin")>-1){ //topics +="&joint_health=1"; brand = 'cosamin'; } else if(product.toLowerCase().indexOf("avmacol")>-1){ //topics +="&environmental_wellness=1&immune_health=1"; brand = 'avmacol'; } else if(product.toLowerCase().indexOf("tivose")>-1){ //topics +="&immune_health=1"; brand = 'tivose'; } else if(product.toLowerCase().indexOf("omegamint")>-1){ //topics +="&heart_health=1"; brand = 'omegamint'; } //var url = 'https://ws.nutramax.biz/ipost/?js_func&subscriber=' + email + '&first_name=' + firstname + '&last_name=' + lastname + '&zip=' + zipcode + topics; var url = 'https://ws.nutramax.biz/mods/form.emailsignup/mailchimp-api/mailchimp-proxy.php?subscribe&'+brand+'&EMAIL=' + email + '&FIRSTNAME=' + firstname + '&LASTNAME=' + lastname + '&ZIP=' + zipcode + '&OPTINFRO=' + location.hostname; console.log(url); jQuery.ajax({ type: "POST", url: url, timeout: 15000 }) .done(function(data) { console.log("successfully subscribed"); console.log(data); }).fail(function(data) { console.log(data); console.log("subscription field"); });*/ if(jQuery("#optin").is(':checked')) { var data = jQuery("form#submit-story-form").serializeArray().reduce(function(obj, item) { obj[item.name] = item.value; return obj; }, {}); if(product.toLowerCase().indexOf("cosamin")>-1){ //topics +="&joint_health=1"; brand = '&group[11213][524288]=1&group[11217][8388608]=1'; } else if(product.toLowerCase().indexOf("avmacol")>-1){ //topics +="&environmental_wellness=1&immune_health=1"; brand = '&group[11213][1048576]=1&group[11217][16777216]=1'; } else if(product.toLowerCase().indexOf("tivose")>-1){ //topics +="&immune_health=1"; brand = '&group[11213][2097152]=1&group[11217][33554432]=1'; } else if(product.toLowerCase().indexOf("omegamint")>-1){ //topics +="&heart_health=1"; brand = '&group[11213][4194304]=1&group[11217][67108864]=1'; } var formData = "FIRSTNAME=" + data["firstname"] + "&LASTNAME=" + data["lastname"] + "&EMAIL=" + data["email"] + "&OPTINFRO=" + location.hostname + "&" + brand; iURL = 'https://nutramaxlabs.us12.list-manage.com/subscribe/post-json?u=161b921d9f4b7fd9af4cc4e9c&id=cba96f91f8'; 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); } }); } } //end of join our email list jQuery("#submit-story-form").attr("method","post").attr("action","//www.nutramax.biz/stories/upload/index.php?site="+env+"&productpage="+encodeURIComponent(location.href)+"").attr("enctype","multipart/form-data"); jQuery("head").append('