var srcFoto1 = ''
var nombreFoto1 = ''
var srcFoto2 = ''
var nombreFoto2 = ''
var srcFoto3 = ''
var nombreFoto3 = ''
var srcFoto4 = ''
var nombreFoto4 = ''

function fncInicio() {
	//Ini****************************************	
	Dyn_fncEnviarTraerDatos("rn_home.asp",2,"FotosPromocion",'','', '','fncCargarFotos')	
	Dyn_fncEnviarTraerDatos("rn_home.asp",1,"Promocion",'','',"divCasaPromo",'fncAsignaNombre')
	//Fin****************************************
}

function fncCargarFotos(root) {	
	document
	var ahora = new Date()  
	var incremento = 0
	var segundos = 0
	var decena = 0
	var unidad = 0
	var foto1 = 0
	var foto2 = 1
	var foto3 = 2
	var foto4 = 3
	var cantFotos = 0
	cantFotos = root.getElementsByTagName('Cantidad')[0].childNodes.item(0).data - 1
	foto1 = aleatorio(0,cantFotos)
	foto2 = aleatorio(0,cantFotos)
	while (foto2 == foto1) {
		foto2 = aleatorio(0,cantFotos)
	}
	foto3 = aleatorio(0,cantFotos)
	while (foto3 == foto1 || foto3 == foto2) {
		foto3 = aleatorio(0,cantFotos)
	}
	foto4 = aleatorio(0,cantFotos)
	while (foto4 == foto1 || foto4 == foto2  || foto4 == foto3) {
		foto4 = aleatorio(0,cantFotos)
	}
	srcFoto1 = root.getElementsByTagName('Foto')[foto1].childNodes.item(0).data
	nombreFoto1 = root.getElementsByTagName('Nombre')[foto1].childNodes.item(0).data
	widthFoto1 = root.getElementsByTagName('Width')[foto1].childNodes.item(0).data
	heightFoto1 = root.getElementsByTagName('Height')[foto1].childNodes.item(0).data		
	srcFoto2 = root.getElementsByTagName('Foto')[foto2].childNodes.item(0).data
	nombreFoto2 = root.getElementsByTagName('Nombre')[foto2].childNodes.item(0).data
	widthFoto2 = root.getElementsByTagName('Width')[foto2].childNodes.item(0).data
	heightFoto2 = root.getElementsByTagName('Height')[foto2].childNodes.item(0).data	
	srcFoto3 = root.getElementsByTagName('Foto')[foto3].childNodes.item(0).data
	nombreFoto3 = root.getElementsByTagName('Nombre')[foto3].childNodes.item(0).data
	widthFoto3 = root.getElementsByTagName('Width')[foto3].childNodes.item(0).data
	heightFoto3 = root.getElementsByTagName('Height')[foto3].childNodes.item(0).data	
	srcFoto4 = root.getElementsByTagName('Foto')[foto4].childNodes.item(0).data
	nombreFoto4 = root.getElementsByTagName('Nombre')[foto4].childNodes.item(0).data
	widthFoto4 = root.getElementsByTagName('Width')[foto4].childNodes.item(0).data
	heightFoto4 = root.getElementsByTagName('Height')[foto4].childNodes.item(0).data

	srcFoto1 = srcFoto1.replace(/@@@/g,"&");	
	srcFoto2 = srcFoto2.replace(/@@@/g,"&");
	srcFoto3 = srcFoto3.replace(/@@@/g,"&");
	srcFoto4 = srcFoto4.replace(/@@@/g,"&");

	document.getElementById("imgFoto1").src = srcFoto1
	document.getElementById("imgFoto2").src = srcFoto2
	document.getElementById("imgFoto3").src = srcFoto3
	document.getElementById("imgFoto4").src = srcFoto4
	
	document.getElementById("imgLoadingFoto1").style.display = 'none'
	document.getElementById("imgFoto1").style.display = ''
	document.getElementById("imgLoadingFoto2").style.display = 'none'
	document.getElementById("imgFoto2").style.display = ''
	document.getElementById("imgLoadingFoto3").style.display = 'none'
	document.getElementById("imgFoto3").style.display = ''
	document.getElementById("imgLoadingFoto4").style.display = 'none'
	document.getElementById("imgFoto4").style.display = ''
	
	if (parseFloat(widthFoto1) > parseFloat(heightFoto1)) {		
		document.getElementById("imgFoto1").width = 187
		document.getElementById("imgFoto1").height = 120
		document.getElementById("bordefoto1").style.backgroundImage = "url(images/borde_foto.gif)"
	}
	else {	
		document.getElementById("imgFoto1").width = 77
		document.getElementById("imgFoto1").height = 120
		document.getElementById("bordefoto1").style.backgroundImage = "url(images/borde_foto_p.gif)"
	}
	if (parseFloat(widthFoto2) > parseFloat(heightFoto2)) {		
		document.getElementById("imgFoto2").width = 60
		document.getElementById("imgFoto2").height = 38
		document.getElementById("imgFoto2").style.marginLeft = "7px"
		document.getElementById("bordefoto2").style.backgroundImage = "url(images/borde_foto_chico.gif)"
	}
	else {		
		document.getElementById("imgFoto2").width = 24
		document.getElementById("imgFoto2").height = 38
		document.getElementById("imgFoto2").style.marginLeft = "25px"
		document.getElementById("bordefoto2").style.backgroundImage = "url(images/borde_foto_chico_p.gif)"
	}
	if (parseFloat(widthFoto3) > parseFloat(heightFoto3)) {		
		document.getElementById("imgFoto3").width = 60
		document.getElementById("imgFoto3").height = 38
		document.getElementById("imgFoto3").style.marginLeft = "7px"
		document.getElementById("bordefoto3").style.backgroundImage = "url(images/borde_foto_chico.gif)"
	}
	else {		
		document.getElementById("imgFoto3").width = 24
		document.getElementById("imgFoto3").height = 38
		document.getElementById("imgFoto3").style.marginLeft = "25px"
		document.getElementById("bordefoto3").style.backgroundImage = "url(images/borde_foto_chico_p.gif)"
	}
	if (parseFloat(widthFoto4) > parseFloat(heightFoto4)) {		
		document.getElementById("imgFoto4").width = 60
		document.getElementById("imgFoto4").height = 38
		document.getElementById("imgFoto4").style.marginLeft = "7px"
		document.getElementById("bordefoto4").style.backgroundImage = "url(images/borde_foto_chico.gif)"
	}
	else {		
		document.getElementById("imgFoto4").width = 24
		document.getElementById("imgFoto4").height = 38
		document.getElementById("imgFoto4").style.marginLeft = "25px"
		document.getElementById("bordefoto4").style.backgroundImage = "url(images/borde_foto_chico_p.gif)"
	}
	
	document.getElementById("AutorFoto").innerHTML = nombreFoto1
}

