<!--
// * * * * * * * * *
// LAYOUT

function writeButtons(i)
{
	if (IE4)
	{
		document.write('<div align="center" style="position:absolute;" id="play'+ i +'"><input type="button" onClick="play('+ i + ')" value="-X-"></div>');
	}
	else if (NS4)
	{
		document.write('<layer id="play' + i + '"><form><input type="button" value="-X-" onClick="play(' + i + ')"></form></layer>');
	}
	else if (GECKO)
	{
		var buttonDiv = document.createElement('div');
		buttonDiv.setAttribute('align', 'center');
		buttonDiv.setAttribute('style', 'position:absolute');
		buttonDiv.setAttribute('id', 'play' + i);
		var buttonEl = document.createElement('input');
		buttonEl.setAttribute('type', 'button');
		buttonEl.setAttribute('value', '-X-');
		buttonEl.setAttribute('onclick', 'play(' + i + ')');
		buttonDiv.appendChild(buttonEl);
		document.body.appendChild(buttonDiv);
	}
}

function writePegs(section)
{
	if (IE4)
	{
		document.write('<div style="position:absolute;" id='+ section + '><img src="../images/pixel.gif" width="1" height="1"></div>');
	}
	else if (NS4)
	{
		document.write('<layer id='+ section + '><img src="../images/pixel.gif" width="1" height="1"></layer>');
	}
	else if (GECKO)
	{
		var pegDiv = document.createElement('div');
		pegDiv.setAttribute('style', 'position:absolute');
		pegDiv.setAttribute('id', section);
		var imgEl = document.createElement('img');
		imgEl.setAttribute('src', '../images/pixel.gif');
		imgEl.setAttribute('width', '1');
		imgEl.setAttribute('height', '1');
		pegDiv.appendChild(imgEl);
		document.body.appendChild(pegDiv);
	}
}

function writeLastRow(winningAmtImg, width, height, lastrow)
{
	var winningAmt = "<img src='" + winningAmtImg + "' width=" + width + " height=" + height + " border=0>";

	if (IE4)
	{
		document.write('<div align="center" style="position:absolute;" id=' + lastrow +  '>' + winningAmt + '</div>');
	}
	else if (NS4)
	{
		document.write('<layer id=' + lastrow +  '>' + winningAmt + '</layer>');
	}
	else if (GECKO)
	{
		var lastrowDiv = document.createElement('div');
		lastrowDiv.setAttribute('style', 'position:absolute');
		lastrowDiv.setAttribute('id', lastrow);
		var lastrowImage = document.createElement('img');
		lastrowImage.setAttribute('src', winningAmtImg);
		lastrowImage.setAttribute('width', width);
		lastrowImage.setAttribute('height', height);
		lastrowImage.setAttribute('border', '0');
		lastrowDiv.appendChild(lastrowImage);
		document.body.appendChild(lastrowDiv);
	}
}

function writeChip()
{
	if (IE4)
	{
		document.write('<div style="position:absolute;" id="chip"><img src="../images/chip.gif" width="20" height="20"></div>');
	}
	else if (NS4)
	{
		document.write('<layer id="chip"><img src="../images/chip.gif" width="20" height="20"></layer>');
	}
	else if (GECKO)
	{
		var chipDiv = document.createElement('div');
		chipDiv.setAttribute('style', 'position:absolute');
		chipDiv.setAttribute('id', 'chip');
		var chipImage = document.createElement('img');
		chipImage.setAttribute('src', '../images/chip.gif');
		chipImage.setAttribute('width', '20');
		chipImage.setAttribute('height', '20');
		chipDiv.appendChild(chipImage);
		document.body.appendChild(chipDiv);
	}
}

function setChipProperties()
{
	var w = CHIP_WH;
	var h = CHIP_WH;
	var l = BOARD_LEFT + ((SECTION_W / 2) - (CHIP_WH / 2));
	var t = BOARD_TOP - CHIP_WH;

	if (IE4)
	{
		with (chip.style)
		{
			backgroundColor = 'transparent';
			width = w;
			height = h;
			pixelLeft = l;
			pixelTop = t;
		}
	}
	else if (NS4)
	{
		with (document["chip"])
		{
			resizeTo(w, h);
			left = l;
			top = t;
	  	}
	}
	else if (GECKO)
	{
		var el = document.getElementById('chip');
		
		el.style.width = w;
		el.style.height = h;
		el.style.left = l;
		el.style.top = t;
	}
}

