//( fade.js version 4 by Thomas Michel for browsers Mozilla 2+, IE 5.5+, NS6+


function T_Image ()
	{
	this.b_Ready = 0;
	}


T_Image.prototype.v_Init = function (S_id)
	{
	if (this.b_Ready)
		{
		return;
		}

	if (S_id)
		{
		var o_img;

		if (document.getElementById)
			{
			o_img = document.getElementById(S_id);
			}

		if (!o_img || o_img.tagName != "IMG")
			{
			return;
			}

		this.s_ID = S_id;
		this.o_IMG = o_img;
		}

	this.b_Ready = 1;

	return;
	}


T_Image.prototype.v_Exit = function ()
	{
	if (!this.b_Ready)
		{
		return;
		}

	var Z;

	if (this.s_ID)
		{
		this.s_ID = Z;
		this.o_IMG = Z;
		}
	else
		{
		if (this.o_IMG)
			{
			delete this.o_IMG;
			this.o_IMG = Z;
			}
		}

	this.b_Ready = 0;
	}


T_Image.prototype.v_Load = function (S_file, FV_notify)
	{
	if (!this.b_Ready)
		{
		return;
		}

	var Z;

	if (!this.s_ID && this.o_IMG)
		{
		delete this.o_IMG;
		this.o_IMG = Z;
		}

	if (S_file)
		{
		if (!this.s_ID)
			{
			this.o_IMG = new Image ();
			}

		if (FV_notify)
			{
			this.o_IMG.onload = FV_notify;
			}

		this.o_IMG.src = S_file;
		}
	}


