function clFrameDescriptor( sName, sSrc, sDimension, fResize, nBorder, scroll, sTitle, nTabIndex )
{
	this.sName      = sName
	this.sSrc       = sSrc
	this.sDimension = sDimension
	this.fResize    = fResize
	this.nBorder    = nBorder
	this.scroll     = scroll
	this.sTitle     = (sTitle == null) ? '' : sTitle
	this.nTabIndex  = nTabIndex
}

clFrameDescriptor.prototype.getHTML = function()
{
	return buildFrameHTML( this.sName, this.sSrc, this.fResize, this.nBorder, this.scroll, this.sTitle, this.nTabIndex )
}

function clFramesetDescriptor( rowsOrCols, arFrames, onLoad, onUnload )
{
	this.rowsOrCols = rowsOrCols
	this.arFrames   = arFrames
	
	this.onLoad     = onLoad
	this.onUnload   = onUnload
}

clFramesetDescriptor.prototype.getHTML = function()
{
	var arFrameHTML = new Array()
	var arFrameSizes = new Array()

	for ( var i=0; i < this.arFrames.length; i++ )
	{
		if ( this.arFrames[i] )
			{
			arFrameSizes.push(this.arFrames[i].sDimension)
			arFrameHTML.push(this.arFrames[i].getHTML())
			}
	}

	return buildFramesetHTML( this.rowsOrCols, arFrameSizes, arFrameHTML, this.onLoad, this.onUnload, 0 )
}

function clFS2Descriptor( rowsOrCols, topOrLeft, bottomOrRight, nBorderWidth, sBorderColor )
{
	this.rowsOrCols    = rowsOrCols
	this.topOrLeft     = topOrLeft
	this.bottomOrRight = bottomOrRight
	this.nBorderWidth  = nBorderWidth
	this.sBorderColor  = sBorderColor
}

function buildFrameHTML( sName, sSrc, fResize, sFrameBorder, scroll, sTitle, nTabIndex )
{
	var sScroll = scroll
	if ( scroll == null )
		sScroll = 'auto'
	else if ( scroll == 0 )
		sScroll = 'no'
	else if ( scroll == 1 )
		sScroll = 'yes'

	var sBorder = ''
	if ( !isEmptyString(sFrameBorder) )
		sBorder = ' frameborder="' + sFrameBorder + '"'
	
	var sResize = (fResize ? '' : 'noresize')
	var sHTML = '<frame name="' + sName + '"' +
	             ' src="' + sSrc + '"' +
	             ' ' + sResize +
	             ' ' + sBorder +
	             ' scrolling="' + sScroll + '"' +
				 ' title="' + sTitle + '"' +
				 ((nTabIndex==null) ? '' : ' tabindex="' + nTabIndex + '"') +
	             '>\n'
	return sHTML
}

function setupLayout( fs, arFrameSizes, arFrameHTML )
{
	var topOrLeft     = fs.topOrLeft
	var bottomOrRight = fs.bottomOrRight
	if (!isEmptyString(topOrLeft.sSrc))
	{
		arFrameSizes.splice(0, null, topOrLeft.sDimension)
		arFrameHTML.splice(0, null, topOrLeft.getHTML())
	}

	if (!isEmptyString(bottomOrRight.sSrc))
	{
		arFrameSizes.push(bottomOrRight.sDimension)
		arFrameHTML.push(bottomOrRight.getHTML())
	}
}

function buildFramesetHTML( sRowsOrCols, arFrameSizes, arFrameHTML, sOnLoad, sOnUnload, nBorderWidth, sBorderColor )
{
	var sFSLayout = sRowsOrCols + '="' + arFrameSizes.join() + '"'
	var sBorderAttributes = ''
	if ( nBorderWidth > 0 )
	{
		// Turn on frame borders with the frameborder property.
		// For actual size, IE respects framespacing, while NN6 respects border.
		sBorderAttributes = 'frameborder="1" ' +
		                    'framespacing="' + nBorderWidth + '" ' +
		                    'border="' + nBorderWidth + '" ';
	}
	else if ( nBorderWidth == 0 )
	{
		sBorderAttributes = 'frameborder="0" ' +
		                    'framespacing="0" ' +
		                    'border="0" ';
	}

	if (!isEmptyString(sBorderColor))
	{
		sBorderAttributes += 'bordercolor="' + sBorderColor + '" '
	}

	var sHTML = '<frameset' +
	                ' ' + sBorderAttributes +
					' ' + sFSLayout +
					((sOnLoad == null) ? '' : ' onLoad="' + sOnLoad + '"') +
					((sOnUnload == null) ? '' : ' onUnload="' + sOnUnload + '"') +
					'>\n'

	for ( var i = 0; i < arFrameHTML.length; i++ )
	{
		sHTML += arFrameHTML[i]
	}

	sHTML += '</frameset>\n' 

	return sHTML
}
