var y = new Array(6);
var height = new Array(6);
var delta = new Array(6);
var moving = new Array(6);

var mheight = new Array(6);
var mdelta = new Array(6);
var mmoving = new Array(6);

var imageHeight = 350;
var fromTop = 87;
var menuHeight = 100;
var divider = 10;

for (i = 0;i<6;i++)
{
	delta[i] = 0;
	moving[i] = 0;
	height[i] = 0;
	mdelta[i] = 0;
	mmoving[i] = 0;
	mheight[i] = 0;
	y[i] = (fromTop + (i + 1) * (imageHeight+divider) - divider);
}

function Move(id)
{
	index = parseInt(id.substr(2));
	height0 = height[index];
	height[index] += delta[index];
	if (height[index] <= 0)
	{
		height[index] = 0;
		delta[index] = 0;
	}
	if (height[index] >= menuHeight)
	{
		height[index] = menuHeight;
		delta[index] = 0;
	}
	y[index] -= (height[index] - height0);
	document.getElementById(id).style.top = y[index]+"px";
	document.getElementById(id).style.height = height[index]+"px";
	if (delta[index] != 0)
	{
		setTimeout(function(){Move(id)},10);
	}
	else
	{
		moving[index] = 0;
	}
}
function mMove(id)
{
	index = parseInt(id.substr(1));
	height0 = mheight[index];
	mheight[index] += mdelta[index];
	if (mheight[index] <= 0)
	{
		mheight[index] = 0;
		mdelta[index] = 0;
	}
	if (mheight[index] >= imageHeight+20)
	{
		mheight[index] = imageHeight;
		mdelta[index] = 0;
		document.getElementById(id).style.background = "url('tapestry majors/m0.png')";
	}
	document.getElementById(id).style.height = mheight[index]+"px";
	if (mdelta[index] != 0)
	{
		setTimeout(function(){mMove(id)},1);
	}
	else
	{
		mmoving[index] = 0;
	}
}
function mLoad(id)
{
	index = parseInt(id.substr(1));
	mdelta[index] = 1;
	if (mmoving[index] == 0)
	{
		mmoving[index] = 1;
		//mMove('id');
		setTimeout(function(){mMove(id)},1);
	}
}
function MouseOver(id)
{
	index = parseInt(id.substr(2));
	delta[index] = 20;
	if (moving[index] == 0)
	{
		moving[index] = 1;
		setTimeout(function(){Move(id)},1);
	}
}
function MouseOut(id)
{
	index = parseInt(id.substr(2));
	delta[index] = -20;
	if (moving[index] == 0)
	{
		moving[index] = 1;
		setTimeout(function(){Move(id)},1);
	}
}

function titleLoad(id)
{
document.getElementById(id).style.backgroundImage = 'url(titles/title-'+Math.floor(Math.random()*18)+'.png)';
}

