// If you use this script, you must leave my copyright and authorship info intact.

// _______________________________________________________________

// Title : Pane implementation 1
// Author : Mark Everett
// Website : www.markeverett.com
// Copyright © Mark Everett 2004 all rights reserved
// _______________________________________________________________

function fadeup (theElement, fromRed, fromGreen, fromBlue, toRed, toGreen, toBlue, upSteps, upInterval, downSteps, downInterval) {
	theID = theElement.getAttribute("ID");
	idNumber = parseInt(theID.match(/\d+/),10);
	if (panes[idNumber] == undefined) {
		panes[idNumber] = new Pane (theElement, fromRed, fromGreen, fromBlue, toRed, toGreen, toBlue, upSteps, upInterval, downSteps, downInterval, idNumber);
	}
	var o = panes[idNumber];
	if (o.currentRed == o.toRed && o.currentGreen == o.toGreen && o.currentBlue == o.toBlue) {
		clearInterval(o.upTimer);
		o.upTimer = "";
		return;
	} else {
		if (o.downTimer != "") {
			clearInterval(o.downTimer);
			o.downTimer = "";
		}
		if (theElement.style.zIndex != 50) {
			theElement.style.zIndex = 50;
		}
		if (o.upTimer == "") {
			o.upTimer = setInterval("fadeup (document.getElementById('" + theID + "'))", o.upInterval);
		}
	}
	o.fadeUpStep();
	theElement.style.color = "rgb(" + o.currentRed + "," + o.currentGreen + "," + o.currentBlue + ")";
}

function fadedown (theElement) {
	theID = theElement.getAttribute("ID");
	idNumber = parseInt(theID.match(/\d+/),10);
	var o = panes[idNumber];
	if (o.currentRed == o.fromRed && o.currentGreen == o.fromGreen && o.currentBlue == o.fromBlue) {
		clearInterval(o.downTimer);
		o.downTimer = "";
		theElement.style.zIndex = o.zindex;
		return;
	} else {
		if (o.upTimer != "") {
			clearInterval(o.upTimer);
			o.upTimer = "";
		}
		if (theElement.style.zIndex != 49) {
			theElement.style.zIndex = 49;
		}
		if (o.downTimer == "") {
			o.downTimer = setInterval("fadedown (document.getElementById('" + theID + "'))", o.downInterval);
		}
	}
	o.fadeDownStep();
	theElement.style.color = "rgb(" + o.currentRed + "," + o.currentGreen + "," + o.currentBlue + ")";
}
