// panel_stage_ctls.js

//----------------------------------------------------------------
function PanelStageCtls(o){
	o.panelObj = this;
	this.folder = new Folder(o.thumbsFolderPath, PanelStageCtls_Build, o);
}

//----------------------------------------------------------------
function PanelStageCtls_Build(folder, o){
	o.panelObj = this;
	//------ CONTROL PANEL ------------
	this.panel = new Panel({
		id: "stage_ctls",
		title: "Background",
		top: o.top,
		left: o.left,
		height: 220,
		width: 330,
		backgroundColor: "blue",
		backgroundImage: "url('../dome/images/backgrounds/marble_122.gif)"
	});

	t = o.panelObj.panel.div;
	t.stage = o.stage;
	t.container = o.panelObj;
	t.o = this;
	
	new PopupMenu({
		parent: o.panelObj.panel.div,
		top:25,
		left:4,
		height:25,
		width:80,
		options: "Small,Medium,Large",
		onchange: ChangeStageSize,
		value:"Medium",
		name: "first"
	});	

	this.grid = new Grid({
		parent: o.panelObj.panel.div,
		top: 21,
		left: 170,
		height: 140,
		width: 140,
		maxCellSize: {width:80,height:80},
		fontColor: "green",
		cellCursor: "hand",
		pictFolderPath: o.thumbsFolderPath,
		cellView: "bkgnd",			// bkgnd or pict
		pictFolder: folder,
		dragPictFolderPath: o.thumbsFolderPath,
		dragArea: o.stage.div,
		selectRowHandler: SelectStageBkgndFunc
	});
}
//--------------------------------------------------------------------------
function SelectStageBkgndFunc(grid, row)
	{
	var filename = grid.pictFolder.GetImageFileByIndex(row);
	if (grid.dragArea != undefined) grid.dragArea.obj.SetBackgroundImage(grid.dragPictFolderPath+"/"+filename);
	}

//-----------------------------------------------------------------------------
PanelRecorderCtls.prototype.SetReadout = function(ticks)
	{
	this.timeReadout.elem.value = TickToMMSSHH(ticks).str;
	}

//----------------------------------------------------------------
function ChangeStageSize(e)
	{
	var stage = mStage;
	var target = GetEventTarget(e);

	switch(target.value)
		{
		case "Small":
			stage.SetSize(ID_Scr640x480);
			break;
			
		case "Medium":
			stage.SetSize(ID_Scr800x600);
			break;
			
		case "Large":
			stage.SetSize(ID_Scr1024x768);
			break;
		}
	}
	

