var myHub=myHub||{},isFirstTimeLoading=!0;myHub={init:function(){myHub.miniSurvey(),myHub.cityAutoComplete(),myHub.addToFavBtn(),myHub.simpleBin(),myHub.weatherTextField(),myHub.mobContent(),myHub.responsiveImage(),myHub.scrollTop(),myHub.homePageMobileCrlImagEvt(),myHub.homePageCraousalNav(),myHub.responsiveIframe()},weatherTextField:function(){$(".skincareTips").length>0&&navigator.userAgent.toLowerCase().indexOf("iphone")>-1&&$('.skincareTips input[type="text"]').addClass("iphoneInput")},scrollTop:function(){$(".top-scroll").on("click",function(){var n=$(this);return $("html, body").animate({scrollTop:0},400,function(){n.fadeOut(300)}),!1});checkHeight=function(n){var t=$(n).offset().top+$(n).height()-$("footer").offset().top;$(n).find(".top-scroll").css({bottom:t+"px",position:"absolute"}),$(n).css("position","relative"),$(document).scrollTop()+window.innerHeight<$("footer").offset().top&&($(n).find(".top-scroll").css({bottom:"0",position:"fixed"}),$(n).css("position","absolute"))},$(window).scroll(function(){checkHeight(".top-scroll-inner"),$(window).scrollTop()>80?$(".top-scroll").fadeIn(300):$(window).scrollTop()<70&&$(".top-scroll").fadeOut(300)})},checkBazaarVoice:function(){var n=$("#BVRRSummaryContainerWrapper #BVRRSummaryContainer .bv-cleanslate");if(n.length){setTimeout(function(){$(".expandCollaspetab.bvReviewsContainer span.text").hasClass("bvTextActive")||($(".expandCollaspetab.bvReviewsContainer span.text").addClass("bvTextActive"),$(".expandCollaspetab.bvReviewsContainer span.text").html($("#BVRRSummaryContainerWrapper #BVRRSummaryContainer").html()),$(".expandCollaspetab.bvReviewsContainer span.text").prepend("<div class='cloneReviews'></div>")),$(".expandCollaspetab.bvReviewsContainer .toggle_container .bv-content-placeholder ").length&&$(".expandCollaspetab.bvReviewsContainer").hide()},1e3),$(".expandCollaspetab.bvReviewsContainer .expand_heading a.readMore").css("margin-top","-20px");$(".cloneWrapper").on("click",function(){$(".expandCollaspetab.bvReviewsContainer .toggle_container .bv-content-placeholder ").length?$(".expandCollaspetab.bvReviewsContainer .expand_heading.pdpRange").removeClass("active"):($(".expandCollaspetab.bvReviewsContainer .toggle_container").show().slideDown("fast"),$(".expandCollaspetab.bvReviewsContainer .expand_heading.pdpRange").addClass("active"),$("body, html").animate({scrollTop:$(".expandCollaspetab.bvReviewsContainer").offset().top},"fast")),$(".expandCollaspetab.bvReviewsContainer .expand_heading").hasClass("active")?$(".expandCollaspetab.bvReviewsContainer").css("border-bottom","none"):$(".expandCollaspetab.bvReviewsContainer").css("border-bottom","1px solid #DBDBDC")});$(".cloneWrapper").css({top:"290px",left:"119px"})}else $(".conentMainContainer .mobileContent.reviewStars").html($(".readMoreReviewsContainer #averageRating .ratingReviewsContainer").html()),$(".cloneWrapper").css({top:"299px",left:"119px"})},mobContent:function(){$(window).width()<=MODULE.config.mobileBreakpoint?myHub.callMobileFunction():$(".toggle_container .simpleRating").remove(),$(window).resize(function(){var t=$("#BVRRSummaryContainerWrapper #BVRRSummaryContainer .bv-cleanslate");$(window).width()<=MODULE.config.mobileBreakpoint?myHub.callMobileFunction():($("#BVRRSummaryContainerWrapper").css({position:"static"}),$(".readMoreReviewsContainer .viewMoreReviewsContainer .expand_heading").hasClass("active")?$(".readMoreReviewsContainer .viewMoreReviewsContainer .viewMoreReviews").text("Read less reviews"):$(".readMoreReviewsContainer .viewMoreReviewsContainer .viewMoreReviews").text("View more reviews"),t.length&&$(".pdpInnerPageContent .conentMainContainer .socialMedia").css("margin","25px 0 0 0"))})},callMobileFunction:function(){$(".pdpInnerPageContent .conentMainContainer .socialMedia").css("margin","10px 10px 25px 59px"),$("#BVRRSummaryContainerWrapper").css({position:"absolute"}),myHub.wrapRelVideoContent(),myHub.checkBazaarVoice(),myHub.socialMediaTab(),$(".readMoreReviewsContainer .viewMoreReviewsContainer .viewMoreReviews").html($(".readMoreReviewsContainer #averageRating .starRatings").html()),$(".readMoreReviewsContainer .expandCollaspetab .toggle_container").appendTo(".readMoreReviewsContainer .expandCollaspetab")},wrapRelVideoContent:function(){var t=$(".leftPanelContainer .relatedVideo .relatedVideoContainer"),n;t.length?(n=t.html(),$(".expandCollaspetab.relatedVideoContainer .toggle_container").html(n)):$(".expandCollaspetab.relatedVideoContainer").css("display","none")},socialMediaTab:function(){isFirstTimeLoading==!0&&($(".headerSocialMedia figure:eq(0)").addClass("activate"),$(".newsFeedContainer article:eq(0)").addClass("activeTab")),$(".headerSocialMedia figure").click(function(){var n=$(this).index();$(".headerSocialMedia").find("figure").removeClass("activate"),$(this).addClass("activate"),$(".newsFeedContainer").find("article").removeClass("activeTab").end().find("article:eq("+n+")").addClass("activeTab"),isFirstTimeLoading=!1})},miniSurveyData:function(n){var t=n;console.log(t),$.ajax({url:t,cache:!1,type:"POST",success:function(n){myHub.miniSurveyFetchData(n)},error:function(){return MODULE.desktopSite.validateTimeOut(),!1}})},miniSurvey:function(){if($("#surveyCon").length>0){var n=$("#surveyCon").data("path");$.ajax({url:n,type:"POST",cache:!1,success:function(n){if($("#surveyCon").html(n),$("#miniSurvayCon").length){var t=$("#miniSurvayCon").data("action");myHub.miniSurveyFetchData("",t)}},error:function(){return MODULE.desktopSite.validateTimeOut(),!1}})}$("#startMiniSurvey").live("click",function(n){n.preventDefault();var i=$(this).data("action"),t=$(this).attr("data-survayCon");$.ajax({url:t,type:"POST",cache:!1,success:function(n){$("#surveyCon").html(""),$("#surveyCon").html(n),myHub.miniSurveyFetchData("",i)},error:function(){return MODULE.desktopSite.validateTimeOut(),!1}})})},miniSurveyFetchData:function(n,t){var i=t;$.ajax({type:"POST",dataType:"json",cache:!1,data:JSON.stringify(n),url:i,success:function(n){var t,r,i;MODULE.desktopSite.validateTimeOut(),t=n.replace(/[\\]/gi,""),t=$.parseJSON(t),t.redirectTo!=undefined&&(r=t.SurveyID.toString(),i=t.redirectTo+"?userSurveyID="+r,document.location.href=i),myHub.miniSurveyCrQuestionaire(t)},error:function(){MODULE.desktopSite.validateTimeOut()}})},miniSurveyCrQuestionaire:function(n){var t=n,f=$("#surveyCon h2").empty(),s=$("#surveyCon p").empty(),o=$("#surveyCon .optionsListCon ul").empty(),e=$(".crQuestion").empty(),h=$(".tQuestion").empty(),u="",r="",c="",i;f.text(t.stepDescription),s.text(t.question),e.text(t.questionOrder),h.text(t.minisurveytotalQuestions),t.questionOption!=null&&$.each(t.questionOption.questionOptionList,function(n,i){i.isSelected.toLowerCase()=="true"?(u="checked",r=t.type.toLowerCase()=="radio"?"radioSelected":"checkSelected"):(r="",u=""),qOption=i.optionType.toLowerCase()=="image"?'<img src="'+i.imageOption+'" />':i.option;var f=$("<li><input type='"+t.type+"' index='"+n+"' name='option' id='"+i.optionId+"' "+u+"  data-action='"+i.selectiontype+"'/><label for='"+i.optionId+"' class='"+r+"'> "+qOption+"</label></li>");o.append(f)}),t.message!=undefined&&(i=$("#surveyCon").data("path"),t.message.toLowerCase().indexOf("101")!=-1&&(i=i+"?thankyou=true"),$.ajax({url:i,type:"POST",cache:!1,success:function(n){$("#surveyCon").html(""),$("#surveyCon").html(n)},error:function(){return MODULE.desktopSite.validateTimeOut(),!1}})),$("#nextMiniQuestion").bind("click",function(n){n.preventDefault();var i=$(this).attr("id");myHub.miniSurveyNextSubmit(t,i)});$("input[type=checkbox]").on("click",function(){$(this).data("action")===1?($(this).parent().siblings().find("input").removeAttr("checked"),$(".ie8").length&&$(this).parent().siblings().find("input").next().removeClass("checkSelected")):($("input[data-action=1]").removeAttr("checked"),$(".ie8").length&&$("input[data-action=1]").next().removeClass("checkSelected"))})},miniSurveyNextSubmit:function(n,t){var i=n,u=t,e=new Date,o,r,f;if(i.dateTime=MODULE.desktopSite.formatDate(e),u.toLowerCase()=="nextminiquestion"){if(i.action="next",o=parseInt($("input[name='option']:checked").attr("index"),10),$("input[name='option']:checked").length==0)return $("#surveyCon .error").length==0&&$("div.errorContainer").html('<div class="error">'+i.errorMessage+"</div> "),!1;$(".error").length&&$(".error").remove(),$.each(i.questionOption.questionOptionList,function(n,t){t.isSelected="",$("input[name='option']:checked").each(function(){if(n==parseInt($(this).attr("index"),10)){t.isSelected="true";return}})}),$("#miniSurvayCon").attr("data-action",i.nextURL),i.action="next"}u.toLowerCase()=="backquestion"&&($("figure."+i.stepId).removeClass("active").css("opacity","0.2").nextAll().css("opacity","0.2"),$(".error").remove(),i.action="previous"),u.toLowerCase()=="pagesubmit"&&(r=$(".optionRef textarea").val().replace(/</g,"&lt;"),r=r.replace(/>/g,"&gt;"),i.action="submit",i.answerText=r,$("#questionairePage .optionContainer").hide()),$("#"+t).unbind("click"),t.toLowerCase()==="nextminiquestion"?$("#"+t).click(function(n){return n.preventDefault,!1}):$("#"+t).unbind("click"),f=$("#miniSurvayCon").attr("data-action"),myHub.miniSurveyFetchData(i,f),$("#"+t).bind("click")},cityAutoComplete:function(){$("#mobile").live("keypress",function(n){n.which==13&&(n.preventDefault(),$("#SubmitMobile").click())});$(document).on("click","#changeLocation",function(n){uSimple.waterMark(),n.preventDefault(),$("div.weatherCon, div.weatherBtn").hide(),$("div#changeLocationCon").show()});$("#SubmitMobile").live("click",function(){var i,t,n;if($("#mobile").val().length==0)return $("#mobileNumberFormatErrorMsg").css("display","inline-block"),!1;if(i=MODULE.desktopSite.mobileNumberValidation(),i===!1)return!1;if(!$("#mobileSMSSubscription").is(":checked")&&$("#mobile").val().length>0)return $("#smsSubscriptionErrorMsg").show(),!1;$("#smsSubscriptionErrorMsg").hide(),t=$("#mobile").val(),n=$("#mobileSMSSubscription").val(),$("#loaderOverlay").show(),$.ajax({url:MODULE.config.saveMobile,type:"POST",data:{mobile:t,mobileOptIn:n},success:function(n){$("#loaderOverlay").hide(),$(".skincareTips").replaceWith(n)},error:function(){return MODULE.desktopSite.validateTimeOut(),!1}})}),$("#mobileSMSSubscription").click(function(){var n=$("#mobile").val();$rErrror=$("#mobileSMSSubscription").data("valid"),$(this).attr("checked")||n.length!=0?$("#smsSubscriptionErrorMsg").hide():$(".smsError").length==0&&$("#smsSubscriptionErrorMsg").show()})},getWeatherInformation:function(n,t){var u=n,f=t,i=u[f],r=MODULE.config.saveCity;$("#loaderOverlay").show(),$.ajax({url:r,type:"POST",data:i,success:function(n){$("#loaderOverlay").hide();var t=$(n).filter("article.skincareTips").html();$(".skincareTips").html(t),uSimple.waterMark()},error:function(){return MODULE.desktopSite.validateTimeOut(),!1}})},addToFavBtn:function(){$(".favoriteText").length>0&&$("a.favoriteBtn").click(function(n){n.preventDefault();var t="",i=$(".favoriteBtn span");$(i).hasClass("favoriteIconBtn")?(t=$(this).data("action-add"),$(this).attr("title",$(this).data("remove-title"))):(t=$(this).data("action-remove"),$(this).attr("title",$(this).data("add-title"))),$.ajax({url:t,type:"POST",success:function(){var r=$(".favoriteBtn").attr("data-add-text"),i=$(".favoriteBtn").attr("data-remove-text"),t=$(".favoriteBtn span");n.preventDefault(),$(t).hasClass("favoriteIconBtnActive")?($(".favoriteBtn span").removeClass("favoriteIconBtnActive"),$(".favoriteBtn span").addClass("favoriteIconBtn"),$(".heroContent").find(".favoriteIconActive").remove(),$(".favoriteBtn span").text(r)):($(".favoriteBtn span").removeClass("favoriteIconBtn"),$(".favoriteBtn span").addClass("favoriteIconBtnActive"),$(".heroContent figure").before('<div class="favoriteIconActive" />'),$(".favoriteBtn span").text(i))},error:function(){return MODULE.desktopSite.validateTimeOut(),!1}})})},simpleBin:function(){$(document).on("click","#SimpleHub .buyNow,#pdpWtb .buyNow",function(n){n.preventDefault();var t=$("#binURL").data("action");MODULE.helper.simpleLightBox("simpleBin",t)})},responsiveImage:function(){$(window).on("resize",function(){$(".resImage").length&&$("body").find(".resImage").each(function(){var i,t;$(window).width()<=MODULE.config.mobileBreakpoint?(t=$(this).data("mobile-image"),i=$(this).closest("li").find(".defaultBtn").attr("href"),$(this).attr("src",""),$(this).attr("src",t),$(this).data("imgLink",i)):(t=$(this).data("dektop-image"),$(this).attr("src",""),$(this).attr("src",t))})}).resize()},homePageCraousalNav:function(){if($("#home-Carousel").length){var t=$("#contentArea").width()/2,n=$("#home-Carousel #nav").width()/2;$fWidth=t-n,$("#home-Carousel #nav").css("left",$fWidth)}},homePageMobileCrlImagEvt:function(){if($(window).width()<=MODULE.config.mobileBreakpoint)$(".homeCarousel").on("click",".resImage",function(){var t=$(this).data("imgLink");window.location.href=t})},responsiveIframe:function(){$("#simpleIFrame").length&&$(window).resize(function(){var t=$("#simpleIFrame"),u=$(window).width(),f=t.attr("data-desktopHeight"),i=t.attr("data-mobileHeight"),r=u<=MODULE.config.mobileBreakpoint?i:f;t.attr("height",r)}).resize()}},$(function(){myHub.init()}),$(window).load(function(){var t=$(".serachNav .countrySelector").html(),n;$(window).width()<=769&&$("#MobileCountrySelector").html(t),$(document).width($(document).width()+10+"px"),n=$("#BVRRSummaryContainerWrapper #BVRRSummaryContainer .bv-cleanslate"),n.length&&($(".expandCollaspetab.bvReviewsContainer span.text").hasClass("bvTextActive")||($(".expandCollaspetab.bvReviewsContainer span.text").addClass("bvTextActive"),$(".expandCollaspetab.bvReviewsContainer span.text").html($("#BVRRSummaryContainerWrapper #BVRRSummaryContainer").html()),$(".expandCollaspetab.bvReviewsContainer span.text").prepend("<div class='cloneReviews'></div>"),$(".expandCollaspetab.bvReviewsContainer .expand_heading a.readMore").css("margin-top","-20px")));$(".cloneWrapper").on("click",function(){$(".expandCollaspetab.bvReviewsContainer .toggle_container .bv-content-placeholder ").length?$(".expandCollaspetab.bvReviewsContainer .expand_heading.pdpRange").removeClass("active"):($(".expandCollaspetab.bvReviewsContainer .toggle_container").show().slideDown("fast"),$(".expandCollaspetab.bvReviewsContainer .expand_heading.pdpRange").addClass("active"),$("body, html").animate({scrollTop:$(".expandCollaspetab.bvReviewsContainer").offset().top},"fast")),$(".expandCollaspetab.bvReviewsContainer .expand_heading").hasClass("active")?$(".expandCollaspetab.bvReviewsContainer").css("border-bottom","none"):$(".expandCollaspetab.bvReviewsContainer").css("border-bottom","1px solid #DBDBDC")});$(document).width($(document).width()-10+"px")})