var TFaders = [];

function TFader(a_items, o_adds) {
	this.n_height = o_adds.height; 
	this.n_width = o_adds.width; 
	
	this.a_items = a_items;
	this.n_id = TFaders.length;
	TFaders[this.n_id] = this;
	this.n_cur =
	this.b_moving =
	this.n_state = 0;
	this.n_dir = 1;
	
	this.f_change = TFaderChg;
	this.goTo = TFaderGoTo;
	this.pause = TFaderPause;
	
	document.write('<table cellpadding="0" cellspacing="0" border="0"', o_adds.width ? ' width="' + o_adds.width + '"' : '', o_adds.height ? ' height="' + o_adds.height + '"' : '', '><tr><td id="TFader', this.n_id, '" style="position:relative;filter:alpha(opacity=100)" valign="top">', a_items[0]);
	document.write('</td></tr></table>');
	this.e_cont = document.layers 
		? document.layers['TFader' + this.n_id]
		: document.all 
			? document.all['TFader' + this.n_id]
			: document.getElementById('TFader' + this.n_id);
	
	this.f_fade = function () {
		this.e_cont.innerHTML = this.a_items[this.n_cur];
		if (this.b_moving)
			this.n_timer = setTimeout('TFaders[' + this.n_id + '].f_change()', this.n_tshow);
	};
	if (o_adds.tfade) {
		this.n_tfade = Math.round(o_adds.tfade / 99);
		var a_ver = navigator.appVersion.match(/MSIE [0-9.]+/);
		if (navigator.userAgent.indexOf('MSIE') > -1 && a_ver && a_ver[0] && a_ver[0].replace('MSIE ', '') >= 5 && this.e_cont.style.filter) {
			document.write('<sc','ript>\n',
				'function TFaderFadeIE(n_opa) {\n',
					'if (n_opa > -99) {\n',
						'n_opa -= 9;\n',
						'try {\n',
							'if (n_opa > 0 && this.e_cont.filters)\n',
								'this.e_cont.filters.alpha.opacity = n_opa;\n',
							'else if (n_opa == 0)\n',
								'this.e_cont.innerHTML = this.a_items[this.n_cur];\n',
							'else\n',
								'this.e_cont.filters.alpha.opacity = - n_opa;\n',
						'}catch (e) {}finally {}\n',
						'return this.n_timer = setTimeout(\'TFaders[\' + this.n_id + \'].f_fade(\' + n_opa + \')\', this.n_tfade);\n',
					'}\n',
					'else if (this.b_moving)\n',
						'this.n_timer = setTimeout(\'TFaders[\' + this.n_id + \'].f_change()\', this.n_tshow);\n',
				'}\n',
			'</scri','pt>');
			this.f_fade = TFaderFadeIE;
		}
		else if (navigator.userAgent.indexOf('Gecko') > -1)
			this.f_fade = function (n_opa) {
				if (n_opa > -99) {
					n_opa -= 9;
					if (n_opa > 0)
						this.e_cont.style.MozOpacity = n_opa / 100;
					else if (n_opa == 0)
						this.e_cont.innerHTML = this.a_items[this.n_cur];
					else
						this.e_cont.style.MozOpacity = - n_opa / 100;
					return this.n_timer = setTimeout('TFaders[' + this.n_id + '].f_fade(' + n_opa + ')', this.n_tfade);
				}
				else if (this.b_moving)
					this.n_timer = setTimeout('TFaders[' + this.n_id + '].f_change()', this.n_tshow);
			};
		else if (window.opera)
			this.f_fade = function (n_opa) {
				if (n_opa > -99) {
					n_opa -= 9;
					if (n_opa > 0)
						this.e_cont.style.opacity = n_opa / 100;
					else if (n_opa == 0)
						this.e_cont.innerHTML = this.a_items[this.n_cur];
					else
						this.e_cont.style.opacity = - n_opa / 100;
					return this.n_timer = setTimeout('TFaders[' + this.n_id + '].f_fade(' + n_opa + ')', this.n_tfade);
				}
				else if (this.b_moving)
					this.n_timer = setTimeout('TFaders[' + this.n_id + '].f_change()', this.n_tshow);
			};
	}

	this.n_tshow = o_adds.tshow;
	this.pause();
}

function TFaderChg(b_dir) {
	this.n_old = this.n_cur;
	this.n_cur += !b_dir * 2 - 1;
	if (this.n_cur >= this.a_items.length)
		this.n_cur = 0;
	else if (this.n_cur < 0)
		this.n_cur = this.a_items.length - 1;
	this.f_fade(99);
}

function TFaderGoTo(n_dir) {
	clearTimeout(this.n_timer);
	this.f_change(n_dir < 0);
	return false;
}

function TFaderPause() {
	if (this.b_moving)
		clearTimeout(this.n_timer);
	else
		this.n_timer = setTimeout('TFaders[' + this.n_id + '].f_change()', this.n_tshow);
	this.b_moving = !this.b_moving;
	return false;
}