function writeBorders()
{
	if (IE4)
	{
		document.write('<div style="position:absolute;" id="borderLeft"><img src="../images/plinkoBorderL.gif" width="' + BORDER_W + '" height="' + BORDER_H + '" border="0"></div>');
		document.write('<div style="position:absolute;" id="borderRight"><img src="../images/plinkoBorderR.gif" width="' + BORDER_W + '" height="' + BORDER_H + '" border="0"></div>');
	}
	else if (NS4)
	{
		document.write('<layer id="borderLeft"><img src="../images/plinkoBorderL.gif" width="' + BORDER_W + '" height="' + BORDER_H + '" border="0"></layer>');
		document.write('<layer id="borderRight"><img src="../images/plinkoBorderR.gif" width="' + BORDER_W + '" height="' + BORDER_H + '" border="0"></layer>');
	}
	else if (GECKO)
	{
		var bLeftDiv = document.createElement('div');
		bLeftDiv.setAttribute('style', 'position:absolute');
		bLeftDiv.setAttribute('id', 'borderLeft');
		var bLeftImg = document.createElement('img');
		bLeftImg.setAttribute('src', '../images/plinkoBorderL.gif');
		bLeftImg.setAttribute('width', BORDER_W);
		bLeftImg.setAttribute('height', BORDER_H);
		bLeftDiv.appendChild(bLeftImg);
		document.body.appendChild(bLeftDiv);
		
		var bRightDiv = document.createElement('div');
		bRightDiv.setAttribute('style', 'position:absolute');
		bRightDiv.setAttribute('id', 'borderRight');
		var bRightImg = document.createElement('img');
		bRightImg.setAttribute('src', '../images/plinkoBorderR.gif');
		bRightImg.setAttribute('width', BORDER_W);
		bRightImg.setAttribute('height', BORDER_H);
		bRightDiv.appendChild(bRightImg);
		document.body.appendChild(bRightDiv);
	}
}

function setBordersProperties()
{
	var clr = '#cc0000';
	var wL = BORDER_W;
	var hL = SECTION_H * (NUM_ROWS + 1);
	var lL = BOARD_LEFT - BORDER_W;
	var tL = BOARD_TOP;
	var wR = BORDER_W;
	var hR = SECTION_H * (NUM_ROWS + 1);
	var lR = BOARD_LEFT + (NUM_COLS * SECTION_W);
	var tR = BOARD_TOP;

	if (IE4)
	{
		with (borderLeft.style)
		{
			backgroundColor = clr;
			width = wL;
			height = hL;
			pixelLeft = lL;
			pixelTop = tL;
		}
		with (borderRight.style)
		{
			backgroundColor = '#cc0000';
			width = wR;
			height = hR;
			pixelLeft = lR;
			pixelTop = tR;
		}
	}//end IE4
	else if (NS4)
	{
		with (document["borderLeft"])
		{
			bgColor = clr;
			resizeTo(wL,hL);
			left = lL;
			top = tL;
		}

		with (document["borderRight"])
		{
			bgColor = clr;
			resizeTo(wR,hR);
			left = lR;
			top = tR;
		}
	}//end NS4
	else if (GECKO)
	{
		var elL = document.getElementById('borderLeft');
		var elR = document.getElementById('borderRight');
		
		elL.style.width = wL;
		elL.style.height = hL;
		elL.style.left = lL;
		elL.style.top = tL;
		elR.style.width = wR;
		elR.style.height = hR;
		elR.style.left = lR;
		elR.style.top = tR;
	}
}

function writeResultLabels()
{
	if (IE4)
	{
		document.write('<div style="position:absolute;" id="chipsleft">&nbsp;</div>');
		document.write('<div align="right" style="position:absolute;" id="gwinnings">&nbsp;</div>');
	}
	else if (NS4)
	{
		document.write('<layer id="chipsleft">&nbsp;</layer>');
		document.write('<layer id="gwinnings">&nbsp;</layer>');
	}
	else if (GECKO)
	{
		var chipsLeftDiv = document.createElement('div');
		chipsLeftDiv.setAttribute('style', 'position:absolute');
		chipsLeftDiv.setAttribute('id', 'chipsleft');
		var chipsLeftText = document.createTextNode(' ');
		chipsLeftDiv.appendChild(chipsLeftText);
		document.body.appendChild(chipsLeftDiv);
		
		var gwinningsDiv = document.createElement('div');
		gwinningsDiv.setAttribute('style', 'position:absolute');
		gwinningsDiv.setAttribute('id', 'gwinnings');
		var gwinningsText = document.createTextNode(' ');
		gwinningsDiv.appendChild(gwinningsText);
		document.body.appendChild(gwinningsDiv);
	}
}