T_Image.prototype.v_SetOpacity = function (N_opacity)
	{
	if (!this.b_Ready)
		{
		return;
		}

	if (!this.s_ID)
		{
		return;
		}

	if (!T_Image.prototype.fv_SetOpacity)
		{
		var s_userAgent;
		s_userAgent = navigator.userAgent;

		if (/^Mozilla\//.test(s_userAgent))
			{
			if (document.getElementById)
				{
				//alert("set opacity function");
				T_Image.prototype.fv_SetOpacity =
				 function (O_image, N_opacity)
				 {
				 //alert(N_opacity);

				 O_image.o_IMG.style.filter =
				  "alpha(opacity =" + N_opacity + ");";

				 O_image.o_IMG.style.opacity = N_opacity / 100;

				 O_image.n_Opacity = N_opacity;
				 }
				 ;
				}
			}
		else
			{
			if (0 && navigator.userAgent.toLowerCase().indexOf("opera") == -1)
				{
				if (document.all)
					{
					T_Image.prototype.fv_SetOpacity =
					 function (O_image, N_opacity)
					 {
					 O_image.o_IMG.style.filter =
					 "alpha(opacity=" + N_opacity + ")";
					 //window.status = "[" + N_opacity + "]";
					 O_image.n_Opacity = N_opacity;
					 }
					 ;
					}
				else if (document.getElementById)
					{
					T_Image.prototype.fv_SetOpacity =
					 function (O_image, N_opacity)
					 {
					 O_image.o_IMG.style.MozOpacity = N_opacity + "%";
					 O_image.n_Opacity = N_opacity;
					 }
					 ;
					}
				}
			}

		if (!T_Image.prototype.fv_SetOpacity)
			{
			//alert("set opacity 100%");

			T_Image.prototype.fv_SetOpacity =
			 function (O_image, N_opacity)
			 {
			 O_image.n_Opacity = 100;
			 }
			 ;
			}
		}

	N_opacity = N_opacity
	 ? (N_opacity < 0 ? 0 : (N_opacity > 100 ? 100 : N_opacity)) : 0;

	this.fv_SetOpacity(this, N_opacity);
	}


function T_Fade (N_from, N_into, N_step, N_time)
	{
	this.n_From = N_from ? (N_from < 0 ? 0
	 : (N_from > 100 ? 100 : N_from)) : 0;
	this.n_Into = N_into ? (N_into < 0 ? 0
	 : (N_into > 100 ? 100 : N_into)) : 0;
	
	if (!(this.n_Step = N_step ? (N_step < 0 ? -N_step : N_step) : 0))
		{
		this.n_Into = this.n_From;
		}

	this.n_Time = N_time ? N_time : 0;
	}


function T_Fader ()
	{
	this.b_Ready = 0;
	}


T_Fader.prototype.v_Init = function (S_id)
	{
	if (this.b_Ready)
		{
		return;
		}

	var o_image;
	o_image = new T_Image ();
	o_image.v_Init(S_id);

	if (!o_image.b_Ready)
		{
		return;
		}

	this.s_ID = S_id;
	this.o_FadedImage = o_image;

	this.b_Run = 0;
	this.b_Stop = 0;

	this.b_Ready = 1;
	}


T_Fader.prototype.v_Exit = function ()
	{
	if (!this.b_Ready)
		{
		return;
		}

	var Z;

	this.v_Stop();

	if (this.o_TriggerImage)
		{
		this.o_TriggerImage.v_Exit();
		delete this.o_TriggerImage;
		this.o_TriggerImage = Z;
		}

	if (this.o_BufferImage)
		{
		this.o_BufferImage.v_Exit();
		delete this.o_BufferImage;
		this.o_BufferImage = Z;
		}

	if (this.o_FadedImage)
		{
		this.o_FadedImage.v_Exit();
		delete this.o_FadedImage;
		this.o_FadedImage = Z;
		}

	this.o_Fade = Z;
	this.fv_OnDone = Z;

	this.b_Ready = 0;
	}


T_Fader.prototype.v_Buffer = function (S_file)
	{
	if (!this.b_Ready)
		{
		return;
		}

	var Z;

	if (this.o_BufferImage)
		{
		this.o_BufferImage.v_Exit();
		delete this.o_BufferImage;
		this.o_BufferImage = Z;
		}

	this.o_BufferImage = new T_Image ();
	this.o_BufferImage.v_Init();

	this.o_BufferImage.v_Load(S_file);
	}


T_Fader.prototype.v_Start = function (N_delay, O_fade, FV_onDone)
	{
	if (!this.b_Ready)
		{
		return;
		}

	if (!O_fade || !this.o_BufferImage)
		{
		return;
		}

	var Z;

	this.b_Run = 1;
	this.b_Stop = 0;

	if (this.o_TriggerImage)
		{
		this.o_TriggerImage.v_Exit();
		delete this.o_TriggerImage;
		this.o_TriggerImage = Z;
		}

	this.o_TriggerImage = new T_Image ();
	this.o_TriggerImage.v_Init();

	var o_this;
	o_this = this;

	this.o_Fade = O_fade;
	this.fv_OnDone = FV_onDone;

	this.o_TriggerImage.v_Load(this.o_BufferImage.o_IMG.src,
	 function () { o_this.v_Triggered(N_delay); });
	}


T_Fader.prototype.v_Stop = function ()
	{
	if (!this.b_Ready)
		{
		return;
		}

	this.b_Stop = 1;
	this.b_Run = 0;
	}


T_Fader.prototype.v_Triggered = function (N_delay)
	{
	var o_this;
	o_this = this;

	setTimeout(function ()
	 { o_this.v_Loop(o_this.o_Fade.n_From); }, N_delay);
	}


T_Fader.prototype.v_Loop = function (N_opacity)
	{
	if (this.b_Stop)
		{
		return;
		}

	var o_fade;
	o_fade = this.o_Fade;

	this.o_FadedImage.v_SetOpacity(N_opacity);

	if (N_opacity == o_fade.n_From)
		{
		this.o_FadedImage.v_Load(this.o_TriggerImage.o_IMG.src);
		}

	if (N_opacity == o_fade.n_Into)
		{
		this.b_Run = 0;

		if (this.fv_OnDone)
			{
			this.fv_OnDone(this);
			}

		return;
		}

	if (o_fade.n_From <= o_fade.n_Into)
		{
		if ((N_opacity += o_fade.n_Step) > o_fade.n_Into)
			{
			N_opacity = o_fade.n_Into;
			}
		}
	else
		{
		if ((N_opacity -= o_fade.n_Step) < o_fade.n_Into)
			{
			N_opacity = o_fade.n_Into;
			}
		}

	var o_this;
	o_this = this;

	setTimeout(function ()
	 { o_this.v_Loop(N_opacity); }, o_fade.n_Time);
	}


//) fade.js version 4 by Thomas Michel for browsers Mozilla 2+, IE 5.5+, NS6+

