// <!--- Last revised December 15, 1999, PRH --->// This version uses the ButtonTracker Object to handle all calls// It is not compatible with earlier versions.// Radio and Checkbox rollovers and clicks are handled correctly by default// Default Radio behavior can be overridden by setting the bRespondToClick property// This si sueful for radio groups used as navigation buttons, when you want a // highlighted navigation button to still be active--e.g. for reloading a page// within a frame.// *******************************************************************************//                                BEGIN PROTOTYPES // *******************************************************************************//--------------------------------------------------------------------------------////	ButtonGroup Prototype Function//		Action: Prototype for ButtonGroup Object, call with "new" function//		  Stores references to ButtonTracker objects and keeps buttons grouped.//		  Note that references to the ButtonTracker objects are stored in //		  and array, bGroupBtnList.//		On entry: pass in a name for the object//		On exit: returns an instance of the object////--------------------------------------------------------------------------------	function ButtonGroup(myName, myType)	{		this.bGroupName = myName;		this.bGroupType = 1;				// default to control/navigation button		this.bRespondToClickbRespondToClick = 0;			// if a button is already highlighted,											// don't respond to clicks (default)		if (myType == "radio")	{			this.bGroupType = 2;		}		if (myType == "checkbox")	{			this.bGroupType = 3;		}		this.bGroupCurrentBtn = "";			// currently highlighted radio button		this.bGroupAction = null;			// action to perform in response to a click		this.bGroupBtnList = new Array();	// list of ButtonTracker objects	}		// create and discard an instance	// this forces a prototype to be created in Navigator 3	new ButtonGroup("dummy");		// accessor functions for bGroupName variable	function GetBGName()	{ return this.bGroupName; }	ButtonGroup.prototype.GetName = GetBGName;	function SetBGName(newName)	{ this.bGroupName = newName; }	ButtonGroup.prototype.SetName = SetBGName;		// accessor functions for bGroupType variable	function GetType()	{ return this.bGroupType; }	ButtonGroup.prototype.GetType = GetType;	function SetType(newType)	{ this.bGroupType = newType; }	ButtonGroup.prototype.SetType = SetType;			// accessor functions for bGroupCurrentBtn variable	function GetCurrentBtn()	{ return this.bGroupCurrentBtn; }	ButtonGroup.prototype.GetCurrentBtn = GetCurrentBtn;	function SetCurrentBtn(btnref)	{ this.bGroupCurrentBtn = btnref; }	ButtonGroup.prototype.SetCurrentBtn = SetCurrentBtn;		// accessor functions for bGroupAction variable	function GetBGAction()		{ if (this.bGroupAction) { 		return this.bGroupAction; 	} else { 		return 0; } 	}	ButtonGroup.prototype.GetAction = GetBGAction;	function SetBGAction(newAction)	{ this.bGroupAction = newAction; }	ButtonGroup.prototype.SetAction = SetBGAction;		function DoBGAction(userParam, bName, bObject, bGroup)	{ 		if (this.bGroupAction)	{			this.bGroupAction(userParam, bName, bObject, bGroup);		}	}	ButtonGroup.prototype.DoAction = DoBGAction;		// accessor functions for bRespondToClick variable	function GetClickRespond()	{ return this.bRespondToClick; }	ButtonGroup.prototype.GetClickRespond = GetClickRespond;	function SetClickRespond(newClickRespond)	{ this.bRespondToClick = newClickRespond; }	ButtonGroup.prototype.SetClickRespond = SetClickRespond;		// accessor functions for bGroupBtnList variable	function GetBtnList()	{ return this.bGroupBtnList; }	ButtonGroup.prototype.GetBtnList = GetBtnList;	function SetBtnList(newList)	{ this.bGroupBtnList = newList; }	ButtonGroup.prototype.SetBtnList = SetBtnList;		// function for adding a buttonTracker variable	// we set the default action for the button to the group action	// and add the new ButtonTracker object to the bGroupBtnList array	function AddButton(imgName, losrc, hisrc, rollsrc)		{ 		this[imgName] = new ButtonTracker(imgName, losrc, hisrc, rollsrc);		len = this.bGroupBtnList.length;		this.bGroupBtnList[len] = this[imgName];		this[imgName].SetGroup(this);	// tell the button which group it belongs to	}	ButtonGroup.prototype.AddButton = AddButton;	//--------------------------------------------------------------------------------////	ButtonTracker Prototype Function//		Action: Prototype for ButtonTracker Object, call with "new" function//		  Stores URLs for image files that correspond to low, high, and //		  rollover states of the button.//		On entry: pass in a name for the object//		On exit: returns an instance of the object////--------------------------------------------------------------------------------	function ButtonTracker(myName, losrc, hisrc, rollsrc)	{		this.btName = myName;			// name of the image		if (losrc != "") { 			this.lo = new Image(); 			this.lo.src = losrc;		// plain, unhighlighted form		}		if (hisrc != "") { 			this.hi = new Image(); 			this.hi.src = hisrc;		// highlighted form		}		if (rollsrc != "") { 			this.roll = new Image(); 			this.roll.src = rollsrc;	// rollover form		}		this.btStatus = 0;				// unhighlighted		this.btGroup = null;			// no group specified on initialization		this.btAction = null;			// default is to do group action	}		// create and discard an instance	// this forces a prototype to be created in Navigator 3	new ButtonTracker("dummy");		// accessor functions for btName variable	function GetName()	{ return this.btName; }	ButtonTracker.prototype.GetName = GetName;	function SetName(newName)	{ this.btName = newName; }	ButtonTracker.prototype.SetName = SetName;		// accessor functions for btGroup variable	// intended for internal not public use	function GetGroup()	{ return this.btGroup; }	ButtonTracker.prototype.GetGroup = GetGroup;	function SetGroup(newGroup)	{ this.btGroup = newGroup; }	ButtonTracker.prototype.SetGroup = SetGroup;		// accessor functions for btStatus variable	function GetStatus()	{ return this.btStatus; }	ButtonTracker.prototype.GetStatus = GetStatus;	function SetStatus(newStatus)	{ this.btStatus = newStatus; }	ButtonTracker.prototype.SetStatus = SetStatus;		// accessor functions for btAction variable	function GetAction()		{ if (this.btAction) { 		return this.btAction; 	} else { 		return 0; } 	}	ButtonTracker.prototype.GetAction = GetAction;	function SetAction(newAction)	{ this.btAction = newAction; }	ButtonTracker.prototype.SetAction = SetAction;	function DoAction(userParam, bName, bObject, bGroup) {	 	if (this.btAction) { 			this.btAction(userParam, bName, bObject, bGroup); 		} else {			bGroup.DoAction(userParam, bName, bObject, bGroup);		}	}	ButtonTracker.prototype.DoAction = DoAction;		// *******************************************************************************//                        BEGIN STANDARD BUTTON FUNCTIONS ////		These are the standard functions for mouse events and button clicks.//		You call them from HREF attributes for the button image.//// *******************************************************************************	//--------------------------------------------------------------------------------////	ButtonLo//		Action: replace an image with its plain, unhighlighted version//		On entry: pass in a reference to the button tracker object for the //		  clicked image and the name of the clicked image//		On exit: image replaced////--------------------------------------------------------------------------------	function ButtonLo(bName)	{		if (!bName)	{			var bName = this.GetName();		// retrieve the name of the button		}		document[bName].src = this.lo.src;	// set button graphic to unhighlight		this.SetStatus(0);					// set highlight status	}	ButtonTracker.prototype.ButtonLo = ButtonLo;//--------------------------------------------------------------------------------////	ButtonHi//		Action: replace an image with its highlighted version//		On entry: pass in a reference to the button tracker object for the //		  clicked image and the name of the clicked image//		On exit: image replaced////--------------------------------------------------------------------------------	function ButtonHi(bName)	{		if (!bName)	{			var bName = this.GetName();		// retrieve the name of the button		}		document[bName].src = this.hi.src;	// set button graphic to highlight 		this.SetStatus(1);					// set highlight status	}	ButtonTracker.prototype.ButtonHi = ButtonHi;//--------------------------------------------------------------------------------////	ButtonRoll//		Action: replace an image with its rollover version//		On entry: pass in a reference to the button tracker object for the //		  clicked image and the name of the clicked image//		On exit: image replaced////--------------------------------------------------------------------------------	function ButtonRoll(bName)	{		if (!bName)	{			var bName = this.GetName();						// retrieve the name of the button		}		bType = this.btGroup.GetType();						// get its associated ButtonGroup object		if (bType == 1) {									// control button			document[bName].src = this.roll.src;			//   set button graphic to rollover		} else if (bType == 2) {							// radio button			if (this.GetStatus()) {							//   if the button is highlighted				if (this.btGroup.GetClickRespond()) {		//   and it's set to respond then					document[bName].src = this.roll.src;	//   set the button graphic to rollover				}											//   otherwise no change			} else {										//   if the button is low				document[bName].src = this.roll.src;		//   set button graphic to rollover			}											} else if (bType == 3) {							// check button			if (this.GetStatus())	{						//   if it's already highlighted				;											//   no change			} else {										//   otherwise				document[bName].src = this.roll.src;		//   set button graphic to rollover			}		}			}	ButtonTracker.prototype.ButtonRoll = ButtonRoll;	//--------------------------------------------------------------------------------////	ButtonRollOff//		Action: when mouse rolls off on a radio or check button//			with a roll state, restore the current highlighted state//			otherwise, set the button to its low state//		On entry: pass in button name//		On exit: button state adjusted////--------------------------------------------------------------------------------	function ButtonRollOff(bName)	{		if (!bName)	{			var bName = this.GetName();						// retrieve the name of the button		}		bType = this.btGroup.GetType();						// get its associated ButtonGroup object		if (bType == 1) {									// control button			this.ButtonLo(bName);							//   set button graphic to low		} else if (bType == 2) {							// radio button			if (this.GetStatus()) {							//   if the button is highlighted				if (this.btGroup.GetClickRespond()) {		//   and it's set to respond then					this.ButtonHi(bName);					//   set the button graphic back to high				}											//   otherwise no change			} else {										//   if the button is low				this.ButtonLo(bName);						//   set button graphic to low			}											} else if (bType == 3) {							// check button			if (this.GetStatus())	{						//   if it's already highlighted				;											//   no change			} else {										//   otherwise				this.ButtonLo(bName);						//   set button graphic to low			}		}			}	ButtonTracker.prototype.ButtonRollOff = ButtonRollOff;//--------------------------------------------------------------------------------////	ButtonClick//		Action: respond to a click on a button//		  handles highlighting and then dispatches a call to the //		  action associated with the button//		On entry: bGroup is the ButtonGroup object for the button, //		  bName contains the name of the button //		On exit: button is set to proper highlighted state and its associated //		  action function is called. //		The optional userParam will be passed to the button's action function //		along with the button name, a reference to the its Button Tracker//		object, and a reference to its ButtonGroup object.////--------------------------------------------------------------------------------	function ButtonClick(userParam)	{		if (!userParam)	{ userParam = ""; }		var bName = this.btName;				// retrieve the name of the button		var bGroup = this.btGroup;				// get a reference to the buttonGroup		var bType = bGroup.bGroupType;			// radio, checkbox or control		if ( bType == 3 )	{					// checkboxes			myState = this.GetStatus();			if (myState)	{				this.ButtonLo(bName);			} else {				this.ButtonHi(bName)			}			this.DoAction(userParam, bName, this, bGroup);	// do button action, user must assess status		} else if ( bType == 2 )	{						// radio buttons			var currentBtn = bGroup.GetCurrentBtn();			if ( currentBtn == bName)	{ 					// if the button is highlighted				if (bGroup.GetClickRespond()) {				// and it's set to respond to clicks					this.DoAction(userParam, bName, this, bGroup);	// do the button action				} 											// but don't change highlighting			} else {				if ( currentBtn == "")	{ 					// if no button in the group is highlighted					this.ButtonHi(bName);					// highlight clicked button and tell 					bGroup.SetCurrentBtn(bName);			// the ButtonGroup it's now the high button				} else {									// if a button is already highlighted					bGroup[currentBtn].ButtonLo(currentBtn)	// unhighlight the old button					this.ButtonHi(bName);					// and highlight the clicked button					bGroup.SetCurrentBtn(bName);				}				// respond to the click by executing a command				this.DoAction(userParam, bName, this, bGroup);	// do button action			}		} else {											// control button			this.DoAction(userParam, bName, this, bGroup);	// do button action		}			}	ButtonTracker.prototype.ButtonClick = ButtonClick;// *******************************************************************************//                                END PROTOTYPES // *******************************************************************************//--------------------------------------------------------------------------------////	BtnReport		//		Action: called using an onload attribute in an image, this function//		  can gather information on the image. It sets the onload attribute//		  to null, so that it is only called once.//		  This is an EXPERIMENT to see if buttons can register themselves...//		On entry: passes in a reference to the loaded object//		On exit: sets the onload attribute of the object to null////--------------------------------------------------------------------------------	function BtnReport(imgobj)	{		var str = "";		if (imgobj.name)	{			str = str + imgobj.name;		}		imgobj.onload = null;	}// *******************************************************************************//                         END STANDARD BUTTON FUNCTIONS // *******************************************************************************