
function popUp(url, ancho, alto, redimensionable){
	
	anchoPantalla 	= $(window).width();
	altoPantalla	= $(window).height();
	izq 			= 	(	(parseInt(anchoPantalla) - parseInt(ancho)) / 2	);	
	arriba 			= 	(	(parseInt(altoPantalla) - parseInt(alto)) / 2);		
		
	vPopUp = window.open(url,"miPopUp","dependent=yes,toolbar=no,location=no,directory=no,status=no,menubar=no,scrollbars=yes,resizable="+redimensionable+",top=" + arriba + ",left=" + izq + ",width=" + ancho + ",height=" + alto);
	vPopUp.focus();
}	


function cambiaFoto(foto){	
	imagen.src 		= foto;
	if(imagen.complete){
		rediImagen(foto);
	}else{
		setTimeout('cambiaFoto(\''+ foto + '\')', 1000);
	}	
}

function rediImagen(foto){
	if(imagen.height >= imagen.width){//si la foto es vertical
		$("#fotoPrincipal").height("234px");
		anchoPropFoto = parseInt((imagen.width*234)/imagen.height);
		$("#fotoPrincipal").width(anchoPropFoto + "px");
		
	}else{//si la foto es horizontal
		altoPropFoto = parseInt((imagen.height*$(".cargafoto").width())/imagen.width);		
		if(altoPropFoto > 234){
			$("#fotoPrincipal").height("234px");
			anchoPropFoto = parseInt((imagen.width*234)/imagen.height);
			$("#fotoPrincipal").width(anchoPropFoto + "px");
			//debug(":: " + $(".cargafoto").width());
		}else{
			//$("#fotoPrincipal").attr("width", "100%");
			$("#fotoPrincipal").width("100%");
			$("#fotoPrincipal").height("");
		}
	}
	$("#fotoPrincipal").attr("src", foto);	
}


function cambiaFotoLarge(foto){	
	imagenLarge 		= new Image;
	imagenLarge.src 	= foto;					
	if(imagenLarge.complete){
		$("#contenedorImagen").animate({
			height: imagenLarge.height
		}, 100);					
	}		
	$("#fotoPrincipal").attr("src", foto);
}



var slideFoto 	= function(){
	if(!bloqueo){				
		$("#padreFotoPrincipal").blur();
		if(posicionActual >= liCarrusel.length) return;
		bloqueo 	= true;
		///////////////////////////				
		var imagenSlide 	= new Image;
		imagenSlide.src 	= liCarrusel[posicionActual].url;	
		
		if(imagenSlide.height){
			$("#contenedorImagen").animate({
				height: imagenSlide.height
			}, 100);			
		}else{
			imagenSlide.onload 	= function(){
				$("#contenedorImagen").animate({
					height: imagenSlide.height
				}, 100);
			}		
		}

		///////////////////////////
		$("#padreFotoPrincipal").prepend('<img src="' + liCarrusel[posicionActual].url + '" id="fotoTemp" style="display:none; position:absolute"  />');//  	id="fotoPrincipal"
		$("#fotoPrincipal").fadeOut("slow", function(){
			$("#fotoPrincipal").remove();					
		});
		$("#fotoTemp").fadeIn("slow", function(){
			$("#fotoTemp").css("position", "relative");	
			$("#fotoTemp").attr("id","fotoPrincipal");
			bloqueo 	= false;
		});				
		if(posicionActual < liCarrusel.length -1) 		posicionActual++;
		else 											posicionActual = 0;
	}
}

