if (typeof epx_core === 'undefined') {
epx_loaded = false;
epx_core = function(s) {this.s = s;}
epx_core.prototype = {
exec: function(func, checkFunc, retry) {
if (retry) retry++; else retry = 1;
if (checkFunc()) {func();} else if (retry <= this.s.maxRetry) {var t = this.s.delay * retry;setTimeout(function() {epx_core_i.exec(func, checkFunc, retry);}, t);}
},
load: function() {function epx_htmlDecode(a){return jQuery("
").html(a).text()}function epx_htmlEncode(a){return $("").text(a).html()}function epx_createDelegate(a,b){return function(){b.apply(a)}}if(typeof epx_timer==="undefined"){epx_timer=function(a,b){this._interval=a;this._enabled=false;this._timer=null;jQuery(this).bind("tick",this,b)};epx_timer.prototype={set_enabled:function(a){if(a!==this._enabled){this._enabled=a;a?this._startTimer():this._stopTimer()}},_timerCallback:function(){jQuery(this).trigger("tick")},_startTimer:function(){this._timer=window.setInterval(epx_createDelegate(this,this._timerCallback),this._interval)},_stopTimer:function(){window.clearInterval(this._timer);this._timer=null}}}epx_searchBoxState=function(){this.userSelectedTermFlag=false;this.userSelectedWordFlag=false;this.autocompleteTermsShownFlag=false;this.autocompleteWordsShownFlag=false};epx_searchBoxState.prototype={userSelectedTerm:function(){this.userSelectedTermFlag=true},userSelectedWord:function(){this.userSelectedWordFlag=true},autocompleteTermsShown:function(){this.autocompleteTermsShownFlag=true},autocompleteWordsShown:function(){this.autocompleteWordsShownFlag=true},getInstrumentationValue:function(){var a=0;if(!this.autocompleteTermsShownFlag)a=1;if(this.autocompleteTermsShownFlag)a=2;if(this.userSelectedTermFlag)a=3;if(!this.autocompleteTermsShownFlag&&!this.autocompleteWordsShownFlag)a=4;if(this.autocompleteWordsShownFlag&&!this.userSelectedWordFlag)a=5;if(this.autocompleteWordsShownFlag&&this.userSelectedWordFlag)a=6;return a}};epx_searchBoxCount=0;epx_searchBox=function(a){this.instanceId=epx_searchBoxCount++;this.sbData=a;this.serviceRequestDelay=400;this.flyoutSpeed=150;this.maxTerms=8;this.termItems=[];this.matchType="None";this.selectedTermIndex=-1;this.textBackground="#ffffff";this.state=new epx_searchBoxState;this.searchExecuting=false;this.flyoutEnabled=true;this.flyoutFocused=false;this.focused=false;this.wordMatchString="Word";this.termMatchString="Term";this.terms=[];this.textAlign="left";if(this.sbData.isRTL)this.textAlign="right";this.listStyle={"list-style":"none",padding:"4px 2px 0px 1px",cursor:"pointer",margin:"1px","white-space":"nowrap"};this.itemNormalStyle={backgroundColor:this.textBackground,"text-decoration":"none"};this.itemHoverStyle={"text-decoration":"underline",backgroundColor:"#eeeeee"}};epx_searchBox.prototype={loadTermsFromService:function(){this.requestTimer.set_enabled(false);var a=jQuery.trim(this.searchBoxElement.value),b=1024;if(a.length>=this.sbData.minimumTermLength&&a.length<=b&&!this.searchExecuting){var c=this.sbData.serviceUri+"Data/Terms?callback=?&t="+encodeURIComponent(a)+"&a="+this.sbData.appId+"&s="+this.sbData.scopeId+"&m="+this.maxTerms+"&mtl="+this.sbData.minimumTermLength;jQuery.ajax({url:c,success:this.termcb,global:false,dataType:"jsonp",context:this})}},instrumentSearch:function(a){var c=Math.floor(Math.random()*1e9),d=this.sbData.serviceUri+"Data/IS?a="+this.sbData.appId+"&s="+this.sbData.scopeId+"&t="+a+"&ac="+this.state.getInstrumentationValue();+"&rnd="+c;var b=new Image;b.src=d},updateTerms:function(){var a=jQuery.trim(this.searchBoxElement.value);if(!this.searchBoxElement.watermarkShown&&a.length>=this.sbData.minimumTermLength){if(a!==this.lastTerm){this.lastTerm=a;this.requestTimer.set_enabled(true)}}else{this.lastTerm="";this.clearTerms();this.updateFlyoutVisibility()}},clearTerms:function(){this.termItems=[];jQuery(this.completionListElement).empty();this.selectedTermIndex=-1},termcb:function(a){a.Term=epx_htmlDecode(a.Term);a.matchType=epx_htmlDecode(a.MatchType);a.Matches=jQuery.map(a.Matches,epx_htmlDecode);var b=this.context;if(b===undefined)b=this;if(b.shouldProcessResult(a)){b.clearTerms();this.matchType=a.MatchType;this.terms=a.Matches;for(var c=0;c1||a.Matches[0].toUpperCase()!==this.lastTerm.toUpperCase());else if(a.matchType==this.wordMatchString){var b=this.getLastWord(this.lastTerm.toUpperCase());return a.Matches.length>1||a.Matches[0].toUpperCase()!==b.toUpperCase()}},getLastWord:function(c){var a=c.split(" "),b=0;if(a.length>1)b=a.length-1;return a[b]},getWordTermSuggestion:function(d){var a=this.lastTerm.split(" "),b=0;if(a.length>1)b=a.length-1;a[b]=d;var c=jQuery(document.createElement("li"));c.attr("term",a.join(" "));return c},createItem:function(b,c){var a=jQuery(document.createElement("li"));a.bind("mouseover",this,function(a){a.data.highlightItem(this)});a.bind("mousedown",this,function(a){if(a.data.matchType==a.data.termMatchString){a.data.setText(this);a.data.executeSearch()}else if(a.data.matchType==a.data.wordMatchString){a.data.setText(a.data.getWordTermSuggestion(b));a.data.hideFlyout();a.data.executeSearch()}});if(this.matchType==this.wordMatchString){var g=c.split(" ");c=g[g.length-1]}if(c){var f=c,h=b.toUpperCase().indexOf(f.toUpperCase()),d=h+f.length;a.append(document.createTextNode(b.slice(0,d)));if(d1){a[a.length-1]="";e.x+=Math.min(b,this.getOffset(a.join(" ")).width-f)}var d="";for(var c=0;c0)this.showFlyout();else this.hideFlyout()},onSearchBoxFocus:function(a){if(!a.data.sbData.focusOnInit){a.data.hideWatermark();a.stopPropagation();this.focused=true;return false}else a.data.focusWithWatermark()},onSearchBoxBlur:function(a){if(a.data.flyoutFocused)setTimeout(function(){a.data.searchBoxElement.focus()},10);else{a.data.hideFlyout();a.data.showWatermark();this.focused=false}},init:function(){this.searchBoxElement=jQuery("#"+this.sbData.boxId).get(0);if(this.sbData.maxTerms)this.maxTerms=this.sbData.maxTerms;if(this.searchBoxElement){this.initEventHandlers();this.initTimer();this.initSearchBoxElement();this.initCompletionList();this.showWatermark();if(this.sbData.focusOnInit&&this.searchBoxElement.watermarkShown)this.focusWithWatermark()}},initEventHandlers:function(){jQuery(document).bind("keyup",this,this.onKeyUp)},initTimer:function(){this.requestTimer=new epx_timer(this.serviceRequestDelay,epx_createDelegate(this,this.loadTermsFromService))},initSearchBoxElement:function(){var a=jQuery(this.searchBoxElement);a.attr("autocomplete","off");a.attr("data-searchtype","searchbox");if(!this.isNullOrUndefined(this.sbData.pgArea))a.attr("data-pgarea",this.sbData.pgArea);a.bind("focus",this,this.onSearchBoxFocus);a.bind("blur",this,this.onSearchBoxBlur);a.bind("keyup",this,this.onSearchBoxKeyUp);a.bind("keydown",this,this.onKeyDown);a.bind("paste",this,this.onPaste);document.getElementById(this.sbData.btnId).onclick=null;jQuery("#"+this.sbData.btnId).bind("click",this,this.onSearchButtonClick);jQuery("#"+this.sbData.btnId).bind("keydown",this,this.onSearchButtonKeydown);jQuery("#"+this.sbData.btnId).attr("data-searchtype","icon");if(!this.isNullOrUndefined(this.sbData.pgArea))jQuery("#"+this.sbData.btnId).attr("data-pgarea",this.sbData.pgArea);var b=this.sbData.sr.searchLabel;if(b.length>0)jQuery(this.searchBoxElement).attr("title",b);if(!this.isNullOrUndefined(this.sbData.sr.searchButtonTooltip)&&this.sbData.sr.searchButtonTooltip.length>0)jQuery("#"+this.sbData.btnId).attr("title",this.sbData.sr.searchButtonTooltip);else jQuery("#"+this.sbData.btnId).attr("title",b)},initCompletionList:function(){this.flyoutElement=this.createFlyout();jQuery(this.searchBoxElement).parent().append(this.flyoutElement)},createFlyout:function(){var a=this.createContainer();a.attr("id","SearchFlyoutContainer");a.bind("mouseover",this,function(a){a.data.flyoutFocused=true});a.bind("mouseout",this,function(a){a.data.flyoutFocused=false});a.css({display:"none",textAlign:this.textAlign,border:"solid 1px buttonshadow",position:"absolute",zIndex:"1000",padding:"2px","background-color":this.textBackground,color:$(this.searchBoxElement).css("color"),"font-family":$(this.searchBoxElement).css("font-family"),"font-size":$(this.searchBoxElement).css("font-size")});a.append(this.createSuggestionContainer());return a},createSuggestionContainer:function(){var a=this.createContainer();a.attr("id","SuggestionContainer");this.completionListElement=document.createElement("ul");jQuery(this.completionListElement).css(this.listStyle);if(!this.isNullOrUndefined(this.sbData.pgArea))jQuery(this.completionListElement).attr("data-pgarea",this.sbData.pgArea);jQuery(this.completionListElement).attr("data-searchtype","search dropdown");a.append(this.completionListElement);a.bind("mouseout",this,function(a){a.data.selectedTermIndex=-1;a.data.resetItemStyle(jQuery("li",jQuery(this)))});return a},createSeparator:function(){var a=this.createContainer();a.css({border:"0px","border-top":"1px solid #dddddd",height:"1px","margin-top":"1px"});return a},createContainer:function(){return jQuery(document.createElement("div"))},onPaste:function(a){a.data.hideWatermark()},onKeyUp:function(a){if(a.keyCode===27)a.data.hideFlyout()},onSearchBoxKeyUp:function(a){var b=a.keyCode;if(b===9&&this.focused){a.stopPropagation();return false}if(b!==38&&b!==40)a.data.updateTerms();if(a.data.searchBoxElement.value.length===0){a.data.showWatermark();a.data.focusWithWatermark()}},onKeyDown:function(a){var b=a.keyCode;if(b===38){if(a.data.selectedTermIndex>0){a.data.selectedTermIndex--;a.data.highlightItemIdx(a.data.selectedTermIndex);if(a.data.matchType==a.data.termMatchString)a.data.setText(a.data.completionListElement.childNodes[a.data.selectedTermIndex]);else if(a.data.matchType==a.data.wordMatchString)a.data.setText(a.data.getWordTermSuggestion(a.data.completionListElement.childNodes[a.data.selectedTermIndex].textContent));a.stopPropagation();a.preventDefault()}}else if(b===40){if(a.data.selectedTermIndex0)a+="&ac="+c;b[0]=a;return b.join("#")},executeSearch:function(){if(!this.sbData.allowEmptySearch&&(this.searchBoxElement.watermarkShown||jQuery.trim(jQuery(this.searchBoxElement).val()).length==0)||jQuery.trim(this.searchBoxElement.value)==this.sbData.sr.searchLabel)return;var query=encodeURIComponent(this.searchBoxElement.watermarkShown?"":jQuery.trim(this.searchBoxElement.value));this.instrumentSearch(query);this.searchExecuting=true;var href="";if(typeof buildSearchUrl==="function"&&buildSearchUrl!=="undefined"&&buildSearchUrl)href=this.addInstrumentationToUrl(buildSearchUrl(this.sbData.boxId));else{href=this.sbData.searchLocation+"?query="+query+this.sbData.queryParams;if(this.sbData.paramsCallback&&eval("typeof "+this.sbData.paramsCallback)!="undefined")href+=eval(this.sbData.paramsCallback+"()");href=this.addInstrumentationToUrl(href)}window.location.href=href},highlightItemIdx:function(a){this.highlightItem(jQuery(this.completionListElement).children().eq(a))},highlightItem:function(a){var b=jQuery(a).parent().children();this.selectedTermIndex=b.index(a);this.resetItemStyle(b);jQuery(a).css(this.itemHoverStyle)},resetItemStyle:function(a){a.css(this.itemNormalStyle)},setText:function(b){var a=jQuery(b).attr("term");if(this.isNullOrUndefined(a)&&!this.isNullOrUndefined(b))a=b;if(a){if(this.matchType==this.termMatchString)this.state.userSelectedTerm();else if(this.matchType==this.wordMatchString)this.state.userSelectedWord();this.searchBoxElement.value=a}},isNullOrUndefined:function(a){return a=="undefined"||a==null}};epx_loaded = true;}}
epx_core_i = new epx_core({'delay':100,'maxRetry':20});
epx_core_i.exec(epx_core_i.load, function() {return typeof(jQuery) !== 'undefined'});
}
epx_core_i.exec(function(){
jQuery(document).ready(function(){new epx_searchBox({"allowEmptySearch":false,"appId":"1","boxId":"HeaderSearchTextBox","btnId":"HeaderSearchButton","focusOnInit":false,"isRTL":false,"maxTerms":null,"minimumTermLength":4,"paramsCallback":null,"pgArea":"header","queryParams":"&pgArea=header&emptyWatermark=true","scopeId":"9","searchLocation":"https:\/\/social.msdn.microsoft.com\/Search\/en-US","serviceUri":"https:\/\/services.social.microsoft.com\/Search\/","sr":{"close":"Close","searchButtonTooltip":"Search MSDN","searchLabel":""}} ).init();});},
function() {return epx_loaded});