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(value){this.advanceSearch=value;},getAdvanceSearch:function(){return this.advanceSearch;},showHideSearchMode:function(advanced){var methodName="showHideSearchMode";console.debug(methodName+"advance: "+advanced);advancedSearchDiv=dojo.byId("Advanced_Search_Form_div");searchResultDiv=dojo.byId("Search_Result_div");if(advanced){dojo.style(advancedSearchDiv,"display","block");advanced=false;}else{dojo.style(advancedSearchDiv,"display","none");}dojo.style(searchResultDiv,"display","block");},submitSimpleSearch:function(formId){if(!submitRequest()){return;}cursor_wait();CatalogSearchDisplayJS.searchMode="simple";wc.render.getRefreshControllerById("catalogSearchResultDisplay_Controller").formId=formId;wc.render.getRefreshControllerById("catalogSearchResultDisplay_Controller").url="AjaxCatalogSearchResultView";var queryString=dojo.formToQuery(dojo.byId(formId));var searchUrl="AjaxCatalogSearchResultView?"+queryString;wc.render.updateContext("catalogSearchResultDisplay_Context",{searchResultsPageNum:"",searchResultsURL:searchUrl,searchResultsView:""});},submitAdvancedSearch:function(formId,searchType){var methodName="submitAdvancedSearch";form=document.getElementById(formId);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,searchType);if(!submitRequest()){return;}cursor_wait();var queryString=dojo.formToQuery(dojo.byId(formId));var searchUrl="AjaxCatalogSearchResultView?"+queryString;console.debug(methodName+" url: "+searchUrl);wc.render.getRefreshControllerById("catalogSearchResultDisplay_Controller").formId=formId;wc.render.getRefreshControllerById("catalogSearchResultDisplay_Controller").url="AjaxCatalogSearchResultView";wc.render.updateContext("catalogSearchResultDisplay_Context",{searchResultsPageNum:"",searchResultsURL:searchUrl,searchResultsView:""});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=resultSummaryDiv.innerHTML;resultSummaryDiv.innerHTML="";if(dojo.byId("cancelSearchButton")!=null&&dojo.byId("cancelSearchButton")!="undefined"){dojo.style(searchCancelBtn,"display","block");}},loadContentFromURL:function(changeUrl){if(changeUrl=="simple"){this.showHideSearchMode(false,"filter");}else{if(changeUrl=="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=changeUrl;wc.render.updateContext("catalogSearchResultDisplay_Context",{searchResultsURL:changeUrl});}}MessageHelper.hideAndClearMessage();},searchResultCallback:function(changeUrl){var methodName="searchResultCallback";console.debug(methodName+" entry");CatalogSearchDisplayJS.searchModeVisible="true";var identifier="&identifier="+(new Date()).getTime();var newUrl=changeUrl+identifier;if(!CatalogSearchDisplayJS.isHistory){console.debug(methodName+" add to history: "+newUrl);var historyObject=new CatalogSearchDisplayJS.HistoryTracker("AjaxCatalogSearchResultView","Search_result_div",newUrl);dojo.back.addToHistory(historyObject);}CatalogSearchDisplayJS.isHistory=false;cursor_clear();console.debug(methodName+" exit ");},goToResultPage:function(resultPageURL){if(!submitRequest()){return;}cursor_wait();wc.render.getRefreshControllerById("catalogSearchResultDisplay_Controller").url=resultPageURL;wc.render.updateContext("catalogSearchResultDisplay_Context",{searchResultsURL:resultPageURL});MessageHelper.hideAndClearMessage();},processURL:function(){var methodName="processURL";console.debug(methodName+" enter");var bookmarkId=location.hash;console.debug(" bookmarkedId is "+bookmarkId);var needContextUpdate=false;var wholeUrl;if(bookmarkId){bookmarkId=bookmarkId.substring(1,bookmarkId.length);wholeUrl=bookmarkId;var indexOfIdentifier=bookmarkId.indexOf("identifier",0);if(indexOfIdentifier>=0){wholeUrl=bookmarkId.substring(0,indexOfIdentifier);}CatalogSearchDisplayJS.showResultsPage=true;needContextUpdate=true;wholeUrl=unescape(wholeUrl);}if(needContextUpdate){cursor_wait();wc.render.getRefreshControllerById("catalogSearchResultDisplay_Controller").url=wholeUrl;wc.render.updateContext("catalogSearchResultDisplay_Context",{searchResultsURL:wholeUrl});}console.debug(methodName+" exit ");},initSearch:function(){var methodName="initSearch";console.debug(methodName+" entry ");CatalogSearchDisplayJS.searchModeVisible="true";console.debug(methodName+" value of searchMode "+CatalogSearchDisplayJS.searchModeVisible+" value of showResultPage "+CatalogSearchDisplayJS.showResultsPage);},initSearchHistory:function(workAreaModeValue,elementId,changeUrl){var methodName="initSearchHistory";console.debug(methodName+" mode: "+workAreaModeValue+" id: "+elementId+" url "+changeUrl);var historyObject=new CatalogSearchDisplayJS.HistoryTracker(workAreaModeValue,elementId,changeUrl);dojo.back.setInitialState(historyObject);},goBack:function(){cursor_wait();var form=document.getElementById("AdvancedCatalogSearchForm");CatalogSearchDisplayJS.loadContentFromURL(this.changeUrl);if(this.changeUrl!="advanced"){var requiredURLArray=[];requiredURLArray=this.changeUrl.toString().split("?");var searchURLArray=[];if(requiredURLArray.length>1){searchURLArray=requiredURLArray[1].toString().split("&");for(var i=0;i<searchURLArray.length;i++){var searchParameterArray=[];searchParameterArray=searchURLArray[i].toString().split("=");if(form[searchParameterArray[0]]!=null&&form[searchParameterArray[0]]!="undefined"){form[searchParameterArray[0]].value=searchParameterArray[1];}}}}CatalogSearchDisplayJS.isHistory=true;},goForward:function(){cursor_wait();var form=document.getElementById("AdvancedCatalogSearchForm");CatalogSearchDisplayJS.loadContentFromURL(this.changeUrl);var requiredURLArray=[];requiredURLArray=this.changeUrl.toString().split("?");var searchURLArray=[];searchURLArray=requiredURLArray[1].toString().split("&");for(var i=0;i<searchURLArray.length;i++){var searchParameterArray=[];searchParameterArray=searchURLArray[i].toString().split("=");if(form[searchParameterArray[0]]!=null&&form[searchParameterArray[0]]!="undefined"){form[searchParameterArray[0]].value=searchParameterArray[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(workAreaModeValue,elementId,changeUrl){this.workAreaModeValue=workAreaModeValue;this.elementId=elementId;this.changeUrl=changeUrl;}};CatalogSearchDisplayJS.HistoryTracker.prototype.back=CatalogSearchDisplayJS.goBack;CatalogSearchDisplayJS.HistoryTracker.prototype.forward=CatalogSearchDisplayJS.goForward;
