<<<<<<< itemFilter.js
// itemFilter.js
//
// Collects all of the required filter types to bring up an item detail and saves them
// Once all the types have been indicated and set, the toHref method can return a valid
// URL to invoke the page.
// @author Scott Ellis
//
function ItemFilterHref( navkey, transaction ) 
{
	this.navkey = navkey;
	this.transaction = transaction;
	this.filterNames = new Array();
	this.level = 0;
	this.itemKey = null;
	this.bIncludeReturn = false;
	this.bNoPush = false;
	this.retailerId = null;
	
	this.addFilter = ItemFilterHrefAddFilter;
	this.toHref = ItemFilterHrefToHref;
	this.toTxnVarArray = ItemFilterHrefToTxnVarArray;
	this.setTypeValue = ItemFilterHrefSetTypeValue;
	this.setItemKey = ItemFilterHrefSetItemKey;
	this.setRetailerId = ItemFilterHrefSetRetailerId;
}

function ItemFilterHrefSetRetailerId( retailerId )
{
	this.retailerId = retailerId;
}

function ItemFilterHrefSetItemKey( itemKey )
{
	this.itemKey = itemKey;
}

function ItemFilterHrefAddFilter( typeName, typeValue )
{
	this.filterNames[ this.filterNames.length ] = 
		new ItemFilterType( typeName, this.level++, typeValue );
}

function ItemFilterHrefSetTypeValue( typeName, typeValue )
{
	for( i=0; i < this.filterNames.length; i++ )
	{
		var itemFilterType = this.filterNames[i];
		if( itemFilterType.typeName == typeName )
		{
			itemFilterType.typeValue = typeValue;
			return;
		}
	}
}

function ItemFilterHrefToHref( bNoSave )
{
	var i;
	var href = "go( '" + this.navkey + "', '" + this.transaction +
		"', null, " + (bNoSave?"true":"null") + ", ";
	href += this.toTxnVarArray();
	href += " )";
	return href;
}

function ItemFilterHrefToTxnVarArray()
{
	var i;
	var href = "new Array( ";
	for( i=0; i < this.filterNames.length; i++ )
	{
		href += this.filterNames[i].toTxnVar();
		if ( i < this.filterNames.length-1 )
		{		
			href += ", ";
		}
	}
	if ( this.itemKey )
	{
		href += ", new TxnVar( 'ItemDetailItemKey', '" + this.itemKey + "' )";
	}
	if ( this.retailerId )
	{
		href += ", new TxnVar( 'ItemRetailerId', '" + this.retailerId + "' )";
	}
	
	if( this.bIncludeReturn )
	{
		var lastNavkey = document.forms['navform'].elements.lastNavkey.value;
		var lastTxn = document.forms['navform'].elements.lastTransaction.value;
		if ( href.length > 12 )
		{
			href += ", ";
		}
		href += "new TxnVar( 'BackNavNavkey', '";
		href += lastNavkey;
		href += "' ), new TxnVar( 'BackNavTransaction', '";
		href += lastTxn;
		href += "' )";
	}

	if( this.bNoPush )
		href += ", new TxnVar( 'BackNoPush', 'true' )";
	
	href += " )";
	return href;
}


function ItemFilterType( typeName, level, typeValue )
{
	this.typeName = typeName;
	this.level = level;
	this.typeValue = typeValue;
	this.toTxnVar = ItemFilterTypeToTxnVar;
}

function ItemFilterTypeToTxnVar()
{
	return "new TxnVar( 'ItemFilter_" + this.level + "_" +
		this.typeName + "', '" + this.typeValue + "' )";
}=======
// itemFilter.js
//
// Collects all of the required filter types to bring up an item detail and saves them
// Once all the types have been indicated and set, the toHref method can return a valid
// URL to invoke the page.
// @author Scott Ellis
//
function ItemFilterHref( navkey, transaction ) 
{
	this.navkey = navkey;
	this.transaction = transaction;
	this.filterNames = new Array();
	this.level = 0;
	this.itemKey = null;
	this.bIncludeReturn = false;
	this.bNoPush = false;
	
	this.addFilter = ItemFilterHrefAddFilter;
	this.toHref = ItemFilterHrefToHref;
	this.toTxnVarArray = ItemFilterHrefToTxnVarArray;
	this.setTypeValue = ItemFilterHrefSetTypeValue;
	this.setItemKey = ItemFilterHrefSetItemKey;
}

function ItemFilterHrefSetItemKey( itemKey )
{
	this.itemKey = itemKey;
}

function ItemFilterHrefAddFilter( typeName, typeValue )
{
	this.filterNames[ this.filterNames.length ] = 
		new ItemFilterType( typeName, this.level++, typeValue );
}

function ItemFilterHrefSetTypeValue( typeName, typeValue )
{
	for( i=0; i < this.filterNames.length; i++ )
	{
		var itemFilterType = this.filterNames[i];
		if( itemFilterType.typeName == typeName )
		{
			itemFilterType.typeValue = typeValue;
			return;
		}
	}
}

function ItemFilterHrefToHref( bNoSave )
{
	var i;
	var href = "go( '" + this.navkey + "', '" + this.transaction +
		"', null, " + (bNoSave?"true":"null") + ", ";
	href += this.toTxnVarArray();
	href += " )";
	return href;
}

function ItemFilterHrefToTxnVarArray()
{
	var i;
	var href = "new Array( ";
	for( i=0; i < this.filterNames.length; i++ )
	{
		href += this.filterNames[i].toTxnVar();
		href += ", ";
	}
	href += " new TxnVar( 'ItemDetailItemKey', '" + this.itemKey + "' )";
	if( this.bIncludeReturn )
	{
		var lastNavkey = document.forms['navform'].elements.lastNavkey.value;
		var lastTxn = document.forms['navform'].elements.lastTransaction.value;
		href += ", new TxnVar( 'BackNavNavkey', '";
		href += lastNavkey;
		href += "' ), new TxnVar( 'BackNavTransaction', '";
		href += lastTxn;
		href += "' )";
	}

	if( this.bNoPush )
		href += ", new TxnVar( 'BackNoPush', 'true' )";
	
	href += " )";
	
	return href;
}


function ItemFilterType( typeName, level, typeValue )
{
	this.typeName = typeName;
	this.level = level;
	this.typeValue = typeValue;
	this.toTxnVar = ItemFilterTypeToTxnVar;
}

function ItemFilterTypeToTxnVar()
{
	return "new TxnVar( 'ItemFilter_" + this.level + "_" +
		this.typeName + "', '" + this.typeValue + "' )";
}

>>>>>>> 1.1

