/*
0x01.js
copyright (c) 2003 ed sibbald
[ed sibbald at cmepw dot org]
*/

var bLoaded = false;
var BoxArray = new Array(10);
BoxArray[0]  = new Image(); BoxArray[0].src  = "img/0x01/box-1.gif";
BoxArray[1]  = new Image(); BoxArray[1].src  = "img/0x01/box-1.gif";
BoxArray[2]  = new Image(); BoxArray[2].src  = "img/0x01/box-0.gif";
BoxArray[3]  = new Image(); BoxArray[3].src  = "img/0x01/box-0.gif";
BoxArray[4]  = new Image(); BoxArray[4].src  = "img/0x01/box-1.gif";
BoxArray[5]  = new Image(); BoxArray[5].src  = "img/0x01/box-0.gif";
BoxArray[6]  = new Image(); BoxArray[6].src  = "img/0x01/box-1.gif";
BoxArray[7]  = new Image(); BoxArray[7].src  = "img/0x01/box-0.gif";
BoxArray[8]  = new Image(); BoxArray[8].src  = "img/0x01/box-1.gif";
BoxArray[9]  = new Image(); BoxArray[9].src  = "img/0x01/box-1.gif";
var iBoxCount = 0;
var ARed = new Image(); ARed.src = "img/0x01/A-red.gif";
var bShowTextPane = false;
var iTextPaneShowing = -1;
var TextPaneLeftIncArray = new Array(-250, -350, -150);
var TextPaneTopIncArray = new Array(-250, -60, 55);
var bRedirect = false;
var Spacer = new Image(); Spacer.src = "img/spacer.gif";


function OnLoad()
	{ bLoaded = true; }


function OnMouseOverBox(iIndex)
{
	if (!bLoaded)
		return;
	var sImageName = "box" + iIndex;
	if (document.images[sImageName].src != BoxArray[iIndex].src) {
		document.images[sImageName].src = BoxArray[iIndex].src;
		iBoxCount++;
		if (iBoxCount == 10) {
			document.images["A"].src = ARed.src;
			document.images["A"].style.cursor = "pointer";
			bShowTextPane = true;
		}
	}
}


function OnMouseOverA()
	{ if (bRedirect) document.images["A"].src = ARed.src; }


function OnMouseOutA()
	{ if (bRedirect) document.images["A"].src = Spacer.src; }


function OnClickA()
{
	if (bShowTextPane) {
		iTextPaneShowing = 0;
		RepositionTextPanes();
		bShowTextPane = false;
		document.images["A"].style.cursor = "default";
	}
	if (bRedirect)
		window.location = "/cmepw-v3.0a/";
}


function OnClickTextPane0()
	{ iTextPaneShowing = 1; }


function OnClickTextPane1()
	{ iTextPaneShowing = 2; }


function OnClickTextPane2()
{
	iTextPaneShowing = -1;
	bRedirect = true;
	document.images["A"].style.cursor = "pointer";
	document.images["A"].src = Spacer.src;
}


function RepositionTextPanes()
{
	var WholePageTable = document.getElementById("WholePageTable");
	var iPageWidth = WholePageTable.offsetWidth;
	var iPageHeight = WholePageTable.offsetHeight;
	for (var i = 0; i <= iTextPaneShowing; i++) {
		var TextPane = document.getElementById("text-pane" + i);
		TextPane.style.left = (iPageWidth / 2 + TextPaneLeftIncArray[i]) + "px";
		TextPane.style.top = (iPageHeight / 2 + TextPaneTopIncArray[i]) + "px";
	}
	if (iTextPaneShowing >= 0)
		setTimeout("RepositionTextPanes()", 100);
	else
		for (var i = 0; i <= 2; i++) {
			var TextPane = document.getElementById("text-pane" + i);
			TextPane.style.left = "-200px";
			TextPane.style.top = "0px";
		}
}


