function initializeSearchFunctions(){var n=GetCookie("i-bidder-search-option");if(n.isNullOrEmpty()?($("span#searchDropDown span.text").html($("#lotSearchOptionList #catalogueSearchOption").html()),$("#lotSearchOptionList #catalogueSearchOption").attr("checked","checked"),$("#lotSearchOptionList #catalogueSearchOption").click()):($("span#searchDropDown span.text").html($("#lotSearchOptionList #"+n).html()),$("#lotSearchOptionList #"+n).attr("checked","checked"),$("#lotSearchOptionList #"+n).click()),searchFunctions===undefined){searchFunctions=new SearchFunctions,n=GetCookie("i-bidder-search-option"),n.isNullOrEmpty()||$("span#searchDropDown span.text").html($("#lotSearchOptionList #"+n).html());$("#goToLotFromDetails").on("click",function(){searchFunctions.GoToLotNumber($("#txtJumpToLotNumber").val())});$("#txtJumpToLotNumber").bind("keypress",function(n){n.keyCode==13&&searchFunctions.GoToLotNumber($(this).val())}),InitializeExactPhrase();$("#searchTerm").on("keyup",function(){InitializeExactPhrase()});$("#exactPhraseCheckBox").on("click",function(){var n=$("#searchTerm").val();if(n=n.replace(/"/g,""),!n||n.length===0||n==='""'||$.trim(n).length===0){$("#searchTerm").val(""),$(this).prop("checked",!1);return}$(this).prop("checked")==!0&&(n='"'+n+'"'),$("#searchTerm").val(n)})}}function DropDownImplementation(n){function r(){t.slideToggle("fast"),t.addClass("hide"),$("body").unbind("click.searchboxExternalClose")}var t=$("#lotSearchOptionList",n),i=$("#searchDropDown",n);this.optionClick=function(n,r,u){r.removeClass("selected"),u.addClass("selected"),$("span.text",i).html(u.html()),t.hasClass("hide")||i.click()},this.GetSelectedAction=function(n){return n.attr("rel")},i.click(function(){return t.hasClass("hide")?(t.slideToggle("fast"),t.removeClass("hide"),$("body").bind("click.searchboxExternalClose",function(){r()})):r(),!1})}function RadioImplementation(){this.optionClick=function(n,t,i){t.attr("checked",!1).removeClass("selected").parent().parent().removeClass("active"),i.attr("checked","checked").addClass("selected").addClass("active").parent().parent().addClass("active")},this.GetSelectedAction=function(n){return n.attr("value")}}function SearchFunctions(){function s(n,t,i){function r(n){document.location.href=n.Url}function u(){ShowNotification("info",portalScriptResources.SearchCouldNotFindLot,portalScriptResources.SearchTryDifferentLot),$("#searchBox").addClass("error")}return h(t)&&(i=i.replace(/lotNumber/gi,$("input#searchTerm",t).val().trim()),$.ajax({type:"POST",url:i,data:{clienturl:$("#clienturl").val()},success:r,error:u,timeout:1e5})),n&&n.preventDefault(),!1}function h(n){var t=$("input#searchTerm",n).val().trim(),i=new RegExp("^[0-9]+[a-zA-Z]*$","");return i.test(t)?!0:(ShowNotification("error",portalScriptResources.SearchInvalidLotNumber,portalScriptResources.SearchEnterLotNumber),$("#searchBox").addClass("error"),!1)}var n=$("form#SearchForm"),i=$(".searchOption",n),f,t=GapSearchOptionsEnum.ThisAuction,o=$("div .field-radio",n).has(".ui.radio.checkbox"),r,u,e;o.each(function(n,t){$(".ui.radio.checkbox",t).checkbox({onChecked:function(){$("input",t).click()}})}),$("#lotSearchOptionList").length&&(r=GetCookie("i-bidder-search-option"),r.isNullOrEmpty()||r!=="lotNumberSearchOption"?r.isNullOrEmpty()||r!=="catalogueSearchOption"||(t=GapSearchOptionsEnum.ThisAuction,n.attr("action",null)):t=GapSearchOptionsEnum.LotNumber),n.removeAttr("onsubmit"),u=Gap.Portal.UI.SiteSearchProperties&&Gap.Portal.UI.SiteSearchProperties.searchOptionsType==Gap.Portal.UI.SiteSearchProperties.searchOptionsTypeDropdown?new DropDownImplementation(n):new RadioImplementation(n),i.click(function(r){var e=$(r.target);e.attr("id")==="lotNumberSearchOption"?(SetCookie("i-bidder-search-option",e.attr("id"),365),t=GapSearchOptionsEnum.LotNumber):e.attr("id")==="catalogueSearchOption"?(SetCookie("i-bidder-search-option",e.attr("id"),365),t=GapSearchOptionsEnum.ThisAuction,n.attr("action",null)):(t=GapSearchOptionsEnum.ThisAuction,DeleteCookie("i-bidder-search-option")),e.attr("id")==="lotNumberSearchOption"?(t=GapSearchOptionsEnum.LotNumber,n.attr("action",null),n.removeAttr("onsubmit"),n.unbind("submit"),n.submit(function(t){return s(t,n,u.GetSelectedAction(e))})):(n.attr("action",u.GetSelectedAction(e)),n.removeAttr("onsubmit"),n.unbind("submit"),n.attr("onsubmit","AddSearchParametersToQuerystring(this);")),$("#lotSearchOptionList",n).hasClass("hide")||$("#searchDropDown",n).click(),u.optionClick(r,i,e),f!==undefined&&f()}),this.GoToLotNumber=function(t){$("#searchTerm").val(t),i.click(),n.submit()},this.GetSearchOption=function(){return t},this.change=function(n){f=n},e=GetCookie("i-bidder-search-option"),!e.isNullOrEmpty()&&Gap.Portal.UI.SiteSearchProperties&&Gap.Portal.UI.SiteSearchProperties.searchOptionsType!=="None"?i.filter("#"+e).click():i.filter(".selected").click()}function InitializeExactPhrase(){var n=$("#searchTerm").val(),t='"';n&&n.length>2&&n!=='""'&&n.indexOf(t,0)===0&&n.lastIndexOf(t)===n.length-1?$("#exactPhraseCheckBox").prop("checked",!0):$("#exactPhraseCheckBox").prop("checked",!1)}var searchFunctions,searchReady,GapSearchOptionsEnum;(function(){window.Gap=window.Gap||{},Gap.Portal=Gap.Portal||{},Gap.Portal.UI=Gap.Portal.UI||{},Gap.Portal.UI.SiteSearchProperties=null})(),$(document).ready(initializeSearchFunctions),GapSearchOptionsEnum={LotNumber:1,ThisAuction:2}