function setResultLabelsProperties()
{
	var clr = '#ffffff';
	var wL = BORDER_BOTTOM_W / 2;
	var lL = BORDER_BOTTOM_L;
	var tL = BORDER_BOTTOM_T + BORDER_BOTTOM_H;
	var wG = BORDER_BOTTOM_W / 2;
	var lG = BORDER_BOTTOM_L + (BORDER_BOTTOM_W / 2);
	var tG = BORDER_BOTTOM_T + BORDER_BOTTOM_H;

	if (IE4)
	{
		with (chipsleft.style)
		{
			width = wL
			backgroundColor = clr;
			pixelLeft = lL;
			pixelTop = tL;
		}
		with (gwinnings.style)
		{
			width = wG
			backgroundColor = clr;
			pixelLeft = lG;
			pixelTop = tG;
		}
	}//end IE4
	else if (NS4)
	{
		with (document["chipsleft"])
		{
			clip.width = wL;
			bgColor = clr;
			left = lL;
			top = tL;
		}
		with (document["gwinnings"])
		{
			clip.width = wG;
			bg = clr;
			left = lG;
			top = tG;
		}
	}//end NS4
	else if (GECKO)
	{
		var elL = document.getElementById('chipsleft');
		var elG = document.getElementById('gwinnings');
		
		elL.style.width = wL;
		elL.style.backgroundColor = clr;
		elL.style.left = lL;
		elL.style.top = tL;
		elG.style.width = wG;
		elG.style.backgroundColor = clr;
		elG.style.left = lG;
		elG.style.top = tG;
	}
}

function writeMessageLabel()
{
	if (IE4)
	{
		document.write('<div align="center" style="position:absolute;" id="messageLabel">...STILL LOADING...</div>');
	}
	else if (NS4)
	{
		document.write('<layer id="messageLabel">...STILL LOADING...</layer>');
	}
	else if (GECKO)
	{
		var msgLabelDiv = document.createElement('div');
		msgLabelDiv.setAttribute('style', 'position:absolute');
		msgLabelDiv.setAttribute('id', 'messageLabel');
		var msgLabelText = document.createTextNode('...STILL LOADING...');
		msgLabelDiv.appendChild(msgLabelText);
		document.body.appendChild(msgLabelDiv);
	}
}

function setMessageLabelProperties()
{
	var z = 2;
	var clr = '#ffffff';
	var w = BORDER_BOTTOM_W / 2;
	var h = BORDER_H - SECTION_H;
	var l = BORDER_BOTTOM_L + (BORDER_BOTTOM_W / 4);
	var t = BOARD_TOP;
	
	if (IE4)
	{
		with (messageLabel.style)
		{
			zIndex = z;
			backgroundColor = clr;
			width = w;
			height = h;
			pixelLeft = l; 
			pixelTop = t;
		}
	}//end IE4
	else if (NS4)
	{
		with (document["messageLabel"])
		{
			zIndex = z;
			bgColor = clr;
			clip.width = w;
			clip.height = h;
			left = l;
			top = t;
		}
	}//end NS4
	else if (GECKO)
	{
		var el = document.getElementById('messageLabel');
		
		el.style.zIndex = z;
		el.style.backgroundColor = clr;
		el.style.width = w;
		el.style.height = h;
		el.style.left = l;
		el.style.top = t;
	}
}

