
YAHOO.namespace("gl.search");YAHOO.gl.search.formActionMap={};YAHOO.gl.search.formActionMap["Movies"]="/search/super_search.jhtml";YAHOO.gl.search.formActionMap["Toys"]="/search/super_search.jhtml";YAHOO.gl.search.formActionMap["Scenes"]="/search/scene_super_search_results.jhtml";YAHOO.gl.search.formActionMap["Stars"]="/search/star_search_results.jhtml";YAHOO.gl.search.updateFormAction=function(searchType){var action=YAHOO.gl.search.formActionMap[searchType];if(action){var frm=document.multiSearchForm;if(frm){frm.action=action;}}}
YAHOO.gl.search.selectSearchType=function(){var opt=this.options[this.selectedIndex];YAHOO.gl.search.updateFormAction(opt.value);}
YAHOO.gl.search.addChangeListener=function(){var slct=document.getElementById("searchType");var opt=slct.options[slct.selectedIndex];YAHOO.gl.search.updateFormAction(opt.value);YAHOO.util.Event.addListener(slct,"change",YAHOO.gl.search.selectSearchType,null,slct);}
YAHOO.namespace("gl.autocomplete");YAHOO.gl.autocomplete.processHighlight=function(sQuery,sResultMatch){var aQuery=sQuery.split(" ");var sProcessing=sResultMatch;var sProcessed="";while(sProcessing.length>0){var iLowestIdx=sProcessing.length;var iAppliedLength=0;var iWordIdx;var iAQueryIdx;for(iAQueryIdx=0;iAQueryIdx<aQuery.length;iAQueryIdx++){if(aQuery[iAQueryIdx].length>0){var iCurIdx=sProcessing.toLowerCase().indexOf(aQuery[iAQueryIdx].toLowerCase());if(iCurIdx>=0){if(iLowestIdx==iCurIdx){if(iAppliedLength<aQuery[iAQueryIdx].length){iLowestIdx=iCurIdx;iAppliedLength=aQuery[iAQueryIdx].length;iWordIdx=iAQueryIdx;}}else if(iLowestIdx>iCurIdx){iLowestIdx=iCurIdx;iAppliedLength=aQuery[iAQueryIdx].length;iWordIdx=iAQueryIdx;}}}}
if(iAppliedLength>0){if(iLowestIdx>0){sProcessed+=sProcessing.substring(0,iLowestIdx);}
sProcessed+="<span style='font-weight:bold'>"+sProcessing.substr(iLowestIdx,iAppliedLength)+"</span>";aQuery.splice(iWordIdx,1);if(sProcessing.length>(iLowestIdx+iAppliedLength)){sProcessing=sProcessing.substr(iLowestIdx+iAppliedLength);}else{sProcessing="";}}else{sProcessed+=sProcessing;sProcessing="";}}
return sProcessed;}
YAHOO.gl.autocomplete.remoteCustomRequest=function(){var oDS=new YAHOO.util.XHRDataSource("/auto_complete/auto_complete_json.jhtml");oDS.responseType=YAHOO.util.XHRDataSource.TYPE_JSON;oDS.responseSchema={resultsList:"Results",fields:["Name","Type"]};oDS.maxCacheEntries=5;var oAC=new YAHOO.widget.AutoComplete("searchTerms","autoCompleteContainer",oDS);oAC.minQueryLength=3;oAC.queryDelay=0.25;oAC.animSpeed=0.1;oAC.autoHighlight=false;oAC.generateRequest=function(sQuery){var slct=document.getElementById("searchType");var opt=slct.options[slct.selectedIndex];var sSearchType=opt.value;return"?pQuery="+sQuery+"&pSearchType="+sSearchType;};oAC.resultTypeList=false;oAC.formatResult=function(oResultData,sQuery,sResultMatch){var sHighLighted=YAHOO.gl.autocomplete.processHighlight(sQuery,sResultMatch);var sTypeData=oResultData.Type;var aMarkup=[sHighLighted," <span style='color:gray'>",sTypeData,"</span>"];return(aMarkup.join(""));};oAC.doBeforeLoadData=function(sQuery,oResponse,oPayload){var aAllResults=oResponse.results;var sMatchKey=(this.dataSource.responseSchema.fields)?(this.dataSource.responseSchema.fields[0].key||this.dataSource.responseSchema.fields[0]):0;for(var i=0;i<aAllResults.length;i++){var oResult=aAllResults[i];oResult[sMatchKey]=Encoder.htmlDecode(oResult[sMatchKey]);}
return true;};oAC.itemSelectEvent.subscribe(function(sType,aArgs){document.multiSearchForm.submit();});return{oDS:oDS,oAC:oAC};}