// Button class //

var isNav, isIE
var range = "";
if (navigator.appName == "Netscape") isNav = true;
if (navigator.appName.indexOf("Microsoft") != -1) isIE = true;


// create and discard a dummy Button object
new Button(0,0);
new ButtonGroup();


function ButtonGroup(selected) {
	this.selected = selected || "";
	this.button = new Array();
}

ButtonGroup.prototype.mouseover=ButtonGroup_mouseover;
ButtonGroup.prototype.mouseout=ButtonGroup_mouseout;
ButtonGroup.prototype.click=ButtonGroup_click;

function ButtonGroup_mouseover(name) {
	window.status = this.button[name].msg;
	this.button[name].ref.src = this.button[name].hi.src;
}


function ButtonGroup_mouseout(name) {
	window.status = " ";
	if (name != this.selected) this.button[name].ref.src = this.button[name].up.src;//cont.images[obj.name].src = obj.up.src;
}



function ButtonGroup_click(name) {
	// if clicked button other than the selected one
	if (this.selected.length && name != this.selected) { 
		// deselect selected button 
		this.button[this.selected].ref.src = this.button[this.selected].up.src;
	}
	this.selected = name;
}


// define constructor function of the class
// initialise instance properties of the object
function Button(buttonName,filename,statusMessage,page,containingDiv) {
  	this.name = buttonName;
	this.up = new Image();
	this.up.src = buttonsPath + filename + ".jpg";
	this.hi = new Image();
	this.hi.src = buttonsPath + filename + "_hi.jpg";
	this.msg = statusMessage;
	this.containingDiv = containingDiv;
	this.page = page;
    
    type = typeof containingDiv; 
	if (type != "string") this.container = document;
	else if (type == "string") {
		if (isNav) {
			this.container = document.layers[containingDiv].document;
		}
		else if (isIE) this.container = document;
	}
	
	this.ref = this.container.images[buttonName];

}