function fncAsignaNombre(root) {
}	

function aleatorio(inferior,superior){
	numPosibilidades = superior - inferior
	aleat = Math.random() * numPosibilidades
	aleat = Math.round(aleat)
	return parseInt(inferior) + aleat
} 

function fncSelFoto(id) {
	var fotoTMP
	var nombreTMP
	var anchoTMP
	fotoTMP = document.getElementById("imgFoto1").src
	anchoTMP = document.getElementById("imgFoto1").width
	document.getElementById("imgFoto1").src	= document.getElementById(id).src
	document.getElementById(id).src = fotoTMP
	switch (id) {
	case 'imgFoto2':
		nombreTMP = document.getElementById("AutorFoto").innerHTML;
		document.getElementById("AutorFoto").innerHTML = nombreFoto2;
		nombreFoto2 = nombreTMP;
		if (document.getElementById("imgFoto2").width == 24) {
			document.getElementById("imgFoto1").width = 77
			document.getElementById("bordefoto1").style.backgroundImage = "url(images/borde_foto_p.gif)"
		}
		else {
			document.getElementById("imgFoto1").width = 187
			document.getElementById("bordefoto1").style.backgroundImage = "url(images/borde_foto.gif)"
		}
		if (anchoTMP == 77) {
			document.getElementById("imgFoto2").width = 24
			document.getElementById("imgFoto2").style.marginLeft = "25px"
			document.getElementById("bordefoto2").style.backgroundImage = "url(images/borde_foto_chico_p.gif)"
		}
		else {
			document.getElementById("imgFoto2").width = 60
			document.getElementById("imgFoto2").style.marginLeft = "7px"
			document.getElementById("bordefoto2").style.backgroundImage = "url(images/borde_foto_chico.gif)"
		}
		break;
	case 'imgFoto3':
		nombreTMP = document.getElementById("AutorFoto").innerHTML;
		document.getElementById("AutorFoto").innerHTML = nombreFoto3;
		nombreFoto3 = nombreTMP;
		if (document.getElementById("imgFoto3").width == 24) {
			document.getElementById("imgFoto1").width = 77
			document.getElementById("bordefoto1").style.backgroundImage = "url(images/borde_foto_p.gif)"
		}
		else {
			document.getElementById("imgFoto1").width = 187
			document.getElementById("bordefoto1").style.backgroundImage = "url(images/borde_foto.gif)"
		}
		if (anchoTMP == 77) {
			document.getElementById("imgFoto3").width = 24
			document.getElementById("imgFoto3").style.marginLeft = "25px"
			document.getElementById("bordefoto3").style.backgroundImage = "url(images/borde_foto_chico_p.gif)"
		}
		else {
			document.getElementById("imgFoto3").width = 60
			document.getElementById("imgFoto3").style.marginLeft = "7px"
			document.getElementById("bordefoto3").style.backgroundImage = "url(images/borde_foto_chico.gif)"
		}
		break;
	case 'imgFoto4':
		nombreTMP = document.getElementById("AutorFoto").innerHTML;
		document.getElementById("AutorFoto").innerHTML = nombreFoto4;
		nombreFoto4 = nombreTMP;
		if (document.getElementById("imgFoto4").width == 24) {
			document.getElementById("imgFoto1").width = 77
			document.getElementById("bordefoto1").style.backgroundImage = "url(images/borde_foto_p.gif)"
		}
		else {
			document.getElementById("imgFoto1").width = 187
			document.getElementById("bordefoto1").style.backgroundImage = "url(images/borde_foto.gif)"
		}
		if (anchoTMP == 77) {
			document.getElementById("imgFoto4").width = 24
			document.getElementById("imgFoto4").style.marginLeft = "25px"
			document.getElementById("bordefoto4").style.backgroundImage = "url(images/borde_foto_chico_p.gif)"
		}
		else {
			document.getElementById("imgFoto4").width = 60
			document.getElementById("imgFoto4").style.marginLeft = "7px"
			document.getElementById("bordefoto4").style.backgroundImage = "url(images/borde_foto_chico.gif)"
		}
		break;
	}
}
