var hidetimeout=null;var xhr=null;var ataAjaxCallsCount=0;var ataAjaxStartTime;var nonataCharCount=0;var ataElapsed;var ataSearchBoxLocation="Top";var numOfATAChars;var searchTerm;var isAta=false;var scopeCategoryId=0;var scopeCatgoryName="All";var scopeTranslatedCategoryName="";var disableScopeSearch;var preferredLanguage="";$(document).ready(function(){if(autoSuggestionEnabled=="0"){return}var g=window.location.pathname.indexOf("Mouser_Web")>0?"/Mouser_Web/":"/";var d=g+(enableNewTypeAhead=="1"?"api/TypeAhead/GetAttributedResults":"ajax/autosuggestion.ashx");
var c=getPreferencesCookie();if(c.pl){preferredLanguage=c.pl}if(preferredLanguage.trim()==""){preferredLanguage="en-US"}var b=$("#search-bar input[name$=keyword], #search-bar input[name$=txt1], input[name$=txtPartKeywordSearch]");var e=$("#search-block").find("input[id$=auimgon]");if(e.length==0){$("#search-bar input[name$=keyword]").after("<input class='ac-ac_div' readonly='readonly' id='auimgon' style='right:15px;top:6px;z-index:3;' />")}var f=$("#searchPartNumberBox").find("input[id$=auimgon]");if(f.length==0){$("input[name$=txtPartKeywordSearch]").after("<input class='ac-ac_div' readonly='readonly' id='auimgon' style='right:35px;float:right;top:10px' />")
}$("input[id=auimgon]").attr("title",auOnMsg);if(!c.as||(c.as&&c.as=="1")){var a=1;$("input[id=auimgon]").hide();b.autoSuggest(d,{host:window.location.protocol+"//"+window.location.host+g,minChars:a,matchCase:false,preferredLanguage:preferredLanguage,extraParams:"&preferredLanguage="+preferredLanguage});if(!$(document.activeElement).is(":input")&&b.length>0){b.first().focus();b.first().blur();b.first().focus()}b.attr("autocomplete","off")}$("input[id=auimgon]").click(function(){var h=getPreferencesCookie();if(h.as&&h.as=="0"){$("input[id=auimgon]").hide();
h.as=1;h.setCookie({expires:365,path:"/",domain:subdomainname,secure:false});$(this).attr("autocomplete","off");b.autoSuggest(d,{host:window.location.protocol+"//"+window.location.host+g,minChars:a,matchCase:false,preferredLanguage:preferredLanguage,extraParams:"&preferredLanguage="+preferredLanguage})}});b.keypress(function(h){if(h.which==13){TrackTypeAheadAjaxCalls()}});$("div[id=searchPartNumberBox] input.searchbutton").click(function(){TrackTypeAheadAjaxCalls()});if(!disableScopeSearch){EnableScopeSearch()
}});$(document).click(function(b){try{$(".as-results").hide()}catch(a){}});jQuery.expr[":"].Contains=jQuery.expr.createPseudo(function(a){return function(b){return jQuery(b).text().toUpperCase().indexOf(a.toUpperCase())>=0}});function sortLi(d,c){return c.innerHTML.length-d.innerHTML.length}function GATracking(f,e,b,a,c,d){ga("send","event","Type Ahead",""+f+"",""+decodeURIComponent(e)+"",(a+("0"+c).slice(-2)),{dimension57:""+(ataSearchBoxLocation=="Top"?(ataSearchBoxLocation+"|"+d):ataSearchBoxLocation)+"",dimension58:""+decodeURIComponent(b)+""})
}function GATrackingAttributedTypeAheadAjaxCount(){if(typeof searchTerm!="undefined"&&ataAjaxCallsCount>0){ga("send","timing","Attributed Type Ahead Ajax Count",""+(searchTerm.length-nonataCharCount)+"",(ataAjaxStartTime-new Date().getMilliseconds()),""+searchTerm+"",{dimension57:""+ataSearchBoxLocation+"",metric3:+ataAjaxCallsCount})}}function TrackTypeAheadAjaxCalls(){if(enableAtaGATrackingEstimatedAjaxCalls==="1"){GATrackingAttributedTypeAheadAjaxCount()}}function NicePrint(a){if(preferredLanguage=="ja-JP"||preferredLanguage=="zh-CN"||preferredLanguage=="zh-CHT"||preferredLanguage=="zh-CHS"||preferredLanguage=="ko-KR"){if(a.length>10){return a.substring(0,9)+"..."
}return a}if(a.length>18){return a.substring(0,17)+"..."}return a}var scopeHistoryList=[];function EnableScopeSearch(){scopeOptionClick();$("div[id=scopeOptionDiv]").removeClass("hidden-scope-ddl");$("div[id=search-bar]").addClass("input-group");$("div[id=scopeOptionDiv] .dropdown-menu li:eq(0) a").addClass("selected");$(".scope-options a").each(function(){$(this).attr("href","javascript:void(0)")});$("#search-bar input[name$=keyword]").click(function(){if($("div[id=scopeOptionDiv]").hasClass("open")){$("div[id=scopeOptionDiv]").removeClass("open")
}});$("div[id=scopeOptionDiv] .dropdown-menu .accordion").click(function(){if($(this).find(".glyphicon-minus").length>0){$(this).find(".glyphicon-minus").removeClass("glyphicon-minus").addClass("glyphicon-plus");var a=$(this).attr("group");$(this).parent().find("[group="+a+"]:gt(0)").hide()}else{$(this).find(".glyphicon-plus").removeClass("glyphicon-plus").addClass("glyphicon-minus");var a=$(this).attr("group");$(this).parent().find("[group="+a+"]:gt(0)").show()}$("div[id=scopeOptionDiv] .dropdown-menu").dropdown("toggle")
})}function scopeOptionClick(){$("div[id=scopeOptionDiv] .dropdown-menu li a").click(function(){var d=scopeTranslatedCategoryName=$(this).text();var b=scopeCategoryId=$(this).data("value");scopeCatgoryName=$(this).attr("eng");$(this).parents(".input-group").find("[name=scopeOptions]").html(NicePrint(d)+' <span class="caret"></span>');$(this).parents(".input-group").find("[name=ScopeSelection]").val(b);$(this).parents(".input-group").find("[name=scopeOptions]").attr("title",d);navids=0;$("div[id=scopeOptionDiv] .dropdown-menu li a").removeClass("selected");
$(this).addClass("selected");var a=$("#search-bar input[name$=txt1], #search-bar input[name$=keyword]");if(a.val()!=""){var c=jQuery.Event("keydown");c.keyCode=65;a.trigger(c)}a.focus()})}function scopeHistoryItem(b,c,a){this.category=b;this.id=c;this.selectedCount=a}function LoadScopeHistory(){scopeHistoryList=JSON.parse(localStorage.getItem("scopeHistory_"+lang));if(scopeHistoryList!=null&&scopeHistoryList.length>0){for(var a=0;a<scopeHistoryList.length;a++){$("div[id=scopeOptionDiv] .dropdown-menu .historyHeader").after('<li><a data-value="'+scopeHistoryList[a].id+'" group="history" href="javascript:;" style="display:none;">'+scopeHistoryList[a].category+"</a></li>")
}}else{scopeHistoryList=[]}}function DeleteScopeHistory(b){for(var a=0;a<scopeHistoryList.length;a++){if(scopeHistoryList[a].category===b){scopeHistoryList.splice(a,1);break}}}function AddScopeHistory(d,f){for(var c=0;c<scopeHistoryList.length;c++){if(scopeHistoryList[c].category===d){var a=parseInt(scopeHistoryList[c].selectedCount);var e=a+1;var b=scopeHistoryList[c];scopeHistoryList.splice(c,1);scopeHistoryList.push(new scopeHistoryItem(b.category,b.id,e));localStorage.setItem("scopeHistory_"+lang,JSON.stringify(scopeHistoryList));
return}}scopeHistoryList.push(new scopeHistoryItem(d,f,1));localStorage.setItem("scopeHistory_"+lang,JSON.stringify(scopeHistoryList))}function DeleteAllScopeHistory(){localStorage.removeItem("scopeHistory_"+lang);$("div[id=scopeOptionDiv] .dropdown-menu").find("[group=history]:gt(0)").parent("li").remove()};