// Banner animation
//==================
var t = new Array();
var width = new Array();
var height = new Array();
var y = new Array();

var delay = 1;
var minW = 98;
var minH = 151;
var maxW = 140;
var maxH = 202;
var minTop = -29;
var maxTop = 0;
var ratioH = 1.35;
var ratioY = 0.65;
var step = 3;

function highlightBanner(index,destImg)
{
	clearTimeout(t[index]);
	elm = document.getElementById("produkt_"+parseInt(index));
	
	//store current size
	width[index] = parseInt(elm.style.width);
	if(!width[index])
	{
		width[index] = minW;
	}
	height[index] = parseInt(elm.style.height);
	if(!height[index])
	{
		height[index] = minH;
	}
	y[index] = parseInt(elm.style.top);
	if(!y[index])
	{
		y[index] = maxTop;
	}
	
	//use large image, but retain present size
	elm.src = destImg;
	elm.style.width = parseInt(width[index])+"px";
	elm.style.height = parseInt(height[index])+"px";
	
	t[index] = setTimeout("animGrow('"+index+"')",delay);
}

function unhighlightBanner(index,destImg)
{
	clearTimeout(t[index]);
	elm = document.getElementById("produkt_"+parseInt(index));
	
	//store current size
	width[index] = parseInt(elm.style.width);
	height[index] = parseInt(elm.style.height);
	y[index] = parseInt(elm.style.top);
	
	//use small image, but retain present size
	elm.src = destImg;
	//elm.style.top = "-29px";
	elm.style.width = parseInt(width[index])+"px";
	elm.style.height = parseInt(height[index])+"px";
	
	t[index] = setTimeout("animShrink('"+index+"')",delay);				
}

function animGrow(index)
{
	elm = document.getElementById("produkt_"+parseInt(index));			
	width[index] += step;
	height[index] += step * ratioH;
	y[index] -= step * ratioY;
	
	var growingH = true;
	var growingW = true;
	var movingY = true;
				
	if( width[index] > maxW )
	{
		growingH = false;
		width[index] = maxW;
	}			
	
	if(height[index] >= maxH)
	{
		growingW = false;
		height[index] = maxH;
	}
	
	if(y[index] <= minTop)
	{
		movingY = false;
		y[index] = minTop;
	}
	
	elm.style.width = parseInt(width[index])+"px";
	elm.style.height = parseInt(height[index])+"px";
	elm.style.top = parseInt(y[index])+"px";
	
	if(growingH || growingW || movingY)
	{
		t[index] = setTimeout("animGrow('"+index+"')",delay);			
	} 
}

function animShrink(index)
{
	elm = document.getElementById("produkt_"+parseInt(index));
	width[index] -= step;
	height[index] -= step * ratioH;
	y[index] += step * ratioY;
	
	var shrinkingH = true;
	var shrinkingW = true;
	var movingY = true;
	
	if(width[index] <= minW)
	{
		shrinkingW = false;
		width[index] = minW;
	}	
	
	if(height[index] <= minH)
	{
		shrinkingH = false;
		height[index] = minH;
	}	
	
	if(y[index] >= maxTop)
	{
		movingY = false;
		y[index] = maxTop;
	}

	elm.style.width = parseInt(width[index])+"px";
	elm.style.height = parseInt(height[index])+"px";						
	elm.style.top = parseInt(y[index])+"px";

	
	if(shrinkingH || shrinkingW || movingY)
	{
		t[index] = setTimeout("animShrink('"+index+"')",delay);			
	} 

}

