soundManager.url = '../../swf/soundmanager2.swf'; // override default SWF url

soundManager.onload = function() {
  soundManager.createSound('click','../../mp3/pokerchip04.mp3');
 }

animatingButtons = new Array();
animationSpeed = 1000 / 40;
pageButtonHeight = 13;
yearButtonHeight = 8;
ybOffsets = new Array( 0, -46, -88,  -110, -131); // computed css values aren't easily accessible

function  onmouseover_pageButton( f)
{
	if ( f.className=='active') return;
	for ( i = 0; i < animatingButtons.length; i++)
	{
		if ( animatingButtons[i][0] == f)
		{
			animatingButtons[i][2] = 1;
			return;
		}
	}
	var img = null;

	for ( i = 0; i < f.childNodes.length; i++)
	{
		if ( f.childNodes[i].nodeName == 'IMG')
		{
			img = f.childNodes[i];
		}
	}
	var newAnimatingButton = new Array( f, -pageButtonHeight, 1, img, pageButtonHeight, 0);
		
	animatingButtons.push( newAnimatingButton);
	if ( animatingButtons.length < 2)
		setTimeout("updateAnimatingButtons()", animationSpeed); 
}

function  onmouseout_pageButton( f)
{
	if ( f.className=='active') return;
	for ( i = 0; i < animatingButtons.length; i++)
	{
		if ( animatingButtons[i][0] == f)
		{
			animatingButtons[i][2] = -1;
			return;
		}
	}
	var img = null;
	for ( i = 0; i < f.childNodes.length; i++)
	{
		if ( f.childNodes[i].nodeName == 'IMG')
		{
			img = f.childNodes[i];
		}
	}
	var newAnimatingButton = new Array( f, 0, -1, img, pageButtonHeight, 0);
		
	animatingButtons.push( newAnimatingButton);
	if ( animatingButtons.length < 2)
		setTimeout("updateAnimatingButtons()", animationSpeed); 
}

function updateAnimatingButtons()
{
	for ( i = animatingButtons.length - 1; i >= 0; i--)
	{
		animatingButtons[i][0].style.backgroundPosition =
			animatingButtons[i][5] +'px ' + animatingButtons[i][1] + 'px';
		if (((animatingButtons[i][1] <= -animatingButtons[i][4]) && ( animatingButtons[i][2] < 0))
			|| (( animatingButtons[i][1] >= 0) &&  ( animatingButtons[i][2] > 0)))
		{
			if ( animatingButtons[i][2] > 0)
				animatingButtons[i][0].style.backgroundPosition = animatingButtons[i][5] + 'px 0';
			else
				animatingButtons[i][0].style.backgroundPosition = animatingButtons[i][5] +'px -' + animatingButtons[i][4] + 'px';
			if ( animatingButtons[i][3] != null)
			{
				animatingButtons[i][3].style.height = animatingButtons[i][4] + 'px';
				animatingButtons[i][3].style.width = animatingButtons[i][4] + 'px';
			}
			if ( animatingButtons[i][1] >= 0)
				soundManager.play('click');
			animatingButtons.splice( i, i + 1);
		} else
		{
			animatingButtons[i][1] = animatingButtons[i][1] +
				animatingButtons[i][2];
			animatingButtons[i][1] = animatingButtons[i][1] +
				animatingButtons[i][2];
			var	height = Math.abs( animatingButtons[i][1]);
			
			if ( height < (animatingButtons[i][4] / 2)) height = ((animatingButtons[i][4] / 2) - height) * 2;
			else height = (height - (animatingButtons[i][4] / 2)) * 2;
			if ( height > animatingButtons[i][4]) height = animatingButtons[i][4];
			if ( animatingButtons[i][3] != null)
			{
				animatingButtons[i][3].style.height = height + 'px';
				animatingButtons[i][3].style.width = animatingButtons[i][4] + 'px';
			}
		}
	}
	if (animatingButtons.length > 0)
		setTimeout("updateAnimatingButtons()", animationSpeed); 
			
}

window.onload = function() {
	var pageButtons = document.getElementsByTagName('div');

	for ( b = 0; b < pageButtons.length; b++)
	{
		if ( pageButtons[b].className == 'page-buttons')
		{
			for ( i=0; i < pageButtons[b].childNodes.length; i++)
			{
				if ( pageButtons[b].childNodes[i].nodeName == 'A')
				{
					pageButtons[b].childNodes[i].onmouseover = function()
					{
						onmouseover_pageButton( this);
					}
					pageButtons[b].childNodes[i].onmouseout = function()
					{
						onmouseout_pageButton( this);
					}
				}
			}
		}
	}

	var yearButtons = document.getElementsByTagName('li');
	
	for ( b = 0; b < yearButtons.length; b++)
	{
		if ( yearButtons[b].id.substr( 0, "year-menu-item-".length) == "year-menu-item-")
		{
			for ( i=0; i < yearButtons[b].childNodes.length; i++)
			{
				if ( yearButtons[b].childNodes[i].nodeName == 'A')
				{
					yearButtons[b].childNodes[i].onmouseover = function()
					{
						onmouseover_yearButton( this);
					}
					yearButtons[b].childNodes[i].onmouseout = function()
					{
						onmouseout_yearButton( this);
					}
				}
			}
		}
	}
}

function  onmouseover_yearButton( f)
{
	var yb =  Number(f.parentNode.id.substr( "year-menu-item-".length, 1));// - 1;
		if ( f.parentNode.className=='active') return;
	for ( i = 0; i < animatingButtons.length; i++)
	{
		if ( animatingButtons[i][0] == f)
		{
			animatingButtons[i][2] = 1;
			return;
		}
	}
	var newAnimatingButton = new Array( f, -yearButtonHeight, 1, null, yearButtonHeight, ybOffsets[yb]);
		
	animatingButtons.push( newAnimatingButton);
	if ( animatingButtons.length < 2)
		setTimeout("updateAnimatingButtons()", animationSpeed); 
}

function onmouseout_yearButton( f)
{
	var yb =  Number(f.parentNode.id.substr( "year-menu-item-".length, 1));// - 1;
		if ( f.parentNode.className=='active') return;
	for ( i = 0; i < animatingButtons.length; i++)
	{
		if ( animatingButtons[i][0] == f)
		{
			animatingButtons[i][2] = 1;
			return;
		}
	}
	var newAnimatingButton = new Array( f, 0, -1, null, yearButtonHeight, ybOffsets[yb]);
		
	animatingButtons.push( newAnimatingButton);
	if ( animatingButtons.length < 2)
		setTimeout("updateAnimatingButtons()", animationSpeed); 
}