// Scripts for the Steven Scott web site
// Copyright (c)2002 ReGo. All rights reserved.
// Must be included after stevenscott.js


function PlayShow4() {
	currentIdx = -1;
	nextIdx = 0;
	showIsPaused = false;

	SSSetupScript4();
	SSPlaceGrid4();
	WriteControl();

	PlayShow24();
}

function PlayShow24() {
	currentIdx = nextIdx++;
	if(nextIdx == script4.scenes.length)
		nextIdx = script4.loopAtEnd;
	if(currentIdx >= script4.scenes.length || currentIdx < 0)
		currentIdx = 0;
	if(nextIdx >= 0) {
		playTimer = setTimeout('PlayShow24()', script4.scenes[currentIdx].totalTime);
	}

	if(currentIdx < script4.scenes.length)
		PlayScene(script4.scenes[currentIdx]);

}


function SSSetupScript4() {
	script4 = new SSScript('script4', -1);	// -1=stop after last scene, 0, 1, ... = Scene index

	var scene50s = new SSScene();
	scene50s.AddAction(new SSAction('hidessinfo4', '', 0, 0, 'gfx/txt_blanka.jpg', 0, 'gfx/txt_blankb.jpg', 0));
	scene50s.AddAction(new SSAction('hideFull', '', 0, 0));

	scene50s.AddAction(new SSAction('A1', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('A2', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('A3', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('A4', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('B1', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('B2', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('B3', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('B4', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('C1', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('C23', 'gfx/sq50c23.jpg', 0, 0));
	scene50s.AddAction(new SSAction('C4', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('D1', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('D2', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('D3', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('D4', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('E1', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('E2', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('E3', 'gfx/blank.jpg', 0, 0));
	scene50s.AddAction(new SSAction('E4', 'gfx/blank.jpg', 15, 0));
	script4.AddScene(scene50s);

	var scene50 = new SSScene();
//	scene50.AddAction(new SSAction('hidessinfo4', '', 0, 0, 'gfx/txt_blanka.jpg', 0, 'gfx/txt_blankb.jpg', 0));
//	scene50.AddAction(new SSAction('hideFull', '', 0, 0));
	scene50.AddAction(new SSAction('hideC23', '', 0, 0));

	scene50.AddAction(new SSAction('A1', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('A2', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('A3', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('A4', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('B1', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('B2', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('B3', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('B4', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('C1', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('C2', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('C3', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('C4', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('D1', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('D2', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('D3', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('D4', 'gfx/blank.jpg', 0, 0));
	scene50.AddAction(new SSAction('Er', 'gfx/sq50r5.jpg', 3, 0, 'gfx/txt_blanka.jpg', 0, 'gfx/txt_blankb.jpg', 0));
	script4.AddScene(scene50);

	var scene51 = new SSScene();
	scene51.AddAction(new SSAction('A1', 'gfx/blank.jpg', 0, 0, 'gfx/txt_blanka.jpg', 0, 'gfx/txt_blankb.jpg', 0));
	scene51.AddAction(new SSAction('A2', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('A3', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('A4', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('B1', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('B2', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('B3', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('B4', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('C1', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('C2', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('C3', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('C4', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('D1', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('D2', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('D3', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('D4', 'gfx/blank.jpg', 0, 0));
	scene51.AddAction(new SSAction('Er', 'gfx/sq50r5.jpg', 0, 0));

	scene51.AddAction(new SSAction('A1', 'gfx/sq51a.jpg', 0, 1));
	scene51.AddAction(new SSAction('A2', 'gfx/sq51b.jpg', 0, 1));
	scene51.AddAction(new SSAction('A3', 'gfx/sq51c.jpg', 0, 1));
	scene51.AddAction(new SSAction('A4', 'gfx/sq51d.jpg', 0, 1));
	scene51.AddAction(new SSAction('B1', 'gfx/sq51e.jpg', 0, 1));
	scene51.AddAction(new SSAction('B2', 'gfx/sq51f.jpg', 0, 1));
	scene51.AddAction(new SSAction('B3', 'gfx/sq51g.jpg', 0, 1));
	scene51.AddAction(new SSAction('B4', 'gfx/sq51h.jpg', 0, 1));
	scene51.AddAction(new SSAction('C1', 'gfx/sq51i.jpg', 0, 1));
	scene51.AddAction(new SSAction('C2', 'gfx/sq51j.jpg', 0, 1));
	scene51.AddAction(new SSAction('C3', 'gfx/sq51k.jpg', 0, 1));
	scene51.AddAction(new SSAction('C4', 'gfx/sq51l.jpg', 0, 1));
	scene51.AddAction(new SSAction('D1', 'gfx/sq51m.jpg', 0, 1));
	scene51.AddAction(new SSAction('D2', 'gfx/sq51n.jpg', 0, 1));
	scene51.AddAction(new SSAction('D3', 'gfx/sq51o.jpg', 0, 1));
	scene51.AddAction(new SSAction('D4', 'gfx/sq51p.jpg', 0, 1));
	scene51.AddAction(new SSAction('Er', 'gfx/sq51r5.jpg', 15, 1, 'gfx/txt_blanka.jpg', 0, 'gfx/txt_blankb.jpg', 0));
	script4.AddScene(scene51);


	var scene52 = new SSScene();
	scene52.AddAction(new SSAction('ABCD', 'gfx/sq51full.jpg', 0, 0));
	scene52.AddAction(new SSAction('Er', 'gfx/sq51r5.jpg', 0, 0));

	scene52.AddAction(new SSAction('ABCD', 'gfx/sq52.jpg', 0, 1));
	scene52.AddAction(new SSAction('Er', 'gfx/sq52r5.jpg', 15, 1));
	script4.AddScene(scene52);


	var scene53 = new SSScene();
	scene53.AddAction(new SSAction('ABCD', 'gfx/sq52.jpg', 0, 0));
	scene53.AddAction(new SSAction('Er', 'gfx/sq52r5.jpg', 0, 0));

	scene53.AddAction(new SSAction('ABCD', 'gfx/sq53.jpg', 0, 1));
	scene53.AddAction(new SSAction('Er', 'gfx/sq53r5.jpg', 15, 1));
	script4.AddScene(scene53);


	var scene54 = new SSScene();
	scene54.AddAction(new SSAction('Full', 'gfx/sq53full.jpg', 0, 0));

	scene54.AddAction(new SSAction('Full', 'gfx/sq54.jpg', 18, 1));
	script4.AddScene(scene54);


	var scene55 = new SSScene();
	scene55.AddAction(new SSAction('Full', 'gfx/sq54.jpg', 0, 0));
	scene55.AddAction(new SSAction('Full', 'gfx/sq55.jpg', 15, 1));
	script4.AddScene(scene55);


	var scene56 = new SSScene();
	scene56.AddAction(new SSAction('Full', 'gfx/sq55.jpg', 0, 0));
	scene56.AddAction(new SSAction('Full', 'gfx/sq56.jpg', 15, 1));
	script4.AddScene(scene56);

	var scene57 = new SSScene();
	scene57.AddAction(new SSAction('Full', 'gfx/sq56.jpg', 0, 0));
	scene57.AddAction(new SSAction('Full', 'gfx/sq57.jpg', 15, 1));
	script4.AddScene(scene57);

	var scene58 = new SSScene();
	scene58.AddAction(new SSAction('Full', 'gfx/sq57.jpg', 0, 0));
	scene58.AddAction(new SSAction('Full', 'gfx/sq58.jpg', 15, 1));
	script4.AddScene(scene58);

	var scene59 = new SSScene();
	scene59.AddAction(new SSAction('Full', 'gfx/sq58.jpg', 0, 0));
	scene59.AddAction(new SSAction('Full', 'gfx/sq59.jpg', 15, 1));
	script4.AddScene(scene59);

	var scene60 = new SSScene();
	scene60.AddAction(new SSAction('Full', 'gfx/sq59.jpg', 0, 0));
	scene60.AddAction(new SSAction('Full', 'gfx/sq60.jpg', 15, 1));
	script4.AddScene(scene60);

	var scene61 = new SSScene();
	scene61.AddAction(new SSAction('Full', 'gfx/sq60.jpg', 0, 0));
	scene61.AddAction(new SSAction('Full', 'gfx/sq61.jpg', 20, 1));
	script4.AddScene(scene61);

	var scene62 = new SSScene();
	scene62.AddAction(new SSAction('Full', 'gfx/sq61.jpg', 0, 0));
	scene62.AddAction(new SSAction('Full', 'gfx/sq62.jpg', 10, 0));
	script4.AddScene(scene62);

// Info
	var sceneInfo4 = new SSScene();
	sceneInfo4.AddAction(new SSAction('hideFull', '', 0, 0));
	sceneInfo4.AddAction(new SSAction('ssinfo4', '', 20, 0, 'gfx/txt_blanka.jpg', 0, 'gfx/txt_blankb.jpg', 0));
	script4.AddScene(sceneInfo4);

	if(scriptHide)
		delete scriptHide;
	if(sceneHide)
		delete sceneHide;

	scriptHide = new SSScript('scriptHide', -1);
	sceneHide = new SSScene();
	sceneHide.AddAction(new SSAction('hideFull', '', 0, 0));
	sceneHide.AddAction(new SSAction('hidessinfo4', '', 0, 0));
	sceneHide.AddAction(new SSAction('hideABCD', '', 0, 0));
	sceneHide.AddAction(new SSAction('hideEr', '', 0, 0));
	scriptHide.AddScene(sceneHide);

	currentLength = script4.scenes.length;
}


function SSPlaceGrid4() {

	var x=0, y=0;
	var i, j, h, w, lyr, name, name2;

	w = gridCols*gridWidth;
	h = Math.floor((gridRows*gridHeight) / 3);

	for(i=0 ; i<gridRows ; i++) {
		y = gridOffsetY + i*gridHeight - i*gridLine;
		for(j=0 ; j<gridCols ; j++) {
			name = rowNames[i] + colNames[j];
			name2 = 'g' + name;
			x = gridOffsetX + j*gridWidth - j*gridLine;

			lyr = new lib_obj(name2);
			lyr.css.width = gridWidth;
			lyr.css.height = gridHeight;
			lyr.moveIt(x, y);
			lyr.showIt();

			theGrid[i][j] = new lib_obj(name);
			theGrid[i][j].css.width = pictureWidth;
			theGrid[i][j].css.height = pictureHeight;
			theGrid[i][j].moveIt(x+gridLine, y+gridLine);
			theGrid[i][j].showIt();

			if(i == 1 && j == 1) {
				theC23G = new lib_obj('gC23');
				theC23G.css.width = 2*gridWidth-gridLine;
				theC23G.css.height = 3*gridHeight-2*gridLine;
				theC23G.moveIt(x, y);

				theC23 = new lib_obj('C23');
				theC23.css.width = 2*pictureWidth+gridLine;
				theC23.css.height = 3*pictureHeight+2*gridLine;
				theC23.moveIt(x+gridLine, y+gridLine);
			}
		}

		// Place row
		name = rowNames[i] + 'r';
		name2 = 'g' + name;

		theRowsG[i] = new lib_obj(name2);
		theRowsG[i].css.width = gridFullW;
		theRowsG[i].css.height = gridHeight;
		theRowsG[i].moveIt(gridOffsetX, y);

		theRows[i] = new lib_obj(name);
		theRows[i].moveIt(gridOffsetX+gridLine, y+gridLine);
		theRows[i].css.width = gridFullW-2*gridLine;
		theRows[i].css.height = pictureHeight;
	}
//	theRows[theRows.length-1].showIt();
//	theRowsG[theRowsG.length-1].showIt();

	// The upper 4/5th part
	theABCDG = new lib_obj('gABCD');
	theABCDG.moveIt(gridOffsetX, gridOffsetY);
	theABCDG.css.width = gridFullW;
	theABCDG.css.height = gridFullH-gridHeight+gridLine;

	theABCD = new lib_obj('ABCD');
	theABCD.moveIt(gridOffsetX+gridLine, gridOffsetY+gridLine);
	theABCD.css.width = gridFullW-2*gridLine;
	theABCD.css.height = gridFullH-3*gridLine-pictureHeight;

	// Full picture
	theFullG = new lib_obj('gFull');
	theFullG.moveIt(gridOffsetX, gridOffsetY);
	theFullG.css.width = gridFullW;
	theFullG.css.height = gridFullH;

	theFull = new lib_obj('Full');
	theFull.moveIt(gridOffsetX+gridLine, gridOffsetY+gridLine);
	theFull.css.width = gridFullW-2*gridLine;
	theFull.css.height = gridFullH-2*gridLine;

	theInfo4 = new lib_obj('ssinfo4');
	theInfo4.moveIt(gridOffsetX, gridOffsetY);
	theInfo4.css.width = gridFullW;
	theInfo4.css.height = gridFullH;

	// Place the text layers
	y = gridOffsetY + gridRows*gridHeight - gridRows + 5;
	theBottomText = new lib_obj('bottom');
	theBottomText.moveIt(gridOffsetX, y);
	theBottomText.showIt();

	y = Math.floor((gridOffsetY - textHeight)/2);
	theTopText1 = new lib_obj('text1');
	theTopText1.css.width = textPartW;
	theTopText1.css.height = textHeight;
	theTopText1.moveIt(gridOffsetX, y);
	theTopText1.showIt();
	theTopText2 = new lib_obj('text2');
	theTopText2.css.height = textHeight;
	theTopText2.moveIt(gridOffsetX + textPartW, y);
	theTopText2.showIt();

	theTopText = new lib_obj('top');
	theTopText.moveIt(gridOffsetX, 0);
}

