// JavaScript Document

var sangria=0;

function ini_foto(cual)
{
switch (cual) {
	case 1: //Foto 1 (central)
		$('foto1_img').src=foto_file[actual];
		break;
	case 2: //Foto 2 (izda)
		if (actual>0) {
			$('foto2_img').src=foto_file[actual-1];
		} else {
			$('foto2_img').src='#';
		}
		break;
	case 3: //Foto 3 (dcha)
		if (actual-1<foto_file.length) {
			$('foto3_img').src=foto_file[actual+1];
		} else {
			$('foto3_img').src='#';
		}
		break;
	}
}


function posicionar_fotoshow()
{
//Calculo la sangra con respecto al borde del navegador
sangria=parseInt((scr_width()-page_width)/2);

$('fotos').style.width=scr_width()+'px';

//Posiciono el carrusel
$('carrusel').style.left=(sangria-(actual*page_width))+"px";
$('carrusel').style.visibility="visible";

//Posiciono los botones
$('izda').style.left=(sangria+10)+"px";
$('dcha').style.left=(sangria-50+page_width)+"px";
mostrarbotones();

//Posiciono las sombras
$('sombra_izda').style.width=sangria+'px';
$('sombra_dcha').style.width=sangria+'px';
$('sombra_dcha').style.left=(sangria+page_width)+'px';

}




function scr_width()
{
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			return window.innerWidth-18;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			return document.body.offsetWidth;
		}
	}
}

function scr_height()
{
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			return window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			return document.body.offsetHeight;
		}
	}
}



Event.observe(window, 'load', posicionar_fotoshow, false);
Event.observe(window, 'resize', posicionar_fotoshow, false);


function mov_izda()
{
	if (actual+1<foto_file.length) {
		capa=document.getElementById('carrusel');
		new Effect.Move( capa,  { x: -(page_width*(actual+1))+sangria, y: 0, duration: 1, mode: 'absolute'} );
		
		//Justifico las fotos dentro de la diapo
		//La que est centrada y se va pos la izda la justifico a la dcha
		capa=document.getElementById('foto'+actual);
		new Effect.Move( capa,  { x: page_width-(2*page_margin)-foto_width[actual], y: 0, duration: 1, mode: 'absolute'} );
		//La que entra por la dcha, la centro
		capa=document.getElementById('foto'+(actual+1));
		new Effect.Move( capa,  { x: (page_width-(2*page_margin)-foto_width[actual+1])/2, y: 0, duration: 1, mode: 'absolute'} );

		actual++;
		
		mostrarbotones();
	}
}

function mov_dcha()
{
	if (actual>0) {
		capa=document.getElementById('carrusel');
		new Effect.Move( capa,  { x: -(page_width*(actual-1))+sangria, y: 0, duration: 1, mode: 'absolute'} );

		//Justifico las fotos dentro de la diapo
		//La que est centrada y se va pos la dcha la justifico a la izda
		capa=document.getElementById('foto'+actual);
		new Effect.Move( capa,  { x: 0, y: 0, duration: 1, mode: 'absolute'} );
		//La que entra por la izda, la centro
		capa=document.getElementById('foto'+(actual-1));
		new Effect.Move( capa,  { x: (page_width-(2*page_margin)-foto_width[actual-1])/2, y: 0, duration: 1, mode: 'absolute'} );

		actual--;

		mostrarbotones();
	}
}


function mostrarbotones()
{
	//Muestro u oculto botones
	if (actual>0) {
		$('izda').style.visibility="visible";
		$('sombra_izda').style.visibility="visible";
	} else {
		$('izda').style.visibility="hidden";
		$('sombra_izda').style.visibility="hidden";
	}
	if (actual+1<foto_file.length) {
		$('dcha').style.visibility="visible";
		$('sombra_dcha').style.visibility="visible";
	} else {
		$('dcha').style.visibility="hidden";
		$('sombra_dcha').style.visibility="hidden";
	}
}






























function mover(cual,hacia)
{

movi_1=(hacia==0?-1:1);
actual=actual-movi_1;
movi_1=movi_1*page_width;
//muevo las fotos
efecto_mover('fotos',movi_1,0,1,'true');

//muevo la 2 que es la rara
capa=document.getElementById('foto2');
switch (actual)
	{
	case 1:
		efecto_opacidad('foto1', .2, 1, 1,'true');
		new Effect.Move( capa,  { x: 0, y: 0, duration: 1, mode: 'absolute'} );
		efecto_opacidad('foto2', 1, .2, 1,'true');
		break;
	case 2:
		efecto_opacidad('foto2', .2, 1, 1,'true');
		new Effect.Move( capa,  { x: 100, y: 0, duration: 1, mode: 'absolute'} );
		efecto_opacidad('foto1', 1, .2, 1,'true');
		efecto_opacidad('foto3', 1, .2, 1,'true');
		break;
	case 3:
		efecto_opacidad('foto3', .2, 1, 1,'true');
		new Effect.Move( capa,  { x: 210, y: 0, duration: 1, mode: 'absolute'} );
		efecto_opacidad('foto2', 1, .2, 1,'true');
		break;
	}

}