function setSectionCProperties(section, baseLeft, baseTop, clr, isPeg)
{
	var w = (isPeg) ? PEG_SIZE : SECTION_W;
	var h = (isPeg) ? PEG_SIZE : SECTION_H;
	var l = (isPeg) ? baseLeft + (SECTION_W / 2) : baseLeft;
	var t = (isPeg) ? baseTop + (SECTION_H / 2) : baseTop;

	if (IE4)
	{
		with (eval(section).style)
		{
			backgroundColor = clr;
			width =  w;
			height = h;
			pixelLeft = l;
			pixelTop = t;
		}
	}// end IE4
	else if (NS4)
	{
		section = eval('document["' + section + '"]');
		with (section)
		{
			bgColor = clr;
			resizeTo(w, h);
			left = l;
			top = t;
		}
	}// end NS4
	else if (GECKO)
	{
		var el = document.getElementById(section);
		
		el.style.width = w;
		el.style.height = h;
		el.style.left = l;
		el.style.top = t;
		el.style.backgroundColor = clr;
	}
}

// * * * * * * * * * * * * 
// ACTION

function getChipLeft()
{
	var chipL = 0;
	if (IE4) { chipL = chip.style.pixelLeft; }
	else if (NS4) { chipL = document["chip"].left ; }
	else if (GECKO)
	{
		var el = document.getElementById('chip');
		// left has the number and 'px' in it
		chipL = parseFloat(el.style.left);
	}

	return chipL;
}

function getChipTop()
{
	var chipT = 0;
	if (IE4) { chipT = chip.style.pixelTop; }
	else if (NS4) { chipT = document["chip"].top ; }
	else if (GECKO)
	{
		var el = document.getElementById('chip');
		// top has the number and 'px' in it
		chipT = parseFloat(el.style.top);
	}

	return chipT;
}

function setChipLeft(chipLeft)
{
	if (IE4) { chip.style.pixelLeft = chipLeft; }
	else if (NS4) { document["chip"].left = chipLeft; }
	else if (GECKO)
	{
		var el = document.getElementById('chip');
		el.style.left = chipLeft;
	}
}

function setChipTop(chipTop)
{
	if (IE4) { chip.style.pixelTop = chipTop; }
	else if (NS4) { document["chip"].top = chipTop; }
	else if (GECKO)
	{
		var el = document.getElementById('chip');
		el.style.top = chipTop;
	}
}

function moveChipLeft(incrChipLeft)
{
	if (IE4) { chip.style.pixelLeft += incrChipLeft; }
	else if (NS4) { document["chip"].left += incrChipLeft; }
	else if (GECKO)
	{
		var el = document.getElementById('chip');
		// left has the number and 'px' in it
		el.style.left = parseFloat(el.style.left) + incrChipLeft;
	}
}

function moveChipTop(incrChipTop)
{
	if (IE4)
	{
		chip.style.pixelTop += incrChipTop;
	}
	else if (NS4) { document["chip"].top += incrChipTop; }
	else if (GECKO)
	{
		var el = document.getElementById('chip');
		
		// top has the number and 'px' in it
		el.style.top = parseFloat(el.style.top) + incrChipTop;
	}
}

function setWinningsText()
{
	var newString = '<font size="+3">' + gameTotalWinnings + '</font>'

	if (IE4)
	{
		gwinnings.innerHTML = newString;
	}
	else if (NS4)
	{
		document["gwinnings"].document.write(newString);
		document["gwinnings"].document.close();
	}
	else if (GECKO)
	{
		var el = document.getElementById('gwinnings');
		el.innerHTML = newString;
	}
}

function setChipsRemainingText(chipsPic)
{
	var newString = '<font size="+3">' + chipsPic + '</font>';
	if (IE4)
	{
		chipsleft.innerHTML = newString;
	}
	else if (NS4)
	{
		document["chipsleft"].document.write(newString);
		document["chipsleft"].document.close();
	}
	else if (GECKO)
	{
		var el = document.getElementById('chipsleft');
		el.innerHTML = newString;
	}
}

function showMessageLabel(isShow, msg)
{
	if (IE4)
	{
		messageLabel.innerHTML = msg;
		messageLabel.style.visibility = (isShow) ? 'visible' : 'hidden';
	}
	else if (NS4)
	{
		document["messageLabel"].document.write(msg);
		document["messageLabel"].document.close();
		document["messageLabel"].visibility = (isShow) ? 'show' : 'hide';
	}
	else if (GECKO)
	{
		var el = document.getElementById('messageLabel');
		el.innerHTML = msg;
		el.style.visibility = (isShow) ? 'visible' : 'hidden';
	}
}

//-->
