//
//	Copyright (c) 2003 General Electric Medical Systems IT
//
//	Version control:
//		$Archive: /releases/FreeViewer_2.0/src/WebViewer/FreeViewer/HTML/seriesmn.js $
//		$Revision: 3 $
//		$Date: 3/04/03 11:59a $
//		$Author: Marceld $
//

DeriveFrom(SeriesLayoutManager, TableLayoutManager);

//
// SeriesLayoutManager C'tor
//
function SeriesLayoutManager(elemContainer)
{
	this._activeseriesindex = 0;	// index of the series with the active viewport (0 or 1)
	this._rgSeries = null;
	this.CtorTableLayoutManager(this, elemContainer);
	this.SetSeriesLayout(1, 1);
}

//
// CreateCellContent
//
function SeriesLayoutManager.prototype.CreateCellContent(iCell)
{ with(this) {
	return '<div class=\"classContainer\" id=\"series' + iCell + '"></div>';
}}

//
// SetSeriesLayout
//
function SeriesLayoutManager.prototype.SetSeriesLayout(newRowCnt, newColCnt)
{ with(this) {
	if (newRowCnt == GetRowCount() && newColCnt == GetColCount())
		return false;

	_rgSeries = new Array();
	ChangeLayout(newRowCnt, newColCnt);
	if (_activeseriesindex >= GetSeriesCount())
	{
		_activeseriesindex = 0;
	}
	InitSeriesAreas();
	return true;
}}

//
// InitSeriesAreas
//
function SeriesLayoutManager.prototype.InitSeriesAreas()
{ with(this) {
	var nCellCnt = GetCellCount();
	for (var i = 0; i < nCellCnt; i++)
	{
		_rgSeries[_rgSeries.length] = new ViewportLayoutManager(GetTableCell(i).children[0], i);
	}
}}

//
// GetActiveSeries
//
function SeriesLayoutManager.prototype.GetActiveSeries()
{ with(this) {
	return GetSeries(_activeseriesindex);
}}

//
// SetActiveSeries
//
function SeriesLayoutManager.prototype.SetActiveSeries(nSeriesIndex)
{ with(this) {
	if (_activeseriesindex != nSeriesIndex)
	{
		GetActiveViewport().MakeInactive();
		_activeseriesindex = nSeriesIndex;
	}
	return GetSeries(_activeseriesindex);
}}

//
// GetSeries
//
function SeriesLayoutManager.prototype.GetSeries(iIdx)
{ with(this) {
	return _rgSeries[iIdx];
}}

//
// GetSeriesCount
//
function SeriesLayoutManager.prototype.GetSeriesCount()
{ with(this) {
	return GetCellCount();
}}

//
// GetActiveSeriesIndex
//
function SeriesLayoutManager.prototype.GetActiveSeriesIndex()
{ with (this) {
	return _activeseriesindex;
}}

//
// GetSeriesLayout
//
function SeriesLayoutManager.prototype.GetSeriesLayout()
{ with (this) {
	return GetRowCount().toString() + 'x' + GetColCount().toString();
}}
