var wiping = 0;
var nav_to_wipe = 0;
var wipe_list = new Object();

function init(ph)
{
	if (ph) page_height = ph;

	document.onmousemove = mouseMove;
	document.onmouseup   = mouseUp;

	if (nav_to_wipe.length)
	{
		temp = nav_to_wipe.shift();
		wipe(temp,5,false,true);
	}

}

function wiper()
{
	var obj = null;
	var speed = null;
	var wiper_obj = null;
	var interval_id = null;
	var gal = false;
	var nav_wipe = false;

	this.setup = function(o,g,n)
	{
		if (!o) return false;
		wiper_obj = document.getElementById(o+"_wipe");
		if (g) gal = true;
		if (n) nav_wipe = true;
		obj = document.getElementById(o);
	}

	function do_wipe()
	{
		x = wiper_obj.offsetWidth;
		if (!gal)
		{
			if (x+speed <= 136 && x+speed >= 3) // SET PIXEL WIDTH HERE TOO
			{
				wiper_obj.style.opacity = 1;
				wiper_obj.style.filter = "alpha(opacity=100)";
				wiper_obj.style.display = '';
				wiper_obj.style.width = (x+speed)+"px";
			}
			else
			{
				if (x+speed > 150) wiper_obj.style.width = "150px"; // SET PIXEL WIDTH HERE TOO (TWICE!!)
				else if (x+speed <= 3)
				{
					wiper_obj.style.width = "1px";
					wiper_obj.style.display = 'none';
				}
				if (nav_to_wipe.length && nav_wipe)
				{
					wiper_obj = nav_to_wipe.shift();
					obj = document.getElementById(wiper_obj);
					wiper_obj = document.getElementById(wiper_obj+"_wipe");
				}
				else
				{
					clearInterval(interval_id);
					interval_id = 0;
					wiping--;
				}
			}
		}
		else
		{
			var new_width = null;
			new_width = parseInt((of/150) * 300);
			if (speed > 0) new_width = 150 - new_width;
			wiper_obj.style.opacity = 1;
			wiper_obj.style.filter = "alpha(opacity=100)";
			wiper_obj.style.width = new_width+"px";
			if (of < 2)
			{
				if (speed < 0)
				{
					wiper_obj.style.width = "1px";
					wiper_obj.style.opacity = 0;
					wiper_obj.style.filter = "alpha(opacity=0)";
				}
				clearInterval(interval_id);
				interval_id = 0;
			}
		}
	}

	this.initiate = function(s)
	{
		speed = s;
		var interval = (gal ? 10 : 10);
		if (!interval_id)
		{
			interval_id = setInterval(do_wipe,interval);
			if (!gal) wiping++;
		}
	}
}

function wipe(obj,speed,gal,nav_wipe)
{
	if (wipe_list[obj])
	{
		wipe_list[obj].initiate(speed);
	}
	else
	{
		wipe_list[obj] = new wiper;
		wipe_list[obj].setup(obj,gal,nav_wipe);
		wipe_list[obj].initiate(speed);
	}
}

