function WSSDataTypes()
{
}

WSSDataTypes.NONE      = 0
WSSDataTypes.CHARACTER = 1
WSSDataTypes.NUMBER    = 2
WSSDataTypes.DATE      = 3
WSSDataTypes.TIME      = 4

function WSSViewField()
{
	this.sName        = ''
	this.sDisplayName = ''
	this.eDataType    = WSSDataTypes.CHARACTER
	this.nWidth       = -1
	this.nDecimals    = -1
	this.bPassword    = false
	this.bDisplayLink = false
	this.objLUT       = null // type == LUT

	this.objLink      = null // type == WSSHTLink
	this.objDataEntry = null // type == PageDataEntryElement

	// Not currently supported - replace data with an image
	// this.objImageLUT  = null
}

WSSViewField.prototype.clone = function()
{
	var oNew = new WSSViewField();

	oNew.sName        = this.sName       
	oNew.sDisplayName = this.sDisplayName
	oNew.eDataType    = this.eDataType   
	oNew.nWidth       = this.nWidth      
	oNew.nDecimals    = this.nDecimals   
	oNew.bPassword    = this.bPassword   
	oNew.bDisplayLink = this.bDisplayLink
	oNew.objLUT       = this.objLUT      

	oNew.objLink      = this.objLink       // TODO: these two should really be clone() calls, since they are objects
	oNew.objDataEntry = this.objDataEntry

	return oNew;
}

WSSViewField.prototype.getTypeStr = function()
{
	if ( this.eDataType == WSSDataTypes.CHARACTER )
		return 'C'
	else if ( this.eDataType == WSSDataTypes.NUMBER )
		return 'N'
	else if ( this.eDataType == WSSDataTypes.DATE )
		return 'D'
	else if ( this.eDataType == WSSDataTypes.TIME )
		return 'T'
	else
		return ''
}

WSSViewField.prototype.getNameOnly = function()
{
	// Returns the column name assuming that sName is either the column
	// name or is table.column

	var iLoc = this.sName.indexOf(".");
	if ( iLoc >= 0 )
		return this.sName.substring( iLoc+1 );

	return this.sName;
}

function WSSViewDataEntryField()
{
	this.bEditable = false
	this.bRequired = false
}
WSSViewDataEntryField.prototype = WSSViewField
WSSViewDataEntryField.prototype.getTypeStr = WSSViewField.prototype.getTypeStr

function WSSView()
{
	this.arFields = new Array()
}

WSSView.prototype.clone = function()
{
	var oNew = new WSSView();

	for ( var i=0; i < this.arFields.length; i++ )
		{
		oNew.addField( this.arFields[i].clone() );
		}

	return oNew;
}

WSSView.prototype.addField = function( objField )
{
	this.arFields[ this.arFields.length ] = objField
}

WSSView.prototype.removeField = function ( sFieldName )
{
	var oField = null;
	for ( var i=0; i < this.arFields.length; i++ )
		{
		if ( this.arFields[i].sName.toUpperCase() == sFieldName )
			{
			oField = this.arFields[i];
			this.arFields.splice( i, 1 );
			break;
			}
		}

	return oField;
}

WSSView.prototype.getFields = function()
{
	return this.arFields
}

WSSView.prototype.getNumFields = function()
{
	return this.arFields.length
}

WSSView.prototype.getField = function( nFieldID )
{
	if ( (nFieldID < 0) || (nFieldID >= this.arFields.length) )
		return null

	return this.arFields[nFieldID]
}

WSSView.prototype.getFieldID = function( sColumnName )
{
	var nNumFields = this.arFields.length
	for (var i = 0; i < nNumFields; i++)
	{
		if ( this.arFields[i].sName == sColumnName )
			return i
	}

	return -1
}
