// JavaScript Document
var imgaux;
var images= new Array();
imagesAncho= new Array();
imagesAlto= new Array();
var frame ;
var num;

function redimensionar(ancho, alto){
	ancho = 90 + Number(ancho);
	alto = 185 + Number(alto);

	if(ancho>screen.width)	ancho=screen.width-10;
	
	if(alto>screen.height)	alto=screen.height-20;	

	window.resizeTo(ancho,alto);
	posIzq = (screen.width-ancho+10)/2;
	posDer = (screen.height-alto+20)/2;
	if(posIzq<0)posIzq=0;
	if(posDer<0)posDer=0;	
	this.moveTo(posIzq-10,posDer-20); 	
}



function changeFlecha(next)
{
	if (document.animation!=null)
	{
		if (next != true) // Si voy para atras
		{	
			frame = frame-1;
			if (frame < 1)
				frame = images.length - 1;			
		}
		else
		{
			frame = frame+1;
			if (frame >= images.length)
				frame = 1;			
		}
		
		if (document.animation!=null){
			document.animation.src = images[frame].src;
			document.getElementById("numim").innerHTML = frame;			
			num = frame+1;
		}
	}
}


function resizeOnLoad()
{
	
	var maxAncho = 0;
	var maxAlto = 0;
	
	frame = parseInt(document.getElementById('idImg').value);
	num = parseInt(document.getElementById('idImg').value);
	
	for(i = 1; i <= document.getElementById('imgCant').value; i++)
	{	
		imgaux = new Image();
		imgaux.src =document.getElementById('imgSrc_'+i).value;
		imgAncho = document.getElementById('imgAncho_'+i).value;
		imgAlto = document.getElementById('imgAlto_'+i).value;
		images[ i ] = imgaux;
		imagesAncho[ i ] = imgAncho;
		imagesAlto[ i ] = imgAlto;
			
		if( parseInt(maxAncho) < parseInt(imagesAncho[i]))			
			maxAncho = imagesAncho[i];

		if(parseInt(imagesAlto[i]) > parseInt(maxAlto))
			maxAlto = imagesAlto[i];
	}
		
	tmpAlto = Number(maxAlto) + 20;
	document.getElementById("tableImg").style.height = tmpAlto + "px";

	if( parseInt(maxAncho) < 300)			
		maxAncho = 300;

	if(parseInt(maxAlto) < 150)
		maxAlto = 150;
		
	redimensionar(maxAncho, maxAlto);
}

