/**
 * HTMLmouseScript v0.3
 * ------------------------------------------------
 * (c)2002 - Copyright by: http://www.Daantje.nl
 * first written: Tue Dec 10 22:31:44 CET 2002
 * laste update:  Wed Dec 11 14:50:01 CET 2002
 *
 * This script makes from a TABLE with A HREFS
 * a simple mouseOver/mouseDown script.
 * This script is tested in Linux/Mozilla 1.0.0
 * and should work with Netscape and MSIE,
 * versions 5.x or higher...
 *
 * LICENSE:
 * This script is FREE to use! You may copy, edit
 * or use this script in ANY way possible!
 * But please, mention me in your credits...
 *
 * SUPPORT:
 * I don't give support on this script. It's for
 * my own use only...
 * ------------------------------------------------
 */

//background colors
var htmlMouseBGcolorDown = '#000000';
var htmlMouseBGcolorOver = '#ffffff';

//link colors
var htmlMouseLKcolorDown = '#ffffff';
var htmlMouseLKcolorOver = '#000000';


//------------------------------------------
//BEGIN THE SCRIPT
//------------------------------------------

//some vars to remember the 'mouseDown' status
htmlMouseSet = new Array();
htmlMouseSet['obj'] = "";
htmlMouseSet['bgcolor'] = "";
htmlMouseSet['lkcolor'] = "";

//some vars to remember the 'mouseOver' status
htmlMouseHover = new Array();
htmlMouseHover['bgcolor'] = "";
htmlMouseHover['lkcolor'] = "";


//change the color of a link.
//	obj = some html object
//	c   = hex color
function htmlMouseSetLinkColor(obj,c){
	//get the A HREF within the clicked object, and set the color.
	l = obj.getElementsByTagName('a');
	l[0].style.color = c;
}


//get the current set colors of a object and return as an array.
//	obj = some html object
//	return:
//		[0] = background hex color
//		[1] = link hex color
function htmlMouseGetColors(obj){
	//get the A HREF within the clicked object, and get the current color.
	arr = new Array();
	//get object background
	arr[0] = obj.getAttribute('bgcolor');
	//get object link color
	l = obj.getElementsByTagName('a');
	arr[1] = l[0].style.color;
	return arr;
}


//-----------------------------------------------------
//Below the functions to call to set the objects
//-----------------------------------------------------

function htmlMouseDown(obj){
	if(htmlMouseSet['obj']){
		//set the old 'down' back to normal
		htmlMouseSet['obj'].setAttribute('bgcolor',htmlMouseSet['bgcolor'],0);
		htmlMouseSetLinkColor(htmlMouseSet['obj'],htmlMouseSet['lkcolor']);
	}
	//remember these
	htmlMouseSet['obj'] = obj;
	htmlMouseSet['bgcolor'] = htmlMouseHover['bgcolor'];
	htmlMouseSet['lkcolor'] = htmlMouseHover['lkcolor'];
	//set newone down.
	if(htmlMouseBGcolorDown) obj.setAttribute('bgcolor',htmlMouseBGcolorDown,0);
	if(htmlMouseLKcolorDown) htmlMouseSetLinkColor(obj,htmlMouseLKcolorDown);
}

function htmlMouseOver(obj){
	if(htmlMouseSet['obj']!=obj){
		//remember these
		v = htmlMouseGetColors(obj);
		htmlMouseHover['bgcolor'] = v[0];
		htmlMouseHover['lkcolor'] = v[1];
		//do the mouse over, when it's not down...
		if(htmlMouseBGcolorOver) obj.setAttribute('bgcolor',htmlMouseBGcolorOver,0);
		if(htmlMouseLKcolorOver) htmlMouseSetLinkColor(obj,htmlMouseLKcolorOver);
	}
}

function htmlMouseOut(obj){
	if(htmlMouseSet['obj']!=obj){
		//UNDO the mouse over, when it's not down...
		obj.setAttribute('bgcolor',htmlMouseHover['bgcolor'],0);
		htmlMouseSetLinkColor(obj,htmlMouseHover['lkcolor']);
	}
}
