/***************************************************
*	JavaScript-Überblendfunktion	v1.8.0425			*
*	Copyright (c) 2008 by Jörg Schuchardt				*
***************************************************/

function fade_object(obj)
{
//	object
	this.obj = document.getElementById(obj);
	if (!this.obj)	return false;

// handle
	this.handle = obj + "Obj";
	eval(this.handle + " = this;");

// methods
	this.fade = fade;

// variables
	var nua = navigator.userAgent;
	this.fade_bw = nua.indexOf('MSIE') >= 0 ? 1 : (nua.indexOf('Gecko') >= 0 ? 2 : 0);
	this.fade_id = 0;
	this.fade_it = new Array();
	this.fade_nx = 0;
	this.fade_op = this.fade_bw ? 100 : 0;
	this.fade_tm = false;

// initialize
	var i = 0, j = 0, msg = "";
	while (this.obj.childNodes[i]) {
		if (this.obj.childNodes[i].nodeType == 1) {
			this.fade_it[j] = this.obj.childNodes[i];

			if (j) {
				if (this.fade_bw == 1) this.fade_it[j].style.filter = 'alpha(opacity=0)';	else
				if (this.fade_bw == 2) this.fade_it[j].style.MozOpacity = 0;
				this.fade_it[j].style.visibility = 'hidden';
			} else {
				if (this.fade_bw == 1) this.fade_it[j].style.filter = 'alpha(opacity=100)';	else
				if (this.fade_bw == 2) this.fade_it[j].style.MozOpacity = 1;
				this.fade_it[j].style.visibility = 'visible';
			}
			j++;
		}
		i++;
	}

	if (j)	this.fade_nx = 1;

	if (!this.fade_it.length) {
		delete this.fade_it;
		delete this.obj;
		return false;
	}

	return this;
}

function fade(wait, step, msec, auto)
{
	if (!this.obj || this.fade_it.length <= 1)	return false;

	if (this.fade_tm)	window.clearTimeout(this.fade_tm);
	this.fade_tm = false;

	if (!wait)	wait = 0;
	if (!step)	step = 10;
	if (!msec)	msec = 25;
	if (!auto) {
		if (this.fade_bw)	this.fade_it[this.fade_nx].style.visibility = 'visible';
		this.fade_tm = window.setTimeout(this.handle + ".fade(" + wait + ", " + step + ", " + msec + ", true);", wait);
		return this.fade_tm;
	}

	if (this.fade_op) {
		this.fade_op = Math.max(0, this.fade_op - step);

		switch (this.fade_bw) {
			case 1:	//	MSIE
				this.fade_it[this.fade_id].style.filter = 'alpha(opacity=' + this.fade_op + ')';
				this.fade_it[this.fade_nx].style.filter = 'alpha(opacity=' + (100 - this.fade_op) + ')';
				break;
			case 2:	//	Gecko
				this.fade_it[this.fade_id].style.MozOpacity = this.fade_op / 100;
				this.fade_it[this.fade_nx].style.MozOpacity = (100 - this.fade_op) / 100;
				break;
		}
		this.fade_tm = window.setTimeout(this.handle + ".fade(" + wait + ", " + step + ", " + msec + ", true);", msec);
	}
	else {
		this.fade_it[this.fade_id].style.visibility = 'hidden';
		this.fade_id = this.fade_nx;
		this.fade_nx = (this.fade_nx + 1) % this.fade_it.length;
		this.fade_it[this.fade_bw ? this.fade_nx : this.fade_id].style.visibility = 'visible';
		this.fade_op = this.fade_bw ? 100 : 0;
		this.fade_tm = window.setTimeout(this.handle + ".fade(" + wait + ", " + step + ", " + msec + ", true);", wait);
	}

	return this.fade_tm;
}
