/*window.onerror = function(message, url, linenumber) { console.log(message+" Line:"+linenumber); return true; }*/ var nmxStoreSite = "https://store.nexternal.com"; var nmxStoreRoot = "/nutramax"; var nmxStoreHomepage = "/nutramax/all-our-products-c34.aspx"; // test.diamond.cosequinequine.com //jQuery("head").append(''); // register.aspx?PersistentBodyClass=RequirePromoCode // register.aspx?BodyClass=RequirePromoCode jQuery = nextQuery; var PromoCode = qs("PromoCode"); var nmxRetailerName = ""; jQuery("document").ready(function(){ //AutoActivateDiamondStore(); RequirePromoCode(); UpdateDiamondStore(); UseDiamondStoreHomepage(); //DiamondStoreActivation(); HandleStoreMemberRegistration(); }); jQuery(window).bind('hashchange',function(e){ RequirePromoCode(); }); function AutoActivateDiamondStore(){ if (Cookies.get("PromoCode") != undefined && !jQuery(".nextEquineCustomer").length && location.search.indexOf("DiamondStoreActivation")==-1){ console.log("auto activate diamond store"); jQuery("body.StoreAccessContentPage").append(''); } } function UpdateDiamondStore(){ //jQuery(".aspNetForm").attr("action",jQuery(".aspNetForm").attr("action").replace("?Coupon=DiamondStoreActivation","")); jQuery(".nextEquineCustomer [id*='tdCouponDiscountText'] *").hide(); jQuery(".nextEquineCustomer [id*='tdCouponDiscountText']").append('Diamond Store Discount:'); window.setTimeout(function(){ if (jQuery(".nextEquineCustomer").length && Cookies.get("PromoCode")!=undefined){ var nmxStoreHomepage = "/nutramax3/equine-c4.aspx"; jQuery(".nextEquineCustomer .nextCartCustomer").append(' 15% Off'); if (jQuery(".nextNotLoggedIn").length){ jQuery(".nextCartLogin").hide(); jQuery(".store-tools .nextCartCustomer").prepend('Register'); } } else{ //jQuery(".nextCartCustomer").append('TEST LINK'); } },800); if (jQuery("script[src*='mobile.js']").length){ UpdateDiamondStoreMobile(); } } function UpdateDiamondStoreMobile(){ jQuery(".nextEquineCustomer [id*='tdCouponDiscountText'] *, .nextCartDiscountRow *").hide(); jQuery(".nextEquineCustomer [id*='tdCouponDiscountText'], .nextCartDiscountRow").append('Diamond Store Discount:'); } /*function DiamondStoreActivation(){ jQuery(".nextEquineCustomer .nextCouponPopup .nextBannerText").text("Welcome"); jQuery(".nextEquineCustomer .nextCouponPopup > div > p:first").html("You are now in the Cosequin Equine Diamond Store. You will receive a 15% discount off all equine products.").show(); }*/ function RequirePromoCode(){ // NMX16090107RSP // NMX16090407RSP if(!jQuery(".nmxRegForm").length){ jQuery("body.RequirePromoCode .nextInnerTable.nextCartTable .main, body.CheckPromoCode .nextInnerTable.nextCartTable .main").prepend(''); jQuery("body.RequirePromoCode .nextInnerTable.nextCartTable .main > *, body.CheckPromoCode .nextInnerTable.nextCartTable .main > *").each(function(){ jQuery(this).appendTo(".nmxRegForm"); }); } if(jQuery("body.RequirePromoCode").length){ jQuery("body .StoreAccessContent").remove(); jQuery(".StoreAccessContent").hide(); document.location = document.location.href.replace(location.hash,"")+"#RequirePromoCode"; jQuery("body.RequirePromoCode .nextInnerTable.nextCartTable .main").append('Special Promotional OffersSome explaination should maybe go right here in this spot, or something at least something should be here below the heading. Some explaination should maybe go right here in this spot, or something at least something should be here below the heading.Enter your code here:').addClass("requestForm"); //jQuery("body.RequirePromoCode #accessCodeSubmit").focus(); jQuery("body.RequirePromoCode input#PromoCode").keyup(function(){ CheckStoreAccessCodeEntry(); }); jQuery("body.RequirePromoCode input#PromoCode").focus(); jQuery("body.RequirePromoCode .RequirePromoCodeForm").append(''); jQuery('#PromoCode').bind('keypress', function(e) {if(e.keyCode==13){ CheckStoreAccessCodeSubmit(); } }); jQuery('#PromoCode').focus(function(){ jQuery(".submitMsg").addClass("fadeout"); }); jQuery("body.RequirePromoCode").removeClass("RequirePromoCode").addClass("StoreAccessContentPage"); if(Cookies.get('PromoCode') != undefined && Cookies.get('EquineRetailer') != undefined){ jQuery("#PromoCode").val(Cookies.get('PromoCode')); jQuery(".enterStoreBtn").removeClass("disabled"); } //Cookies.get('PromoCode'); //Cookies.remove('EquineRetailer'); } if(jQuery("body.CheckPromoCode").length){ jQuery(".StoreAccessContent").hide(); //document.location = document.location.href.replace(location.hash,"")+"#CheckPromoCode"; jQuery("body.CheckPromoCode .nextInnerTable.nextCartTable .main").append('Validating promotional code...'+PromoCode+'').addClass("requestForm"); //window.setTimeout(function(){ //jQuery("body.CheckPromoCode").append('').removeClass("CheckPromoCode").addClass("StoreAccessContentPage"); //},100); console.log("validate promo code"); jQuery.getJSON( "http://ws.nutramax.biz/nutramax/promos/validate/?cid="+qs("cid"), function(json){ if(json.status=="valid"){ //jQuery(".surveys-survey-start").append('Not '+json.first_name+' '+json.last_name+'? click here'); jQuery("body").addClass("valid"); } else { if(json.error!=""){ jQuery(".surveys-survey-start").html(''+json.status+''+json.msg+'').show(); } } }); } //window.onhashchange=function(){ //if (location.hash.indexOf("RequirePromoCode")>-1){ RequirePromoCode(); } //else { console.log("no require code"); } //} } function ValidateAccessCode(){ // no longer required console.log("validating code"); if (jQuery(".nextCustomerCustomFieldLabelCell label:contains('Equine Retailer')").length){ if(nmxRetailerName != undefined){ window.setTimeout(function(){ StoreAccessOops(); },10); if(nmxRetailerName == "Invalid"){ window.setTimeout(function(){ StoreAccessSorry(); },10); } else{ window.setTimeout(function(){ StoreAccessWelcome(); },10); } } } } function StoreAccessSorry(){ jQuery(".StoreAccessContent").hide(); document.location = document.location.href.replace(location.hash,"")+"#StoreAccessSorry"; jQuery("body.StoreAccessContentPage .nextInnerTable.nextCartTable .main").append('Cosequin Equine Dimond StoreNMX25250514R-NA We\'re SorryWe did not find any dealer associated with the code you entered. Check your code card and try again or start shopping now. You entered: '+PromoCode+'').addClass("requestForm"); jQuery("body.StoreAccessContentPage .diamon-code-card-text").append('Try Another CodeShop the Cosequin Store'); Blink(".AccessCardPointer",660,114); } function StoreAccessOops(){ jQuery(".StoreAccessContent").hide(); //document.location = document.location.href.replace(location.hash,"")+"#StoreAccessOops"; jQuery("body.StoreAccessContentPage .nextInnerTable.nextCartTable .main").append('Cosequin Equine Dimond StoreOops!Store Unavailable').addClass("requestForm"); } function StoreAccessWelcome(){ console.log("access welcome"); jQuery(".StoreAccessContent").hide(); document.location = document.location.href.replace(location.hash,"")+"#StoreAccessWelcome"; Cookies.set("PromoCode",PromoCode); Cookies.set("EquineRetailer",nmxRetailerName.toTitleCase()); jQuery("body.StoreAccessContentPage .nextInnerTable.nextCartTable .main").append('Cosequin Equine Dimond StoreWelcome to the program!As a preferred customer of '+nmxRetailerName.toTitleCase()+', you will receive a 15% discount on all equine products.').addClass("requestForm"); jQuery("body.StoreAccessContentPage .diamon-code-card-text").prepend('Sponsoring Equine Dealer:'+nmxRetailerName.toTitleCase()+''+nmxRetailerAddr1+''+nmxRetailerCity+', '+nmxRetailerState+' '+nmxRetailerZip+''); /*var nmxRetailerName var nmxRetailerAddr1 var nmxRetailerCity var nmxRetailerState var nmxRetailerZip var nmxRetailerStoreNumber*/ jQuery("body.StoreAccessContentPage .diamon-code-card-text").append('Create an accountStart Shopping'); jQuery("body.StoreAccessContentPage .diamon-code-card-text").append(''); //jQuery(".nextEquineCustomer .nextRemoveCoupon").attr("href") /* jQuery.ajax({ url: 'equine-c4.aspx?Coupon=DiamondStoreActivation', context: document.body }).done(function() { UpdateDiamondStore(); console.log("UpdateDiamondStore"); });*/ //jQuery("body.StoreAccessContentPage .background-activate").load(nmxStoreSite+nmxStoreRoot+'/equine-c4.aspx?Coupon=DiamondStoreActivation #tdBottom', function(){ //jQuery("body.StoreAccessContentPage .diamon-code-card-text").append('Activation Complete'); //jQuery("body.StoreAccessContentPage .background-activate").show(); //}); AutoActivateDiamondStore(); } function UseDiamondStoreHomepage(){ if (jQuery(".nextEquineCustomer.nextCategory3").length){ document.location = nmxStoreSite+nmxStoreRoot+"/equine-c4.aspx"; } } function HandleStoreMemberRegistration(){ if (!jQuery(".nextRegister").length){ return; } jQuery(".nextRegister .nextPasswordTextCell").html(jQuery(".nextRegister .nextPasswordTextCell").html().replace("If you wish, you may c","C").replace("Nutramax Laboratories Veterinary Sciences, Inc. Online Store","Cosequin Equine Diamond Store")); jQuery(".nextRegister .nextCustomerCustomFieldLabelCell label:contains('Equine Retailer')").closest("tr").find("input[type=text]").val(Cookies.get("PromoCode")+" ("+Cookies.get("EquineRetailer")+")"); } function CheckStoreAccessCodeSubmit(){ if(jQuery("body .enterStoreBtn.disabled").length){ jQuery(".submitMsg").text("Not a valid code").removeClass("fadeout"); Blink(".AccessCardPointer",160,4); window.setTimeout(function(){ jQuery(".submitMsg").addClass("fadeout"); },4000); } else{ PromoCode = jQuery("input#PromoCode").val().trim(); jQuery("body").removeClass("RequirePromoCode").addClass("CheckPromoCode"); RequirePromoCode(); } } function CheckStoreAccessCodeEntry(){ jQuery("body input#PromoCode").val(jQuery("body input#PromoCode").val().toUpperCase()); if(jQuery("body input#PromoCode").val().replace(/-/g,"").length < 14){ jQuery("body .enterStoreBtn").addClass("disabled"); } else if(jQuery("body input#PromoCode").val().replace(/-/g,"").length > 14){ jQuery("body .enterStoreBtn").addClass("disabled"); jQuery("body input#PromoCode").val(jQuery("body input#PromoCode").val().substr(0,15)); } if(jQuery("body input#PromoCode").val().replace(/-/g,"").length == 14){ jQuery("body .enterStoreBtn").removeClass("disabled"); } } function Blink(selector,interval,blinks){ if(jQuery(selector+":visible").length) { jQuery(selector).hide(); } else { jQuery(selector).show(); } if (blinks < 1){ jQuery(selector).show(); return; } blinks=blinks-.5; window.setTimeout(function(){ Blink(selector,interval,blinks); },interval); } function qs(variable){ var query = window.location.search.substring(1); var vars = query.split('&'); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split('='); if (decodeURIComponent(pair[0]) == variable) { return decodeURIComponent(pair[1]).replace(/\+/g," "); } } //console.log('Query variable %s not found', variable); return "";//location.search; } String.prototype.toTitleCase = function() { var i, j, str, lowers, uppers; str = this.replace(/([^\W_]+[^\s-]*) */g, function(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); // Certain minor words should be left lowercase unless // they are the first or last words in the string lowers = ['A', 'An', 'The', 'And', 'But', 'Or', 'For', 'Nor', 'As', 'At', 'By', 'For', 'From', 'In', 'Into', 'Near', 'Of', 'On', 'Onto', 'To', 'With']; for (i = 0, j = lowers.length; i < j; i++) str = str.replace(new RegExp('\\s' + lowers[i] + '\\s', 'g'), function(txt) { return txt.toLowerCase(); }); // Certain words such as initialisms or acronyms should be left uppercase uppers = ['Id', 'Tv']; for (i = 0, j = uppers.length; i < j; i++) str = str.replace(new RegExp('\\b' + uppers[i] + '\\b', 'g'), uppers[i].toUpperCase()); return str; }
Some explaination should maybe go right here in this spot, or something at least something should be here below the heading. Some explaination should maybe go right here in this spot, or something at least something should be here below the heading.
Not '+json.first_name+' '+json.last_name+'? click here
'+json.msg+'
We did not find any dealer associated with the code you entered. Check your code card and try again or start shopping now.
You entered: '+PromoCode+'
Store Unavailable
As a preferred customer of '+nmxRetailerName.toTitleCase()+', you will receive a 15% discount on all equine products.
'+nmxRetailerAddr1+''+nmxRetailerCity+', '+nmxRetailerState+' '+nmxRetailerZip+'