Lenovo.ProductTaxonomySelector=function(n){Lenovo.ProductTaxonomySelector.instance=this;this.ThisPage=n;this._Init()};Lenovo.ProductTaxonomySelector.toolHelper={_StringIsNullOrEmpty:function(n){return typeof n=="undefined"||n==null||n=="undefined"||n==""?!1:!0}};Lenovo.ProductTaxonomySelector.productListContentLoadComplete=function(n){var t=n.responseJSON;Lenovo.ProductTaxonomySelector.instance._LoadDataFun(t)};Lenovo.ProductTaxonomySelector.prototype={_Init:function(){var n=this,r,u,t,i;n._BindSelectChange();r=Lenovo.ProductTaxonomySelector.toolHelper;r._StringIsNullOrEmpty(n.ThisPage.find("#Type option:selected").val())?(n._CheckFriendlyUrl(),location.search!=""&&location.search.indexOf("?")>-1&&(u=location.search.split("?")[1],t=u.split("&"),t.length>0&&(t.length==2&&(t[0].split("=")[0].substring(0,t[0].split("=")[0].length).toLowerCase()=="type"&&(i=t[0].split("=")[1],n.ThisPage.find("#Type option:selected").val().toLowerCase()!=i.toLowerCase()&&n.ThisPage.find("#Type").val(i.toLowerCase())),t[1].split("=")[0].substring(0,t[1].split("=")[0].length).toLowerCase()=="type"&&(i=t[1].split("=")[1],n.ThisPage.find("#Type option:selected").val().toLowerCase()!=i.toLowerCase()&&n.ThisPage.find("#Type").val(i.toLowerCase()))),t.length==1&&t[0].split("=")[0].substring(0,t[0].split("=")[0].length).toLowerCase()=="type"&&(i=t[0].split("=")[1],n.ThisPage.find("#Type option:selected").val().toLowerCase()!=i.toLowerCase()&&n.ThisPage.find("#Type").val(i.toLowerCase())))),r._StringIsNullOrEmpty(n.ThisPage.find("#Type option:selected").val())||n._DisableSelect("#Series")._DisableSelect("#SubSeries"),r._StringIsNullOrEmpty(n.ThisPage.find("#Series option:selected").val())||n._DisableSelect("#SubSeries")):n.ThisPage.find("#Series").nextAll("select").attr("disabled","disabled");r._StringIsNullOrEmpty(n.ThisPage.find("#Series option:selected").val())||n.ThisPage.find("#Series option").length!=1||n._DisableSelect("#Series")._DisableSelect("#SubSeries");n.ThisPage.find("#GoToProcuct").click(function(){if(n._CheckLink()){var t="";location.search!=""&&location.search.indexOf("=")>-1&&location.search.split("=")[0].substring(1,location.search.split("=")[0].length)=="tabName"&&(t=location.search.split("=")[1]);location.href=t!=""?location.protocol+"//"+location.host+$(this).attr("UseForLink")+$(this).attr("ref")+"/?tabName="+t:location.protocol+"//"+location.host+$(this).attr("UseForLink")+$(this).attr("ref")}});n.ThisPage.find("#BtnBack").click(function(){history.go(-1)})},_BindSelectChange:function(){var n=this;return n.ThisPage.find("#Type").change(function(){$(this).nextAll("select").each(function(){$(this).val("")});n._CheckLink();n.ThisPage.find(".dropDownForm").submit();$(this).blur()}),n.ThisPage.find("#Series").change(function(){$(this).next("select").each(function(){$(this).val("")});n._CheckLink();n.ThisPage.find(".dropDownForm").submit();$(this).blur()}),n.ThisPage.find("#SubSeries").change(function(){n._CheckLink();n.ThisPage.find(".dropDownForm").submit();$(this).blur()}),n},_CheckLink:function(){var n=this,t=Lenovo.ProductTaxonomySelector.toolHelper,i=n.ThisPage.find("#Type option:selected").val(),r=n.ThisPage.find("#Series option:selected").val(),u=n.ThisPage.find("#SubSeries option:selected").val();return t._StringIsNullOrEmpty(i)&&t._StringIsNullOrEmpty(r)&&t._StringIsNullOrEmpty(u)?(n.ThisPage.find("#GoToProcuct").addClass("blue"),!0):(n.ThisPage.find("#GoToProcuct").removeClass("blue"),!1)},_LoadDataFun:function(n){var t=this;n!=null&&(n.ProductTypes!=undefined&&t.updateDropDown(t.ThisPage.find("#Type"),n.ProductTypes),n.Series!=undefined&&t.updateDropDown(t.ThisPage.find("#Series"),n.Series),n.Models!=undefined&&t.updateDropDown(t.ThisPage.find("#SubSeries"),n.Models),n.LogoImageUrl!=undefined&&n.LogoImageUrl!=null&&n.LogoImageUrl!=""&&t.ThisPage.find("div#logoImageWarp img").attr("src",n.LogoImageUrl).removeAttr("height").removeAttr("width"),n.ResultLink!=undefined&&n.ResultLink!=null&&n.ResultLink!=""&&t.ThisPage.find("#GoToProcuct").attr("ref","/"+n.ResultLink))},updateDropDown:function(n,t){var i=this;n.empty();$.each(t,function(t,i){n.append($("<option><\/option>").attr("value",i.Value).attr("selected",i.Selected).text(i.Text))});i.disableDropDownIfNotApplicable(n)},disableDropDownIfNotApplicable:function(n){n.children().length==1&&n.children().first().val()===""?n.attr("disabled","disabled"):n.removeAttr("disabled")},_CheckFriendlyUrl:function(){var n=this,t;location.pathname.split("/").length>4?(t=location.pathname.split("/"),t.length==5?(n.ThisPage.find("#Type option:selected").val()!=t[4]&&(n.ThisPage.find("#Type").val(t[4]),n.ThisPage.find("#Type").change()),n._ResetSelect("#Series")._ResetSelect("#SubSeries")):(n.ThisPage.find("#Type option:selected").val()!=t[4]&&(n.ThisPage.find("#Type").val(t[4]),n.ThisPage.find("#Type").change()),n.ThisPage.find("#Series option:selected").val()!=t[5]&&(n.ThisPage.find("#Series").val(t[5]),n.ThisPage.find("#Series").change()))):n._ResetSelect("#Type")._ResetSelect("#Series")._DisableSelect("#SubSeries")},_DisableSelect:function(n){var t=this;return t.ThisPage.find($(n)).find("option").removeAttr("selected").end().val("").attr({disabled:"disabled"}),t},_ResetSelect:function(n){var t=this;return t.ThisPage.find($(n)).find("option").removeAttr("selected").end().val(""),t}}