/******************************************************************************
*
*	Pivotal eService 5.0
*
*	File:		searchobject.js 
*	Purpose:	Search object javascript functions.
*	Date:		January 1, 2003
*
******************************************************************************/

function PivotalSearch( objSearchData )
{
	this.search_data = objSearchData;
	this.search_quickSearch = null;
	this.search_fullText = null;
	this.search_resultsListItems = null
	
	//need to implement the parameters & refinements = initialization & access
	this.search_parameters = null;
	this.search_refinements = null;
}

PivotalSearch.prototype.getSearchID = function()
{
	return this.search_data[SEARCH_SEARCHID];
}

PivotalSearch.prototype.getSortOrder = function()
{
	return this.search_data[SEARCH_SORTORDER];
}

PivotalSearch.prototype.getSortItem = function()
{
	return this.search_data[SEARCH_SORTITEM];
}

PivotalSearch.prototype.getSearchType = function()
{
	return this.search_data[SEARCH_SEARCHTYPE];
}

PivotalSearch.prototype.getRefinements = function()
{
	return this.search_refinements;
}

PivotalSearch.prototype.getRefinementCount = function()
{
	return this.search_data[SEARCH_REFINEMENTS].length;
}
PivotalSearch.prototype.initializeRefinements = function()
{
	if (this.search_refinements == null){
		this.search_refinements = new Array();
		for ( var i=0; i < this.getRefinementCount(); i++){
			this.search_refinements[i] = this.search_data[SEARCH_REFINEMENTS][i];
		}
	}
	return this.search_refinements;
}
PivotalSearch.prototype.getRefinementData = function( intIndex, intDataIndex )
{
	/*
		DataIndex
		0 = Parameter Field Name
		1 = RId
		2 = checked?
	*/
	
	this.initializeRefinements();
	return this.search_refinements[intIndex][intDataIndex];
}
PivotalSearch.prototype.setRefinementData = function( intRefineIndex, intDataIndex, strDataValue )
{
	/*
		DataIndex
		0 = Parameter Field Name
		1 = RId
		2 = checked?
	*/
	
	this.initializeRefinements();
	return this.search_refinements[intRefineIndex][intDataIndex] = strDataValue;
}

PivotalSearch.prototype.getParameters = function()
{
	return this.search_parameters;
}
PivotalSearch.prototype.getParameterCount = function()
{
	return this.search_data[SEARCH_PARAMETERS].length;
}

PivotalSearch.prototype.initializeParameters = function()
{
	if (this.search_parameters == null){
		this.search_parameters = new Array();
		for ( var i=0; i < this.getParameterCount(); i++){
			this.search_parameters[i] = this.search_data[SEARCH_PARAMETERS][i];
		}
	}
	return this.search_parameters;
}
PivotalSearch.prototype.getParameterData = function( intParamIndex, intDataIndex )
{
	/*
		DataIndex
		0 = Parameter Field Name
		1 = Field Label
		2 = Data Type
		3 = Is Optional?
		4 = Data Value
		5 = Display Value
		6 = Field Name
	*/
	this.initializeParameters();
	return this.search_parameters[intParamIndex][intDataIndex];
}


PivotalSearch.prototype.setParameterData = function( intParamIndex, intDataIndex, strData)
{
	/*
		DataIndex
		0 = Parameter Field Name
		1 = Field Label
		2 = Data Type
		3 = Is Optional?
		4 = Data Value
		5 = Display Value
		6 = Field Name
	*/
	this.search_parameters[intParamIndex][intDataIndex] = strData;
}

PivotalSearch.prototype.getSelectedTab = function()
{
	return this.search_data[SEARCH_SELECTEDTAB];
}
PivotalSearch.prototype.getSearchResultListName = function()
{
	return this.search_data[SEARCH_RESULTSLIST];
}

PivotalSearch.prototype.initializeFullTextSource = function()
{
	if (this.search_fullText == null){
		this.search_fullText = new Array();
		for ( var i=0; i < this.getFullTextSourceCount(); i++){
			this.search_fullText[i] = this.search_data[SEARCH_SEARCHSOURCE][i];
		}
	}
	return this.search_fullText;
}

PivotalSearch.prototype.getFullTextSourceCount = function()
{
	return this.search_data[SEARCH_SEARCHSOURCE].length;
}

PivotalSearch.prototype.getFullTextSourceByIndex = function( intIndex )
{
	this.initializeFullTextSource();
	return this.search_fullText[ intIndex ];
}

PivotalSearch.prototype.initializeQuickSearch = function()
{
	if (this.search_quickSearch == null){
		this.search_quickSearch = new Array();
		for ( var i=0; i < this.getQuickSearchCount(); i++){
			this.search_quickSearch[i] = this.search_data[SEARCH_QUICKSEARCHES][i];
		}
	}
	return this.search_quickSearch;
}

PivotalSearch.prototype.getQuickSearchCount = function()
{
	return this.search_data[SEARCH_QUICKSEARCHES].length;
}

PivotalSearch.prototype.getQuickSearchByIndex = function( intIndex )
{
	this.initializeQuickSearch();
	return this.search_quickSearch[ intIndex ];
}

PivotalSearch.prototype.getSearchText = function()
{
	return this.search_data[SEARCH_SEARCHTEXT];
}

PivotalSearch.prototype.getSearchName = function()
{
	return this.search_data[SEARCH_SEARCHNAME];
}

PivotalSearch.prototype.getSearchTableId = function()
{
	return this.search_data[SEARCH_SEARCHTABLEID];
}

PivotalSearch.prototype.getSearchLabel = function()
{
	return this.search_data[SEARCH_SEARCHLABEL];
}

PivotalSearch.prototype.getSRLFieldsCount = function()
{
	return this.search_data[SEARCH_SEARCHLISTITEMS].length;
}

PivotalSearch.prototype.initializeSRLFields = function()
{
	if (this.search_resultsListItems == null){
		this.search_resultsListItems = new Array();
		for ( var i=0; i < this.getSRLFieldsCount(); i++){
			this.search_resultsListItems[i] = this.search_data[SEARCH_SEARCHLISTITEMS][i];
		}
	}
	return this.search_resultsListItems;
}

PivotalSearch.prototype.getSRLItemsByIndex = function( intIndex )
{
	this.initializeSRLFields();
	return this.search_resultsListItems[ intIndex ];
}
