//###############################################################################################
//###############################################################################################
//##											       ##
//## << SwitchImage Class V1.1 by Uhu >>						       ##
//##											       ##
//## Thu, August 12th, 1999								       ##
//##											       ##
//##-------------------------------------------------------------------------------------------##
//##											       ##
//## Constructor:									       ##
//##	SwitchImage (imgName, imgNormalSource[, imgHighlightSource])			       ##
//##											       ##
//## Properties: none									       ##
//##											       ##
//## Methods:										       ##
//##	adaptTo (imgName[, imgNormalSource, imgHighlightSource]);			       ##
//##	adaptFrom (otherSwitchImage);							       ##
//##	setNormal (imgNormalSource);							       ##
//##	setHighlight (imgHighlightSource);						       ##
//##	validate (); < returns Boolean VALIDATION_SUCCEEDED >				       ##
//##	getName (); < returns String/Integer imgName >					       ##
//##	getNormal (); < returns String imgNormal.src >					       ##
//##	getHighlight (); < returns String imgHighlight.src >				       ##
//##	normal ();									       ##
//##	highlight ([delay[, actionString]]);						       ##
//##											       ##
//##-------------------------------------------------------------------------------------------##
//##											       ##
//## Uhu's Anime Zone:	http://www.anizone.de						       ##
//##			http://www.geocities.com/Tokyo/Flats/2711			       ##
//##			http://kei.animenetwork.com/anime/uhu				       ##
//##											       ##
//## Lum's World:	http://www.lumsworld.com					       ##
//##											       ##
//## ShampooCat's Cafe:	http://kei.animenetwork.com/ranma/catcafe			       ##
//##											       ##
//###############################################################################################
//###############################################################################################

//===============================================================================================
//== Constructor ================================================================================
//===============================================================================================

function SwitchImage (imgName, imgNormalSource, imgHighlightSource) {
	this.current="SI_NORMAL";
	this.imgNormal=new Image();
	this.imgHighlight=new Image();
	if (SwitchImage.arguments.length==2) {
		this.imgName=imgName;
		this.imgNormal.src=imgNormalSource;
		this.imgHighlight.src=imgNormalSource;
	}
	else if (SwitchImage.arguments.length>2) {
		this.imgName=imgName;
		this.imgNormal.src=imgNormalSource;
		this.imgHighlight.src=imgHighlightSource;
	}
	this.adaptTo=adaptTo;
	this.adaptFrom=adaptFrom;
	this.setNormal=setNormal;
	this.setHighlight=setHighlight;
	this.validate=imgValidation;
	this.getName=getName;
	this.getNormal=getNormal;
	this.getHighlight=getHighlight;
	this.normal=normal;
	this.highlight=highlight;
}

//###############################################################################################

//===============================================================================================
//== Function Implementation ====================================================================
//===============================================================================================

function adaptTo (imgName, imgNormalSource, imgHighlightSource) {
	this.imgName=imgName;
	if (adaptTo.arguments.length==2) {
		this.imgNormal.src=imgNormalSource;
		this.imgHighlight.src=imgNormalSource;
	}
	else if (adaptTo.arguments.length>2) {
		this.imgNormal.src=imgNormalSource;
		this.imgHighlight.src=imgHighlightSource;
	}
}

function adaptFrom (otherSwitchImage) {
	this.imgNormal.src=otherSwitchImage.imgNormal.src;
	this.imgHighlight.src=otherSwitchImage.imgHighlight.src;
}

function setNormal (imgNormalSource) {
	this.imgNormal.src=imgNormalSource;
}

function setHighlight (imgHighlightSource) {
	this.imgHighlight.src=imgHighlightSource;
}

function imgValidation () {
	VALIDATION_SUCCEEDED=true;
	if (this.current=="SI_NORMAL") this.normal();
	else 
		if (this.current=="SI_HIGHLIGHT") this.highlight();
		else VALIDATION_SUCCEEDED=false;
	return(VALIDATION_SUCCEEDED);
}

function getName () {
	return(this.imgName);
}

function getNormal () {
	return(this.imgNormal.src);
}

function getHighlight () {
	return(this.imgHighlight.src);
}

function normal () {
	this.current="SI_NORMAL";
	document.images[this.imgName].src=this.imgNormal.src;
	return(true);
}

function highlight (delay, actionString) {
	myself=this;
	this.current="SI_HIGHLIGHT"
	document.images[this.imgName].src=this.imgHighlight.src;
	if (highlight.arguments.length>0) {
		window.setTimeout("myself.normal()", parseInt(delay));
		if (highlight.arguments.length>1) window.setTimeout("eval("+actionString+")", parseInt(delay)+10);
	}
}

