dojo.require("wc.render.RefreshController");dojo.require("wc.render.Context");dojo.require("wc.widget.RefreshArea");dojo.require("wc.service.common");if(CatalogSearchDisplayJS==null||typeof(CatalogSearchDisplayJS)!="object"){var CatalogSearchDisplayJS=new Object()}CatalogSearchDisplayJS={showResultsPage:false,searchModeVisible:true,searchMode:"topBar",isHistory:false,advanceSearch:false,contextChanged:false,setAdvanceSearch:function(a){this.advanceSearch=a},getAdvanceSearch:function(){return this.advanceSearch},showHideSearchMode:function(b){var a="showHideSearchMode";console.debug(a+"advance: "+b);advancedSearchDiv=dojo.byId("Advanced_Search_Form_div");searchResultDiv=dojo.byId("Search_Result_div");if(b){dojo.style(advancedSearchDiv,"display","block");b=false}else{dojo.style(advancedSearchDiv,"display","none")}dojo.style(searchResultDiv,"display","block")},submitSimpleSearch:function(b){if(!submitRequest()){return}cursor_wait();CatalogSearchDisplayJS.searchMode="simple";wc.render.getRefreshControllerById("catalogSearchResultDisplay_Controller").formId=b;wc.render.getRefreshControllerById("catalogSearchResultDisplay_Controller").url="AjaxCatalogSearchResultView";var c=dojo.formToQuery(dojo.byId(b));var a="AjaxCatalogSearchResultView?"+c;wc.render.updateContext("catalogSearchResultDisplay_Context",{searchResultsPageNum:"1",searchResultsURL:a,searchResultsView:"image"})},submitAdvancedSearch:function(d,b){var a="submitAdvancedSearch";form=document.getElementById(d);CatalogSearchDisplayJS.searchMode="advanced";this.setAdvanceSearch(true);form.searchTerm.value=trim(form.searchTerm.value);if(form.searchTerm!==null&&form.searchTerm!="undefined"){form.searchTerm.value=form.searchTerm.value.replace(/^\s+/g,"").replace(/\s+$/g,"")}form.filterTerm.value=trim(form.filterTerm.value);if(form.filterTerm!==null&&form.filterTerm!="undefined"){form.searchTerm.value=form.searchTerm.value.replace(/^\s+/g,"").replace(/\s+$/g,"")}form.manufacturer.value=trim(form.manufacturer.value);form.minPrice.value=trim(form.minPrice.value);form.maxPrice.value=trim(form.maxPrice.value);if(form.minPrice!==null&&form.minPrice!="undefined"){form.minPrice.value=form.minPrice.value.replace(/^\s+/g,"").replace(/\s+$/g,"")}if(form.maxPrice!==null&&form.maxPrice!="undefined"){form.maxPrice.value=form.maxPrice.value.replace(/^\s+/g,"").replace(/\s+$/g,"")}if((form.minPrice.value=="")&&(form.maxPrice.value=="")){form.currency.value=""}form.resultCatEntryType.value="2";this.showHideSearchMode(false,b);if(!submitRequest()){return}cursor_wait();var e=dojo.formToQuery(dojo.byId(d));var c="AjaxCatalogSearchResultView?"+e;console.debug(a+" url: "+c);wc.render.getRefreshControllerById("catalogSearchResultDisplay_Controller").formId=d;wc.render.getRefreshControllerById("catalogSearchResultDisplay_Controller").url="AjaxCatalogSearchResultView";wc.render.updateContext("catalogSearchResultDisplay_Context",{searchResultsPageNum:"1",searchResultsURL:c,searchResultsView:"image"});this.setAdvanceSearch(false);MessageHelper.hideAndClearMessage()},setResultSummaryMessage:function(){resultDiv=dojo.byId("Search_Result_Summary");searchCancelBtn=dojo.byId("cancelSearchButton");if(dojo.byId("Search_Advanced_Header")!=null&&dojo.byId("Search_Advanced_Header")!="undefined"){dojo.style(dojo.byId("Search_Advanced_Header"),"display","none")}if(dojo.byId("Search_Result_Summary")!=null&&dojo.byId("Search_Result_Summary")!="undefined"&&dojo.byId("Search_Result_Summary_div")!=null&&dojo.byId("Search_Result_Summary_div")!="undefined"){resultSummaryDiv=document.getElementById("Search_Result_Summary_div")}else{if(dojo.byId("Search_Result_Summary_div_2")!=null&&dojo.byId("Search_Result_Summary_div_2")!="undefined"){resultSummaryDiv=document.getElementById("Search_Result_Summary_div_2")}}dojo.style(resultDiv,"display","block");resultDiv.innerHTML=null;resultDiv.innerHTML=resultSummaryDiv.innerHTML;resultSummaryDiv.innerHTML=null;if(dojo.byId("cancelSearchButton")!=null&&dojo.byId("cancelSearchButton")!="undefined"){dojo.style(searchCancelBtn,"display","block")}},loadContentFromURL:function(a){if(a=="simple"){this.showHideSearchMode(false,"filter")}else{if(a=="advanced"){this.showHideSearchMode(true);searchResultDivision=dojo.byId("Search_Result_div");dojo.style(searchResultDivision,"display","none");searchMsgDiv=dojo.byId("Search_Advanced_Header");dojo.style(searchMsgDiv,"display","block");searchResultMsgDiv=dojo.byId("Search_Result_Summary");dojo.style(searchResultMsgDiv,"display","none");cursor_clear()}else{wc.render.getRefreshControllerById("catalogSearchResultDisplay_Controller").url=a;wc.render.updateContext("catalogSearchResultDisplay_Context",{searchResultsURL:a})}}MessageHelper.hideAndClearMessage()},searchResultCallback:function(e){var a="searchResultCallback";console.debug(a+" entry");CatalogSearchDisplayJS.searchModeVisible="true";var b="&identifier="+(new Date()).getTime();var d=e+b;if(!CatalogSearchDisplayJS.isHistory){console.debug(a+" add to history: "+d);var c=new CatalogSearchDisplayJS.HistoryTracker("AjaxCatalogSearchResultView","Search_result_div",d);dojo.back.addToHistory(c)}CatalogSearchDisplayJS.isHistory=false;cursor_clear();console.debug(a+" exit ")},goToResultPage:function(a){if(!submitRequest()){return}cursor_wait();wc.render.getRefreshControllerById("catalogSearchResultDisplay_Controller").url=a;wc.render.updateContext("catalogSearchResultDisplay_Context",{searchResultsURL:a});MessageHelper.hideAndClearMessage()},processURL:function(){var b="processURL";console.debug(b+" enter");var d=location.hash;console.debug(" bookmarkedId is "+d);var e=false;var a;if(d){d=d.substring(1,d.length);a=d;var c=d.indexOf("identifier",0);if(c>=0){a=d.substring(0,c)}CatalogSearchDisplayJS.showResultsPage=true;e=true;a=unescape(a)}if(e){cursor_wait();wc.render.getRefreshControllerById("catalogSearchResultDisplay_Controller").url=a;wc.render.updateContext("catalogSearchResultDisplay_Context",{searchResultsURL:a})}console.debug(b+" exit ")},initSearch:function(){var a="initSearch";console.debug(a+" entry ");CatalogSearchDisplayJS.searchModeVisible="true";console.debug(a+" value of searchMode "+CatalogSearchDisplayJS.searchModeVisible+" value of showResultPage "+CatalogSearchDisplayJS.showResultsPage)},initSearchHistory:function(a,c,e){var b="initSearchHistory";console.debug(b+" mode: "+a+" id: "+c+" url "+e);var d=new CatalogSearchDisplayJS.HistoryTracker(a,c,e);dojo.back.setInitialState(d)},goBack:function(){cursor_wait();var e=document.getElementById("AdvancedCatalogSearchForm");CatalogSearchDisplayJS.loadContentFromURL(this.changeUrl);if(this.changeUrl!="advanced"){var c=[];c=this.changeUrl.toString().split("?");var b=[];b=c[1].toString().split("&");for(var d=0;d<b.length;d++){var a=[];a=b[d].toString().split("=");if(e[a[0]]!=null&&e[a[0]]!="undefined"){e[a[0]].value=a[1]}}}CatalogSearchDisplayJS.isHistory=true},goForward:function(){cursor_wait();var e=document.getElementById("AdvancedCatalogSearchForm");CatalogSearchDisplayJS.loadContentFromURL(this.changeUrl);var c=[];c=this.changeUrl.toString().split("?");var b=[];b=c[1].toString().split("&");for(var d=0;d<b.length;d++){var a=[];a=b[d].toString().split("=");if(e[a[0]]!=null&&e[a[0]]!="undefined"){e[a[0]].value=a[1]}}searchResultDivisionStyle=document.getElementById("Search_Result_div").style;if(searchResultDivisionStyle.display=="none"){dojo.style(dojo.byId("Search_Result_div"),"display","block")}CatalogSearchDisplayJS.showHideSearchMode(false);CatalogSearchDisplayJS.isHistory=true},HistoryTracker:function(a,b,c){this.workAreaModeValue=a;this.elementId=b;this.changeUrl=c}};CatalogSearchDisplayJS.HistoryTracker.prototype.back=CatalogSearchDisplayJS.goBack;CatalogSearchDisplayJS.HistoryTracker.prototype.forward=CatalogSearchDisplayJS.goForward;
