//variables del slideshow

function fotografia(imagen,ventana_w,ventana_h) {
	// respecto al fichero que llama a la funcion
	var ficherodestino = 'fotografia.htm#'
	var remote = window.open( ficherodestino + imagen , "Fotografia" + get_random(99999) , "width=" + ventana_w + ",height=" + ventana_h + ",resizable=no,scrollable=yes,scrollbars=no,menubar=no,status=no,toolbar=no,location=no,directories=no");
}

function runSlideShow() {
	if (document.all) {
		document.images.SlideShow.style.filter="blendTrans(duration=2)";
		document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
		document.images.SlideShow.filters.blendTrans.Apply();
	}
	document.images.SlideShow.src = preLoad[j].src;
	if (document.all) {
		document.images.SlideShow.filters.blendTrans.Play();
	}
	j = j + 1;
	if (j > (p - 1)) j = 0;
	t = setTimeout('runSlideShow()', slideShowSpeed);
}
function abrirVentana(imagen,ventana_w,ventana_h) {
// respecto al fichero que llama a la funcion
var ficherodestino = 'fotografia.htm#'
var nombreVentana = imagen;
nombreVentana = nombreVentana.replace('_','');
nombreVentana = nombreVentana.replace(' ','');
nombreVentana = nombreVentana.replace('.','');
var remote = window.open( ficherodestino + imagen , nombreVentana , "width=" + ventana_w + ",height=" + ventana_h + ",resizable=no,scrollable=yes,scrollbars=no,menubar=no,status=no,toolbar=no,location=no,directories=no");
}

function get_random(numero)
{
    var ranNum= Math.round(Math.random()*numero);
    return ranNum;
}

function autoAmplia (mi_imagen) {
	imageSrc  = mi_imagen.src;
	imagePath = imageSrc.substring(0,imageSrc.lastIndexOf('/'));
	imageName = imageSrc.substring(imageSrc.lastIndexOf('/')+1,imageSrc.length);
	imageOnlyName = imageName.substring(0,imageName.lastIndexOf('.'));
	imageW = vDecode(imageOnlyName.substring(imageOnlyName.length-4 ,imageOnlyName.length-2));
	imageH = vDecode(imageOnlyName.substring(imageOnlyName.length-2 ,imageOnlyName.length));
	abrirVentana(imageName,imageW,imageH);
}

function vEncode (numero) {
	//Produce 2 'bytes'
	var encodingValues = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
	var base = encodingValues.length;
	vCoded = '';
	vCoded = encodingValues.substr(parseInt(numero / base),1) + vCoded + encodingValues.substr(parseInt(numero % base),1);
	return vCoded;
	}
	
function vDecode (cadena) {
	//Se asume que la cadena es de longitud 2
	var encodingValues = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
	var base = encodingValues.length;
	vDecoded = -1;
	vDecoded = (encodingValues.indexOf(cadena.substr(0,1))*base)+(encodingValues.indexOf(cadena.substr(1,1)));
	return vDecoded;
	}
