
// Carga de fotos flash
function cargaFotos() {
	var oFlash = window.document.fotosFlash;	
	if (typeof(oFlash) != "undefined") oFlash.TCallLabel("/", "carga");
}

// -----------------------------------------------------------------------------------------
// Rutinas cambio de fotos
// -----------------------------------------------------------------------------------------
var numFotoActual = 0;
var numContenedorFotoP = 0;

function cargaFotoMediana(numFoto) {
	
	numFotoActual = numFoto;
	
	// Cambia foto mediana
	var img = "../../img/fotos/medianas/" + "foto"+numFotoActual+".jpg";
	document.images['imgMediana'].src = img;
}

function overFotoP(numFoto, numContenedor) {
	if (numFotoActual != numFoto) {
		var imgP = "../../img/fotos/pequenas/" + "foto"+numFoto+"_.jpg";
		var contP = "imgP"+numContenedor;
		document.images[contP].src = imgP;
	}
}

function cargaFotoMediana2(numFoto, numContenedor) {
	
	// Restaura imagen anterior
	if (numFotoActual != 0) {
		var imgAnterior = "../../img/fotos/pequenas/" + "foto"+numFotoActual+".jpg";
		var contAnterior = "imgP"+numContenedorFotoP;
		document.images[contAnterior].src = imgAnterior;
	}
	
	numFotoActual = numFoto;
	numContenedorFotoP = numContenedor;
	
	// Cambia foto pequeña
	var imgP = "../../img/fotos/pequenas/" + "foto"+numFotoActual+"_.jpg";
	var contP = "imgP"+numContenedorFotoP;
	document.images[contP].src = imgP;
	
	// Cambia foto mediana
	var img = "../../img/fotos/medianas/" + "foto"+numFotoActual+".jpg";
	document.images['imgMediana'].src = img;
}

function overFotoP(numFoto, numContenedor) {
	if (numFotoActual != numFoto) {
		var imgP = "../../img/fotos/pequenas/" + "foto"+numFoto+"_.jpg";
		var contP = "imgP"+numContenedor;
		document.images[contP].src = imgP;
	}
}

function outFotoP(numFoto, numContenedor) {
	if (numFotoActual != numFoto) {
		var imgP = "../../img/fotos/pequenas/" + "foto"+numFoto+".jpg";
		var contP = "imgP"+numContenedor;
		document.images[contP].src = imgP;
	}
}

function cargaFotoGrande() {
	if (numFotoActual != 0) {
		abreFoto("../popupFoto.htm","../img/fotos/grandes/foto"+numFotoActual+".jpg");
	}
}

function cargaFotoGrande2(numFoto) {
	numFotoActual = numFoto;
	
	if (numFotoActual != 0) {
		abreFoto("../popupFoto.htm","../img/fotos/grandes/foto"+numFotoActual+".jpg");
	}
}

// -----------------------------------------------------------------------------------------
// Fin rutinas cambio de fotos
// -----------------------------------------------------------------------------------------


// Valida formulario contacto
function valida(){
	var resultado = true;
	var cadena = "Debe rellenar correctamente los siguientes campos: \n\n";
	
	var f = document.forms[0];
	
	nombre = f.nombre.value;
	telefono = f.telefono.value;
	email = f.email.value;
	comentarios = f.comentarios.value;


	
	if (nombre ==""){ resultado=false; cadena+=" - Nombre sin rellenar \n" }
	if (email ==""){ resultado=false; cadena+=" - E-mail sin rellenar \n" }
	if (telefono ==""){ resultado=false; cadena+=" - Teléfono sin rellenar \n" }



	if (resultado == false) {
		alert(cadena);
	} else {
		f.submit();
	}
}


// Abre el popup del vr
function abreVR() {
	v=window.open('vr/index.html','vr','toolbar=no,location=0,directories=no,menubar=no,scrollbars=no,resizable=no,width=424,height=256,left=10,top=10');
	v.focus();
}



// Abre un popup con un html y una imagen de un plano dado
function abrePlano(html,foto) {
	v=window.open(html+'?foto='+foto,'popupFoto','width=500,height=350,top=5,left=5,scrollbars=no');
   	v.focus();
}

// Abre un popup de plano
function abrePlano1(nombrePlano) {
	v=window.open('../popUpPlano1.htm?nombrePlano='+nombrePlano,'popupPlano','width=780,height=500,top=5,left=5,scrollbars=no');
   	v.focus();
}


// Abre un popup con un html y una foto dada
function abreFoto(html,foto) {
	v=window.open(html+'?foto='+foto,'popupFoto','width=10,height=10,top=5,left=5,scrollbars=no');
   	v.focus();
}

// Abre un popup con un html y una foto dada
function abreFoto2(html,foto) {
	v=window.open(html+'?foto='+foto,'popupFoto','width=800,height=600,top=5,left=5,scrollbars=yes');
   	v.focus();
}






// Limita caracteres en una cadena
function limiteCaracteres(cadena, total) {
	var cadenaFin = cadena.substr(0, total);
	if (cadenaFin.length < cadena.length) {
		return cadenaFin + " ...";
	} else {
		return cadenaFin;
	}
}

// Funciones control ventana navegador
function wSize() {
	var userAgent = navigator.userAgent;
	var isFirefox = ( userAgent != null && userAgent.indexOf( "Firefox/" ) != -1 );

	if(navigator.appName == "Netscape") {
		iAlto = window.innerHeight;
		iAncho = window.innerWidth;
		iScrollAncho = document.width + 12;
		iScrollAlto = document.height + 30;
		
		if (isFirefox) {
			if (document.images['foto']) {
				iScrollAncho = (document.images['foto'].width) + 10;
				iScrollAlto = (document.images['foto'].height) + 55;
			} else {
				iScrollAncho = screen.width;
				iScrollAlto = screen.height;
			}
		}
	}

	if (navigator.appVersion.indexOf("MSIE") != -1){
		if (navigator.appVersion.indexOf("Mac") == -1){
			iAncho=document.body.clientWidth;
			iAlto=document.body.clientHeight;
			iScrollAncho = document.body.scrollWidth + 12;
			iScrollAlto = document.body.scrollHeight + 30;
		}
 	}
	myWidth = iScrollAncho;
	myHeight = iScrollAlto;
	return [myWidth, myHeight];
}

function escalaVentana() {
	sizeTemp = wSize();
	ancho = sizeTemp[0];
	alto = sizeTemp[1];
	window.resizeTo(ancho,alto);
}


