<!--

	// Copyright 2000 A Walk Beyond, LLC.  All rights reserved.


	var sImageDir = "../../images/games/images/";
	var sAnimDir  = "../../images/games/animations/";

	var nMaxLevel = 4;
	var nTimeoutCount = 0;

	var domInstruct = null;
	var domReward = null;
	var domPreload = null;
	var domControls = null;


	// Support Functions
	
	function RandomInRange ( nLow, nHigh )
	{
		return Math.round(Math.abs(nHigh - nLow) * Math.random() + Math.min(nLow,nHigh));
	}

	function NormalizeInRange ( vA, vB, vC )
	{
		if (vA < vB) return vB;
		if (vA > vC) return vC;
		return vA;
	}
	
	function FlashReward ( nMilliseconds )
	{
		if (domReward == null) domReward = new DocObject("reward");
		domReward.SetVisible(true); window.setTimeout ("domReward.SetVisible(false);", nMilliseconds);
	}

	function PreloadOn()
	{
		if (domPreload == null) domPreload = new DocObject("preload");
		domPreload.SetVisible(true); domPreload.SetOrder(9);
	}

	function PreloadOff()
	{
		if (domPreload == null) domPreload = new DocObject("preload");
		domPreload.SetVisible(false); domPreload.SetOrder(0);
	}

	function StatusOn ( oObject, sLabel )
	{
		if (oObject) oObject.title = sLabel;
		window.status = sLabel;
		return true;
	}

	function StatusOff ( oObject )
	{
		if (oObject) oObject.title = "";
		window.status = "";
		return true;
	}
	

	// Class GraphicButton
	//
	//	This class encapsulates two-state graphic button behavior.  The
	//	class depends on button graphic names being prefaced with 'button_'
	//	and suffixed with '_on.gif' or '_off.gif' according to state.

	function GraphicButton ( sName )
	{
		this.name = sName;
		this.source = new Array();
		this.domName = null;
		this.state = false;
		
		this.source["off"] = sImageDir + "button_" + sName + "_off.gif";
		this.source["on"]  = sImageDir + "button_" + sName + "_on.gif";

		this.Bind = GraphicButton_Bind;
		this.On = GraphicButton_On;
		this.Off = GraphicButton_Off;
		this.Toggle = GraphicButton_Toggle;

		function GraphicButton_Bind()
		{
			this.domName = FindObject(document, this.name);
			this.Off();
		}
		
		function GraphicButton_On() { if (this.domName) this.domName.src = this.source["on"]; this.state = true; }
		function GraphicButton_Off() { if (this.domName) this.domName.src = this.source["off"]; this.state = false; }
		function GraphicButton_Toggle() { if (this.domName) this.state ? this.Off() : this.On(); }
	}

// -->

