
if(typeof(JScript)=="undefined")
throw DHTML.newError(0,"JavaScript OOP API is not included.  Add JScriptCore.js to your file");if(typeof(Olive)=="undefined"||!Olive.Controls)
throw DHTML.newError(0,"Olive Web SDK core classes are not included.  Add OwcControl.js to your file");if(typeof(Olive.Data)=="undefined"||!Olive.Data.SearchQuery)
throw DHTML.newError(0,"Olive search query data classes are not included.  Add OwcSearchQuery.js to your file");Olive.Controls.controlTypeNames.SearchForm="searchform";Olive.Controls.controlTypeNames.SearchOption="searchoption";Olive.Controls.controlTypeNames.UserParam="user-param";Olive.Controls.controlTypeNames.SearchInSelectedFolder="searchinselectedfolder";Olive.Controls.controlTypeNames.SearchInFolderLookup="searchinfolderlookup";Olive.Controls.controlTypeNames.SearchInTreeAndFolder="searchintreeandfolder";Olive.Controls.attributes.SearchOperators=Olive.Controls.prefix+":"+"operators";Olive.Controls.attributes.SearchFlags=Olive.Controls.prefix+":"+"flags";var OwcCmd_SubmitSearch="search";if(!Olive.Controls.ISearchFormField)
{Olive.Controls.ISearchFormField=new Interface("Olive.Controls.ISearchFormField");Olive.Controls.ISearchFormField.Implement=function OwcISearchFormField_Implement(rObject,bDynamic)
{if(!this.Register(rObject,bDynamic))
return;Olive.Controls.IFormField.ImplementInterface(rObject,bDynamic);JScript.Type.DeclareMethod(rObject,"readFromSearchData",null);JScript.Type.DeclareMethod(rObject,"writeToSearchData",null);}
Olive.Controls.ISearchFormField.Control_ApplyFlagOption=function OwcISearchFormField_Control_ApplyFlagOption(oControl,nMask)
{if(!oControl.m_sDataType)
{if(DHTML.isSelectElem(oControl.HtmlElement))
oControl.m_sDataType=Olive.Controls.DataTypeName.Number;else if(DHTML.isRadioButton(oControl.getHtmlValueElement()))
oControl.m_sDataType=Olive.Controls.DataTypeName.String;else
oControl.m_sDataType=Olive.Controls.DataTypeName.Boolean;}
oControl.m_nFlagMask=nMask;oControl.readFromSearchData=OwcISearchFormField_readOptionFlag;oControl.writeToSearchData=OwcISearchFormField_writeOptionFlag;}
function OwcISearchFormField_readOptionFlag(oDataObject)
{var oValue=oDataObject.getSearchFlagMode(this.m_nFlagMask);if(this.m_sDataType==Olive.Controls.DataTypeName.Boolean)
oValue=(oValue==Olive.Data.SearchOptions.Mode.Enabled);return this.setValue(oValue);}
function OwcISearchFormField_writeOptionFlag(oDataObject)
{var nMode=this.getValue();if(this.m_sDataType==Olive.Controls.DataTypeName.Boolean)
nMode=(nMode?Olive.Data.SearchOptions.Mode.Enabled:Olive.Data.SearchOptions.Mode.Disabled);oDataObject.setSearchFlagMode(this.m_nFlagMask,nMode);}
Olive.Controls.ISearchFormField.Control_ApplySortByOption=function OwcISearchFormField_ApplySortByOption(oControl)
{oControl.m_sDataType=Olive.Controls.DataTypeName.SortBy;oControl.readFromSearchData=OwcISearchFormField_readSortBy;oControl.writeToSearchData=OwcISearchFormField_writeSortBy;}
function OwcISearchFormField_readSortBy(oDataObject)
{return this.setValue(oDataObject.getSortBy());}
function OwcISearchFormField_writeSortBy(oDataObject)
{oDataObject.setSortBy(this.getValue());}
Olive.Controls.ISearchFormField.Control_ApplyPageSizeOption=function OwcISearchFormField_ApplyPageSizeOption(oControl)
{oControl.m_sDataType=Olive.Controls.DataTypeName.Number;oControl.readFromSearchData=OwcISearchFormField_readPageSize;oControl.writeToSearchData=OwcISearchFormField_writePageSize;}
function OwcISearchFormField_readPageSize(oDataObject)
{return this.setValue(oDataObject.getPageSize());}
function OwcISearchFormField_writePageSize(oDataObject)
{var nValue=this.getValue();oDataObject.setPageSize(nValue?nValue:-1);}
Olive.Controls.ISearchFormField.Control_ApplyTemplateNameOption=function OwcISearchFormField_ApplyTemplateNameOption(oControl)
{oControl.m_sDataType=Olive.Controls.DataTypeName.String;oControl.readFromSearchData=OwcISearchFormField_readTemplateName;oControl.writeToSearchData=OwcISearchFormField_writeTemplateName;}
function OwcISearchFormField_readTemplateName(oDataObject)
{return this.setValue(oDataObject.getTemplateName());}
function OwcISearchFormField_writeTemplateName(oDataObject)
{var sValue=this.getValue();oDataObject.setTemplateName(sValue?sValue:null);}
Olive.Controls.ISearchFormField.Control_ApplyFuzzyLevelOption=function OwcISearchFormField_ApplyFuzzyLevelOption(oControl)
{oControl.m_sDataType=Olive.Controls.DataTypeName.Number;oControl.readFromSearchData=OwcISearchFormField_readFuzzyLevel;oControl.writeToSearchData=OwcISearchFormField_writeFuzzyLevel;}
function OwcISearchFormField_readFuzzyLevel(oDataObject)
{return this.setValue(oDataObject.getFuzzyLevel());}
function OwcISearchFormField_writeFuzzyLevel(oDataObject)
{var nValue=this.getValue();oDataObject.setFuzzyLevel(typeof(nValue)!="undefined"?nValue:-1);}}
if(!Olive.Controls.SearchOption)
{Olive.Controls.SearchOption=function OwcSearchOption()
{}
Olive.Controls.SearchOption.OptionName={PageSize:"pagesize",SortBy:"sort-by",HitsOnly:"hits-only",PropagateHits:"propagate-hits",Stemming:"stemming",Phonic:"phonic",Synonyms:"synonyms",FuzzyLevel:"fuzzy-level",TemplateName:"template-name"}
Olive.Controls.SearchOption.DeclareType=function OwcCtrlSearchOption_DeclareType()
{this.OverrideMethod("parseControlHtmlAttr",OwcCtrlSearchOption_parseControlHtmlAttr);}
function OwcCtrlSearchOption_parseControlHtmlAttr()
{this.parseFieldName();var sFiledName=this.m_sFieldName.toLowerCase();switch(sFiledName)
{case Olive.Controls.SearchOption.OptionName.HitsOnly:Olive.Controls.ISearchFormField.Control_ApplyFlagOption(this,Olive.Data.SearchOptions.Flags.HitsOnly);break;case Olive.Controls.SearchOption.OptionName.PropagateHits:Olive.Controls.ISearchFormField.Control_ApplyFlagOption(this,Olive.Data.SearchOptions.Flags.PropagateHits);break;case Olive.Controls.SearchOption.OptionName.Stemming:Olive.Controls.ISearchFormField.Control_ApplyFlagOption(this,Olive.Data.SearchOptions.Flags.Stemming);break;case Olive.Controls.SearchOption.OptionName.Phonic:Olive.Controls.ISearchFormField.Control_ApplyFlagOption(this,Olive.Data.SearchOptions.Flags.Phonic);break;case Olive.Controls.SearchOption.OptionName.Synonyms:Olive.Controls.ISearchFormField.Control_ApplyFlagOption(this,Olive.Data.SearchOptions.Flags.Synonyms);break;case Olive.Controls.SearchOption.OptionName.SortBy:Olive.Controls.ISearchFormField.Control_ApplySortByOption(this);break;case Olive.Controls.SearchOption.OptionName.PageSize:Olive.Controls.ISearchFormField.Control_ApplyPageSizeOption(this);break;case Olive.Controls.SearchOption.OptionName.FuzzyLevel:Olive.Controls.ISearchFormField.Control_ApplyFuzzyLevelOption(this);break;case Olive.Controls.SearchOption.OptionName.TemplateName:Olive.Controls.ISearchFormField.Control_ApplyTemplateNameOption(this);break;default:this.reportKnownError(Olive.Errors.Code.UnknownSearchOption,this.m_sFieldName);return;}
if(this.BaseClassMethod)
this.BaseClassMethod.apply(this,arguments);}
JScript.Type.RegisterClass("Olive.Controls.SearchOption",Olive.Controls.SearchOption,Olive.Controls.Field,[Olive.Controls.ISearchFormField]);}
if(!Olive.Controls.SearchUserParam)
{Olive.Controls.SearchUserParam=function OwcSearchUserParam()
{}
Olive.Controls.SearchUserParam.DeclareType=function OwcCtrlSearchUserParam_DeclareType()
{this.DeclareField("m_sDataType",Olive.Controls.DataTypeName.String);this.ReplaceMethod("readFromSearchData",OwcCtrlSearchUserParam_readUserParam);this.ReplaceMethod("writeToSearchData",OwcCtrlSearchUserParam_writeUserParam);}
function OwcCtrlSearchUserParam_readUserParam(oDataObject,sFieldName)
{return this.setValue(oDataObject.getUserParam(sFieldName));}
function OwcCtrlSearchUserParam_writeUserParam(oDataObject,sFieldName)
{var sValue=this.getValue();oDataObject.setUserParam(sFieldName,sValue?sValue:null);}
JScript.Type.RegisterClass("Olive.Controls.SearchUserParam",Olive.Controls.SearchUserParam,Olive.Controls.Field,[Olive.Controls.ISearchFormField]);}
if(!Olive.Controls.SearchTerm)
{Olive.Controls.SearchTerm=function OwcCtrlSearchTerm()
{this.m_oSearchOptions=new Olive.Data.SearchOptions();}
Olive.Controls.SearchTerm.DeclareType=function OwcCtrlSearchTerm_DeclareType()
{this.DeclareField("m_oSearchOptions",null);this.ReplaceMethod("readFromSearchData",OwcCtrlSearchTerm_readFromSearchData);this.ReplaceMethod("writeToSearchData",OwcCtrlSearchTerm_writeToSearchData);this.DeclareMethod("parseSearchOperators",OwcCtrlSearchTerm_parseSearchOperators);this.DeclareMethod("parseSearchFlags",OwcCtrlSearchTerm_parseSearchFlags);this.OverrideMethod("parseControlHtmlAttr",OwcCtrlSearchTerm_parseControlHtmlAttr);}
function OwcCtrlSearchTerm_parseControlHtmlAttr()
{if(this.BaseClassMethod)
this.BaseClassMethod.apply(this,arguments);if(this.parseSearchOperators)
this.parseSearchOperators();}
function OwcCtrlSearchTerm_readFromSearchData(oDataObject,sFieldName)
{var oValue=oDataObject.getSearchInField(sFieldName,this.m_oSearchOptions);return this.setValue(oValue);}
function OwcCtrlSearchTerm_writeToSearchData(oDataObject,sFieldName)
{oDataObject.addSearchInField(sFieldName,this.getValue(),this.m_oSearchOptions);}
function OwcCtrlSearchTerm_parseSearchOperators()
{var sOperators=DHTML.getAttr(this.HtmlElement,Olive.Controls.attributes.SearchOperators);if(sOperators&&this.m_oSearchOptions)
this.m_oSearchOptions.parseOperators(sOperators,/[, \t]/);}
function OwcCtrlSearchTerm_parseSearchFlags()
{var sSearchFlags=DHTML.getAttr(this.HtmlElement,Olive.Controls.attributes.SearchFlags);if(sSearchFlags&&this.m_oSearchOptions)
this.m_oSearchOptions.parseOperators(sOperators,/[, \t]/);}
JScript.Type.RegisterClass("Olive.Controls.SearchTerm",Olive.Controls.SearchTerm,Olive.Controls.Field,[Olive.Controls.ISearchFormField]);}
if(!Olive.Controls.SearchInFolder)
{Olive.Controls.SearchInFolder=function OwcSearchInFolder()
{Olive.Controls.SearchTerm.apply(this,arguments);}
Olive.Controls.SearchInFolder.DeclareType=function OwcSearchInFolder_DeclareType()
{this.DeclareField("m_sDataType",Olive.Controls.DataTypeName.String);this.DeclareField("m_sFieldName",Olive.Data.SearchQuery.SpecialFields.Folder);}
JScript.Type.RegisterClass("Olive.Controls.SearchInFolder",Olive.Controls.SearchInFolder,Olive.Controls.SearchTerm);}
if(!Olive.Controls.SearchInFolderLookup)
{Olive.Controls.SearchInFolderLookup=function SearchInFolderLookup()
{Olive.Controls.SearchInFolder.apply(this,arguments);}
Olive.Controls.SearchInFolderLookup.DeclareType=function OwcSearchInFolderLookup_DeclareType()
{this.DeclareMethod("setFolder",OwcSearchInFolderLookup_setFolder);this.DeclareMethod("onSearchInAllFoldersChanged",OwcSearchInFolderLookup_onSearchInAllFoldersChanged);this.OverrideMethod("initControl",OwcSearchInFolderLookup_initControl);this.ReplaceMethod("readFromSearchData",OwcSearchInFolderLookup_readFromSearchData);this.ReplaceMethod("writeToSearchData",OwcSearchInFolderLookup_writeToSearchData);this.ReplaceMethod("_updateLookupValue",OwcSearchInFolderLookup_updateLookupValue);}
function OwcSearchInFolderLookup_setFolder(oFolder)
{var oFolderRefParams=new QueryString();oFolder.buildRefParams(oFolderRefParams);var sFolderRef=oFolderRefParams.getQueryString(",","=",false);this.m_sFolderIdRef=sFolderRef;var oFolderTitleControl=OwcGetControlFromHtmlElem(this.getUiElement("FolderTitle"));if(oFolderTitleControl)
{if(oFolder.m_sTitle)
oFolderTitleControl.setValue(oFolder.m_sTitle);else
oFolderTitleControl.setValue("");}}
function OwcSearchInFolderLookup_initControl()
{if(this.BaseClassMethod)
this.BaseClassMethod.apply(this,arguments);var oSearchInAllControl=OwcGetControlFromHtmlElem(this.getUiElement("SearchInAllFolders"));if(oSearchInAllControl)
{oSearchInAllControl.setValue(true);oSearchInAllControl.attachOwcEventHandler("valueChanged",this.onSearchInAllFoldersChanged,this);}
var oUiFolderSelection=this.getUiElement("FolderSelection");if(oUiFolderSelection)
DHTML.addCssClassToElem(oUiFolderSelection,"Hidden");}
function OwcSearchInFolderLookup_onSearchInAllFoldersChanged(oEvent)
{var oUiFolderSelection=this.getUiElement("FolderSelection");if(oUiFolderSelection)
{if(oEvent.newValue)
DHTML.addCssClassToElem(oUiFolderSelection,"Hidden");else
DHTML.removeCssClassFromElem(oUiFolderSelection,"Hidden");}}
function OwcSearchInFolderLookup_readFromSearchData(oDataObject,sFieldName)
{var oSearchTerm=oDataObject.findSearchInTerm(sFieldName,this.m_oSearchOptions);var sFolderIdRef=null;var nRecursiveMode=Olive.Data.SearchOptions.Mode.Undefined;if(oSearchTerm)
{sFolderIdRef=oSearchTerm.getValue();nRecursiveMode=oSearchTerm.getRecursiveMode();}
this.m_sFolderIdRef=sFolderIdRef;var bSearchInAllFolders=(sFolderIdRef==null);var oSearchInAllControl=OwcGetControlFromHtmlElem(this.getUiElement("SearchInAllFolders"));if(oSearchInAllControl)
oSearchInAllControl.setValue(bSearchInAllFolders);var oFolderTitleControl=OwcGetControlFromHtmlElem(this.getUiElement("FolderTitle"));if(oFolderTitleControl)
{if(sFolderIdRef)
oFolderTitleControl.setValue(sFolderIdRef);else
oFolderTitleControl.setValue("");}
var oRecursiveControl=OwcGetControlFromHtmlElem(this.getUiElement("Recursive"));if(oRecursiveControl)
oRecursiveControl.setValue(nRecursiveMode==Olive.Data.SearchOptions.Mode.Enabled);var oUiFolderSelection=this.getUiElement("FolderSelection");if(oUiFolderSelection)
{if(bSearchInAllFolders)
DHTML.addCssClassToElem(oUiFolderSelection,"Hidden");else
DHTML.removeCssClassFromElem(oUiFolderSelection,"Hidden");}
return true;}
function OwcSearchInFolderLookup_writeToSearchData(oDataObject,sFieldName)
{var bSearchInAllFolders=true;var oSearchInAllControl=OwcGetControlFromHtmlElem(this.getUiElement("SearchInAllFolders"));if(oSearchInAllControl)
bSearchInAllFolders=oSearchInAllControl.getHtmlValue(true);if(bSearchInAllFolders||!this.m_sFolderIdRef)
return;var bRecursiveSearch=false;var oRecursiveControl=OwcGetControlFromHtmlElem(this.getUiElement("Recursive"));if(oRecursiveControl)
bRecursiveSearch=oRecursiveControl.getHtmlValue(true);var oSearchOptions=Object_Clone(this.m_oSearchOptions);if(bRecursiveSearch)
oSearchOptions.setRecursiveMode(Olive.Data.SearchOptions.Mode.Enabled);else
oSearchOptions.setRecursiveMode(Olive.Data.SearchOptions.Mode.Disabled);oDataObject.addSearchInField(sFieldName,this.m_sFolderIdRef,oSearchOptions);}
function OwcSearchInFolderLookup_updateLookupValue(dialogResult,lookupValue,popupInfo)
{if(dialogResult!=Olive.PopupInfo.DialogResult.Cancel)
this.setFolder(lookupValue);}
JScript.Type.RegisterClass("Olive.Controls.SearchInFolderLookup",Olive.Controls.SearchInFolderLookup,Olive.Controls.SearchInFolder,[Olive.IUiElements]);}
if(!Olive.Controls.SearchInTreeAndFolder)
{Olive.Controls.SearchInTreeAndFolder=function SearchInTreeAndFolder()
{Olive.Controls.SearchInFolder.apply(this,arguments);}
Olive.Controls.SearchInTreeAndFolder.DeclareType=function OwcSearchInTreeAndFolder_DeclareType()
{this.DeclareField("m_sCurrentTree","");this.DeclareField("m_bChooseFolderHidden",true);this.DeclareMethod("onTreeSelectionChanged",OwcSearchInTreeAndFolder_onTreeSelectionChanged);this.DeclareMethod("onFolderSelected",OwcSearchInTreeAndFolder_onFolderSelected);this.DeclareMethod("ViewChooseFolder",OwcSearchInTreeAndFolder_ViewChooseFolder);this.DeclareMethod("ChooseAllFolders",OwcSearchInTreeAndFolder_ChooseAllFolders);this.DeclareMethod("LoadTree",OwcSearchInTreeAndFolder_LoadTree);this.DeclareMethod("SetAllFolders",OwcSearchInTreeAndFolder_SetAllFolders);this.DeclareMethod("ShowFolderSelection",OwcSearchInTreeAndFolder_ShowFolderSelection);this.DeclareMethod("ShowFolderTree",OwcSearchInTreeAndFolder_ShowFolderTree);this.DeclareMethod("ShowRecursiveCheckbox",OwcSearchInTreeAndFolder_ShowRecursiveCheckbox);this.OverrideMethod("initControl",OwcSearchInTreeAndFolder_initControl);this.ReplaceMethod("readFromSearchData",OwcSearchInTreeAndFolder_readFromSearchData);this.ReplaceMethod("writeToSearchData",OwcSearchInTreeAndFolder_writeToSearchData);}
Olive.Controls.SearchInTreeAndFolder.ApplyPrototype=function SearchInTreeAndFolder_ApplyPrototype(rObject,bDynamic)
{Olive.CmdTarget.RegisterCommand(rObject,"ViewChooseFolder","ViewChooseFolder");Olive.CmdTarget.RegisterCommand(rObject,"ChooseAllFolders","ChooseAllFolders");}
function OwcSearchInTreeAndFolder_initControl()
{if(this.BaseClassMethod)
this.BaseClassMethod.apply(this,arguments);var bShowFolderSelectField=true;var oSelectTreeControl=OwcGetControlFromHtmlElem(this.getUiElement("TreeSelection"));if(oSelectTreeControl)
{oSelectTreeControl.attachOwcEventHandler("valueChanged",this.onTreeSelectionChanged,this);var sTree=oSelectTreeControl.getHtmlValue();if(sTree.toLowerCase()=="")
bShowFolderSelectField=false;}
this.ShowFolderSelection(bShowFolderSelectField);this.ShowFolderTree(false);var oUiFolderTree=this.getUiElement("FolderTree");if(oUiFolderTree)
{if(bShowFolderSelectField)
{this.LoadTree();this.SetAllFolders();}
var ctrlFolderTree=OwcGetControlFromHtmlElem(oUiFolderTree);if(ctrlFolderTree)
ctrlFolderTree.attachOwcEventHandler("selectionItemClicked",this.onFolderSelected,this);}
this.ShowRecursiveCheckbox(false);}
function OwcSearchInTreeAndFolder_onTreeSelectionChanged(oEvent)
{this.ShowFolderSelection(oEvent.newValue!="");this.LoadTree();this.SetAllFolders();}
function OwcSearchInTreeAndFolder_onFolderSelected(ev)
{var oCI=ev.srcObject.getSelectedContentItem();var uiSelectedFolderTitle=this.getUiElement("SelectedFolderTitle");uiSelectedFolderTitle.value=oCI.m_sTitle;this.ViewChooseFolder();this.ShowRecursiveCheckbox(true);}
function OwcSearchInTreeAndFolder_ChooseAllFolders()
{this.SetAllFolders();this.ViewChooseFolder();}
function OwcSearchInTreeAndFolder_ViewChooseFolder()
{if(this.m_bChooseFolderHidden)
{this.LoadTree();var uiSelectedFolderTitle=this.getUiElement("SelectedFolderTitle");var uiAllFoldersOption=this.getUiElement("AllFoldersOption");if(uiSelectedFolderTitle.value==uiAllFoldersOption.innerText)
{DHTML.removeCssClassFromElem(uiAllFoldersOption,"folderNode");DHTML.addCssClassToElem(uiAllFoldersOption,"folderNodeSelected");}
else
{DHTML.removeCssClassFromElem(uiAllFoldersOption,"folderNodeSelected");DHTML.addCssClassToElem(uiAllFoldersOption,"folderNode");}}
this.ShowFolderTree(this.m_bChooseFolderHidden);this.m_bChooseFolderHidden=!this.m_bChooseFolderHidden;}
function OwcSearchInTreeAndFolder_ShowFolderSelection(bShow)
{var uiSelectedFolderTitle=this.getUiElement("SelectedFolderTitle");var uiSelectedFolderDropDownButton=this.getUiElement("SelectedFolderDropDownButton");if(typeof(bShow)=="undefined"||bShow==true)
{DHTML.removeCssClassFromElem(uiSelectedFolderTitle,"Hidden");DHTML.removeCssClassFromElem(uiSelectedFolderDropDownButton,"Hidden");}
else
{DHTML.addCssClassToElem(uiSelectedFolderTitle,"Hidden");DHTML.addCssClassToElem(uiSelectedFolderDropDownButton,"Hidden");}}
function OwcSearchInTreeAndFolder_ShowFolderTree(bShow)
{var uiAllFoldersOption=this.getUiElement("AllFoldersOption");var uiFolderTree=this.getUiElement("FolderTree");if(typeof(bShow)=="undefined"||bShow==true)
{DHTML.removeCssClassFromElem(uiAllFoldersOption,"Hidden");DHTML.removeCssClassFromElem(uiFolderTree,"Hidden");}
else
{DHTML.addCssClassToElem(uiAllFoldersOption,"Hidden");DHTML.addCssClassToElem(uiFolderTree,"Hidden");}}
function OwcSearchInTreeAndFolder_ShowRecursiveCheckbox(bShow)
{var uiRecursive=this.getUiElement("RecursiveArea");var oRecursiveControl=OwcGetControlFromHtmlElem(this.getUiElement("RecursiveCheckbox"));if(typeof(bShow)=="undefined"||bShow==true)
{DHTML.removeCssClassFromElem(uiRecursive,"Hidden");if(oRecursiveControl)
oRecursiveControl.setValue(Olive.Data.SearchOptions.Mode.Enabled);}
else
{DHTML.addCssClassToElem(uiRecursive,"Hidden");if(oRecursiveControl)
oRecursiveControl.setValue(Olive.Data.SearchOptions.Mode.Disabled);}}
function OwcSearchInTreeAndFolder_SetAllFolders()
{var ctrlFolderSelect=OwcGetControlFromHtmlElem(this.getUiElement("FolderTree"));ctrlFolderSelect.selectionClear();var uiSelectedFolderTitle=this.getUiElement("SelectedFolderTitle");var uiAllFoldersOption=this.getUiElement("AllFoldersOption");uiSelectedFolderTitle.value=uiAllFoldersOption.innerText;this.ShowRecursiveCheckbox(false);}
function OwcSearchInTreeAndFolder_LoadTree()
{var uiTreeSelection=this.getUiElement("TreeSelection");var ctrlFolderSelect=OwcGetControlFromHtmlElem(this.getUiElement("FolderTree"));if(uiTreeSelection.value!=this.m_sCurrentTree)
{ctrlFolderSelect.displayTree(uiTreeSelection.value);this.m_sCurrentTree=uiTreeSelection.value;}}
function OwcSearchInTreeAndFolder_readFromSearchData(oDataObject,sFieldName)
{var oSearchTerm=oDataObject.findSearchInTerm(sFieldName,this.m_oSearchOptions);var sFolderIdRef=null;var nRecursiveMode=Olive.Data.SearchOptions.Mode.Undefined;if(oSearchTerm)
{sFolderIdRef=oSearchTerm.getValue();nRecursiveMode=oSearchTerm.getRecursiveMode();}
var bSearchInAllFolders=(sFolderIdRef==null);var oSearchInAllControl=OwcGetControlFromHtmlElem(this.getUiElement("SearchInAllFolders"));if(oSearchInAllControl)
oSearchInAllControl.setValue(bSearchInAllFolders);var oFolderTitleControl=OwcGetControlFromHtmlElem(this.getUiElement("FolderTitle"));if(oFolderTitleControl)
{if(sFolderIdRef)
oFolderTitleControl.setValue(sFolderIdRef);else
oFolderTitleControl.setValue("");}
var oRecursiveControl=OwcGetControlFromHtmlElem(this.getUiElement("RecursiveCheckbox"));if(oRecursiveControl)
oRecursiveControl.setValue(nRecursiveMode==Olive.Data.SearchOptions.Mode.Enabled);var oUiFolderSelection=this.getUiElement("FolderSelection");if(oUiFolderSelection)
{if(bSearchInAllFolders)
DHTML.addCssClassToElem(oUiFolderSelection,"Hidden");else
DHTML.removeCssClassFromElem(oUiFolderSelection,"Hidden");}
return true;}
function OwcSearchInTreeAndFolder_writeToSearchData(oDataObject,sFieldName)
{var uiTreeSelection=this.getUiElement("TreeSelection");var sTreeSelection=DHTML.getValue(uiTreeSelection);if(sTreeSelection=="")
return;var bAllFoldersSelected=false;var ctrlFolderTree=OwcGetControlFromHtmlElem(this.getUiElement("FolderTree"));var oFolderRefParams=new QueryString();var oFolderCI=ctrlFolderTree.getSelectedContentItem();if(!oFolderCI)
{bAllFoldersSelected=true;oFolderCI=ctrlFolderTree.getContentItem();}
oFolderCI.buildRefParams(oFolderRefParams);var sFolderRef=oFolderRefParams.getQueryString(",","=",false);var bRecursiveSearch=false;var oRecursiveControl=OwcGetControlFromHtmlElem(this.getUiElement("RecursiveCheckbox"));if(oRecursiveControl)
bRecursiveSearch=oRecursiveControl.getHtmlValue(true);var oSearchOptions=Object_Clone(this.m_oSearchOptions);if(bRecursiveSearch&&!bAllFoldersSelected)
oSearchOptions.setRecursiveMode(Olive.Data.SearchOptions.Mode.Enabled);else
oSearchOptions.setRecursiveMode(Olive.Data.SearchOptions.Mode.Disabled);oDataObject.addSearchInField(sFieldName,sFolderRef,oSearchOptions);}
JScript.Type.RegisterClass("Olive.Controls.SearchInTreeAndFolder",Olive.Controls.SearchInTreeAndFolder,Olive.Controls.SearchInFolder,[Olive.IUiElements]);}
if(!Olive.Controls.SearchInSelectedFolder)
{Olive.Controls.SearchInSelectedFolder=function OwcSearchInSelectedFolder()
{Olive.Controls.SearchInFolder.apply(this,arguments);}
Olive.Controls.SearchInSelectedFolder.Mode={All:"",Selected:"selected",Recursive:"recursive"}
Olive.Controls.SearchInSelectedFolder.DeclareType=function SearchInSelectedFolder_DeclareType()
{this.DeclareField("m_oFolderTree",null);this.DeclareMethod("setFolderTree",OwcSearchInSelectedFolder_setFolderTree);this.DeclareMethod("getSelectedFolder",OwcSearchInSelectedFolder_getSelectedFolder);this.DeclareMethod("updateControlState",OwcSearchInSelectedFolder_updateControlState);this.DeclareMethod("onFolderSelectionChanged",OwcSearchInSelectedFolder_onFolderSelectionChanged);this.ReplaceMethod("readFromSearchData",OwcSearchInSelectedFolder_readFromSearchData);this.ReplaceMethod("writeToSearchData",OwcSearchInSelectedFolder_writeToSearchData);}
function OwcSearchInSelectedFolder_setFolderTree(oFolderTree)
{if(this.m_oFolderTree==oFolderTree)
return;if(this.m_oFolderTree)
this.m_oFolderTree.detachOwcEventHandler("selectionChanged","onFolderSelectionChanged",this,Delegate.Type.Method);this.m_oFolderTree=oFolderTree;if(this.m_oFolderTree)
this.m_oFolderTree.attachOwcEventHandler("selectionChanged","onFolderSelectionChanged",this,Delegate.Type.Method);this.updateControlState();}
function OwcSearchInSelectedFolder_getSelectedFolder()
{if(!this.m_oFolderTree)
return null;var oSelectedItem=this.m_oFolderTree.getSelectedItem();if(!oSelectedItem)
return null;return oSelectedItem.getContentItem();}
function OwcSearchInSelectedFolder_updateControlState(oSelectedFolder)
{if(oSelectedFolder==undefined)
oSelectedFolder=this.getSelectedFolder();if(!oSelectedFolder)
{this.setHtmlValue("");this.HtmlElement.disabled=true;}
else
this.HtmlElement.disabled=false;}
function OwcSearchInSelectedFolder_onFolderSelectionChanged(oEvent)
{var oFolderItem=null;if(oEvent.newSelection&&oEvent.newSelection.length>0)
oFolderItem=oEvent.newSelection[0].getContentItem();this.updateControlState(oFolderItem);}
function OwcSearchInSelectedFolder_readFromSearchData(oDataObject,sFieldName)
{var oSearchTerm=oDataObject.findSearchInTerm(sFieldName,this.m_oSearchOptions);var sValue=Olive.Controls.SearchInSelectedFolder.Mode.All;if(oSearchTerm)
{var nRecursiveMode=oSearchTerm.getRecursiveMode();if(nRecursiveMode==Olive.Data.SearchOptions.Mode.Enabled)
sValue=Olive.Controls.SearchInSelectedFolder.Mode.Recursive;else
sValue=Olive.Controls.SearchInSelectedFolder.Mode.Selected;}
return this.setValue(sValue);}
function OwcSearchInSelectedFolder_writeToSearchData(oDataObject,sFieldName)
{var oSelectedFolder=this.getSelectedFolder();if(!oSelectedFolder)
return;var sCurValue=this.getValue();var oSearchOptions=Object_Clone(this.m_oSearchOptions);var oFolderRefParams=new QueryString();oSelectedFolder.buildRefParams(oFolderRefParams);var sFolderRef=oFolderRefParams.getQueryString(",","=",false);switch(sCurValue.toLowerCase())
{case Olive.Controls.SearchInSelectedFolder.Mode.Selected:oSearchOptions.setRecursiveMode(Olive.Data.SearchOptions.Mode.Disabled);break;case Olive.Controls.SearchInSelectedFolder.Mode.Recursive:oSearchOptions.setRecursiveMode(Olive.Data.SearchOptions.Mode.Enabled);break;default:return;}
oDataObject.addSearchInField(sFieldName,sFolderRef,oSearchOptions);}
JScript.Type.RegisterClass("Olive.Controls.SearchInSelectedFolder",Olive.Controls.SearchInSelectedFolder,Olive.Controls.SearchInFolder);}
if(!Olive.Controls.SearchForm)
{Olive.Controls.SearchForm=function OwcSearchForm()
{this.m_oValue=this.createNewValue();}
Olive.Controls.SearchForm.DeclareType=function OwcSearchForm_DeclareType()
{this.DeclareMethod("submitSearch",OwcSearchForm_submitSearch);this.ReplaceMethod("createNewValue",OwcSearchForm_createNewValue);this.ReplaceMethod("updateControlFromDataField",OwcSearchForm_updateControlFromDataField);this.ReplaceMethod("updateDataFieldFromControl",OwcSearchForm_updateDataFieldFromControl);this.OverrideMethod("bindHtmlElement",OwcSearchForm_bindHtmlElement);this.OverrideMethod("filterControl",OwcSearchForm_filterControl);this.OverrideMethod("autoApplyFieldInterface",OwcSearchForm_autoApplyFieldInterface);}
Olive.Controls.SearchForm.ApplyPrototype=function OwcSearchForm_ApplyPrototype(rObject,bDynamic)
{Olive.CmdTarget.RegisterCommand(rObject,OwcCmd_SubmitSearch,"submitSearch");rObject.registerOwcEventsClass2("searchRequest","onSearchRequest",true);rObject.registerControlType(Olive.Controls.controlTypeNames.Field,Olive.Controls.SearchTerm);rObject.registerControlType(Olive.Controls.controlTypeNames.UserParam,Olive.Controls.SearchUserParam);rObject.registerControlType(Olive.Controls.controlTypeNames.SearchOption,Olive.Controls.SearchOption);rObject.registerControlType(Olive.Controls.controlTypeNames.SearchInSelectedFolder,Olive.Controls.SearchInSelectedFolder);rObject.registerControlType(Olive.Controls.controlTypeNames.SearchInFolderLookup,Olive.Controls.SearchInFolderLookup);rObject.registerControlType(Olive.Controls.controlTypeNames.SearchInTreeAndFolder,Olive.Controls.SearchInTreeAndFolder);}
function OwcSearchForm_bindHtmlElement(oHtmlElement)
{if(this.BaseClassMethod)
this.BaseClassMethod.apply(this,arguments);DHTML.attachEvent(oHtmlElement,"keypress",OwcSearchForm_DHTML_onKeyPress);}
function OwcSearchForm_DHTML_onKeyPress(oEvent)
{if(oEvent.keyCode==13)
this.m_OwcControl.submitSearch();}
function OwcSearchForm_submitSearch()
{if(!this.updateData())
return false;var oEvent=this.createOwcEventObject("searchRequest");oEvent.SearchParams=Object_Clone(this.getValue());if(oEvent.SearchParams.m_arrFields&&typeof(oEvent.SearchParams.m_arrFields.text)!="undefined")
{this.fireOwcEvent(oEvent);}
else
{var sNoInputToSearch=this.getResString("SEARCH_EMPTYSTR");var oPage=this.getOwnerPage();var oSearchResControl=oPage.findControlByType(Olive.Controls.controlTypeNames.SearchRes);var oSearchResultsContainer;if(oSearchResControl)
{oSearchResultsContainer=oSearchResControl.HtmlElement;}
if(oSearchResultsContainer&&typeof(oSearchResultsContainer)!="undefined")
{DHTML.pasteHtmlContent(oSearchResultsContainer,sNoInputToSearch);}
else
{this.fireOwcEvent(oEvent);}}
Object_Destroy(oEvent);}
function OwcSearchForm_createNewValue()
{return new Olive.Data.SearchQuery();}
function OwcSearchForm_updateControlFromDataField(oControl,oDataObject,sFieldName)
{return oControl.readFromSearchData(oDataObject,sFieldName);}
function OwcSearchForm_updateDataFieldFromControl(oControl,oDataObject,sFieldName)
{oControl.writeToSearchData(oDataObject,sFieldName);return true;}
function OwcSearchForm_filterControl(ctxScanner,oControl)
{if(!Olive.Controls.ISearchFormField.IsImplementedBy(oControl))
return(Olive.Controls.Scanner.FilterMode.Reject+Olive.Controls.Scanner.FilterMode.StopFilter);if(this.BaseClassMethod)
return this.BaseClassMethod.apply(this,arguments);return Olive.Controls.Scanner.FilterMode.Process;}
function OwcSearchForm_autoApplyFieldInterface(oControl,oHtmlElement,sFieldName)
{JScript.Type.ApplyTypeOnScriptObject(Olive.Controls.SearchTerm,oControl);}
JScript.Type.RegisterClass("Olive.Controls.SearchForm",Olive.Controls.SearchForm,Olive.Controls.Control,[Olive.Controls.IForm]);Olive.Controls.RegisterControlType(Olive.Controls.controlTypeNames.SearchForm,Olive.Controls.SearchForm);}