var key1;
var key2;

Event.observe(window, 'load', preloader); 

function showGroot(i,j)
{
	key1 = eval(i);
	key2 = eval(j);
	new Effect.Opacity('container', 
	{ 
		from: 1, 
		to: 0.4, 
		duration: 0.5, 
		afterFinish: function() 
		{ 
			if(type != "outfits")
			{
				document["grootImage"].src = "../images/" + page + "/groot/" + fotoArray[i][j] + ".jpg";
			}else{
				
				document["grootImage"].src = "../images/outfits/groot/" + fotoArray[i][j] + ".jpg";
			}
			$('techGroot').appear({ duration: 0.5 });
		}
	});
}


function hideGroot()
{
	$('techGroot').fade(
	{
		duration: 0.5, 
		afterFinish: function() 
		{ 
			new Effect.Opacity('container',
			{
				from: 0.4, 
				to: 1, 
				duration: 0.5
			});
		}
	
	});
}


function changeGroot(dif)
{
	key2 += eval(dif);
	
	if(key2 == fotoArray[key1].length)
	{
		key2 = 0;
		key1 = (key1 == fotoArray.length-1) ? 0 : key1+1;	
	}else if(key2 == -1){
		key2 = fotoArray[key1].length-1;
		key1 = (key1 == 0) ? fotoArray.length-1 : key1-1;
	}
	
	if(fotoArray[key1][key2] == "") 
	{
		changeGroot(dif);
	}else{
		new Effect.Opacity('imgHolder',
		{
			from: 1, 
			to: 0, 
			duration: 0.5,
			afterFinish: function() 
			{ 
				if(type != "outfits")
	     		{
					document["grootImage"].src = "../images/" + page + "/groot/" + fotoArray[key1][key2] + ".jpg";
				}else{
					document["grootImage"].src = "../images/outfits/groot/" + fotoArray[key1][key2] + ".jpg";
				}
				new Effect.Opacity('imgHolder',
				{
					from: 0, 
					to: 1, 
					duration: 0.5
				});
			}
		});
	}
}

function preloader() 
{
     // counter
     var i = 0;
   
     // create object
     imageObj = new Image();

     // set image list
     images = new Array();
     
     for(var u=0; u<fotoArray.length; u++)
     {
     	for(var j=0; j<fotoArray[u].length; j++)
     	{
     		if(type != "outfits")
     		{
     			imageObj.src = "../images/" + page + "/groot/" +fotoArray[u][j] + ".jpg";
     		}else{
     			imageObj.src = "../images/outfits/groot/" +fotoArray[u][j] + ".jpg";
     		}
     		i++;
  		}
  	}
} 