//<script>
/*
	Image functions
	Created 7/5/1999 by Jeremy Clough <jhbc@bigfoot.com>
*/

var hasImages = !(!document.images);
var _definedButtons;
if (hasImages) _definedButtons = new Array();

// "public" functions
function buttonOn(which) {
	if (hasImages && !(!_definedButtons[which])) _definedButtons[which].on();
}

function buttonOff(which) {
	if (hasImages && !(!_definedButtons[which])) _definedButtons[which].off();
}


// "private" functions
function _buttonOn() {
	if (hasImages) {
		if (!(!this.onImage)) this.set(this.onImage.src);
		for (button in this.others) {
			this.others[button]["image"].src = this.others[button]["on"].src;
		}
	}
	if (this.onStatus != null) self.status = this.onStatus;

	return (true);
}

function _buttonOff() {
	if (hasImages) {
		if (!(!this.offImage)) this.set(this.offImage.src);
		for (button in this.others) {
			this.others[button]["image"].src = this.others[button]["off"].src;
		}
	}
	
	if (this.offStatus != null) self.status = this.offStatus;
	else self.status = self.defaultStatus;

	return (true);
}

function _buttonActive() {
	if (hasImages) this.set(this.activeImage.src);

	return (true);
}

function _buttonAdd(imageObj, offSrc, onSrc) {
	if (hasImages) {
		var rollover = new Array();
		rollover["image"] = imageObj;

		var offImage = new Image();
		offImage.src = offSrc;
		rollover["off"] = offImage;

		var onImage = new Image();
		onImage.src = onSrc;
		rollover["on"] = onImage;

		this.others[this.others.length] = rollover;
	}

	return (true);
}

function _buttonGetImage() {
	if (typeof(this.image) == "string") return eval(this.image);
	else return this.image;
}

function _buttonSetImage(src) {
	var image = this.get();
	image.src = src;
}


// Button "object"
function Button(imageObj, offSrc, onSrc, activeSrc, offStatus, onStatus) {
	this.image = null;
	this.others = null;

	this.offImage = null;
	this.offStatus = null;

	this.onImage = null;
	this.onStatus = null;

	if (hasImages) {
		if (typeof(imageObj) == "string") this.image = "document." + imageObj;
		else this.image = imageObj;
		
		this.others = new Array();
		this.offImage = null;
		this.onImage = null;
		this.activeImage = null;

		if (offSrc != null) {
			this.offImage = new Image();
			this.offImage.src = offSrc;
			this.offStatus = offStatus;
		}

		if (onSrc != null) {
			this.onImage = new Image();
			this.onImage.src = onSrc;
			this.onStatus = onStatus;
		}

		if (activeSrc != null) {
			this.activeImage = new Image();
			this.activeImage.src = activeSrc;
		}

		if (typeof(imageObj) == "string") _definedButtons[imageObj] = this;
		else _definedButtons[this.image.name] = this;
	}

	Button.prototype.on			= _buttonOn;
	Button.prototype.off		= _buttonOff;
	Button.prototype.active		= _buttonActive;
	Button.prototype.add		= _buttonAdd;
	Button.prototype.get		= _buttonGetImage;
	Button.prototype.set		= _buttonSetImage;

	if (this.image != null) this.off();
}

