// FUNCIONES DIVERSAS

var nombrevisible = "visible";
var nombrescondido = "hidden";

// ------------------------------------------------------>
// Abre la ventanita que muestra cada edificio en planta
function abrepiso(piso)
{
	var ventana = "../"+piso+"/"+piso+".html"; 
	window.open( ventana, piso, "toolbar=0, location=0, directories=0, menuBar=0, scrollbars=1, resizable=1, width=625, height=470, left=2, top=60");
}
// ------------------------------------------------------>
// FUNCIONES DE GESTIONAR PASO DEL RATON SOBRE LOS BOTONES
function apaga_boton(cual)
{
	var color_letras = "#FFFFA7";
	var color_fondo = "#6672A6";
	colorea_boton( cual, color_letras, color_fondo );
	return false;
}
// ------------------------------------------------------>
function enciende_boton(cual)
{
	var color_letras = "#2255FF";
	var color_fondo = "#FFFFAA";
	colorea_boton( cual, color_letras, color_fondo );
	return false;
}
// ------------------------------------------------------>
function aprieta_boton(cual)
{
	var color_letras = "#2255FF";
	var color_fondo = "#FFAA55";
	colorea_boton( cual, color_letras, color_fondo );
	return false;
}
// ------------------------------------------------------>
function suelta_boton(cual)
{
	var color_letras = "#2255FF";
	var color_fondo = "#FF5500";
	colorea_boton( cual, color_letras, color_fondo );
	return false;
}
// ------------------------------------------------------>
function colorea_boton( cual, color_letras, color_fondo )
{
	if (BOTONES[cual]) {
		if (ns4) {
			BOTONES[cual].color = color_letras; 
			BOTONES[cual].backgroundColor = color_fondo;
		}
		else {
			BOTONES[cual].style.color = color_letras;
			BOTONES[cual].style.backgroundColor = color_fondo;
		}
	}
	return false;
}
// ------------------------------------------------------>
// Cambia el gráfico en curso de un elemento dado del documento (cual)
// por un nuevo gráfico (nuevo). Se la llama desde onMouseover y 
// onMouseout.
function cambia_grafico(cual,nuevo)
{
     document.images[cual].src = nuevo;
}
// ------------------------------------------------------>
// Coloca los "postit" de los mapas.
function cuentame(elque)
{
	var tiempo;

	if ( elque != "" ) {
		layeroff( postit );
		layeron( elque );
	}

	tiempo = 800;
	layeroff( postit+'rel');
	layeron( elque+'rel');
	muestrarel = true;

	if (ns4) {
		setTimeout( "layeroff( '"+elque+"_rel')", tiempo);
	}
	else {
		setTimeout( "muestrarel = false;" , tiempo );
	}

	postit = elque;
	return false;
}
// ------------------------------------------------------>
function layeron(elque)
{
	if ( elque != "" ) {
		if (ns4) {
			if ( capas[elque] ) capas[elque].visibility = nombrevisible;
		}
		else if (msie) {
			if ( capas[elque] ) capas[elque].style.visibility = nombrevisible;
		}
		else {
			if ( document.getElementById(elque) )
				document.getElementById(elque).style.visibility = nombrevisible;
		}
	}
	return false;
}
// ------------------------------------------------------>
function layeroff(elque)
{
	if ( elque != "" ) {
		if (ns4) {
			if ( capas[elque] ) capas[elque].visibility = nombrescondido;
		}
		else if (msie) {
			if ( capas[elque] ) capas[elque].style.visibility = nombrescondido;
		}
		else {
			if ( document.getElementById(elque) )
				document.getElementById(elque).style.visibility = nombrescondido;
		}
	}
	return false;
}
// ------------------------------------------------------>
function layertest( elque )
{
	if ( elque != "" ) {
		if (ns4) {
			if ( capas[elque] ) return capas[elque].visibility;
		}
		else if (msie) {
			if ( capas[elque] ) return capas[elque].style.visibility;
		}
		else {
			if ( document.getElementById(elque) )
				return document.getElementById(elque).style.visibility;
		}
	}
	return "error"
}
//-------------------------------------------------------->
// ESTA FUNCION HACE DESAPARECER LA ILUMINACION
// DE LOS CAMINOS DE LOS MAPAS. ES LLAMADA POR 
// LOS DOS MAPAS.
function nada()
{
	if (postit != 'esquina' ) {
		if ( layertest( postit+'rel' ) == nombrevisible ) {
			if ( muestrarel == false ) {
				layeroff( postit+'rel' );
			}
		}
	}
}
//-------------------------------------------------------->
// Precarga los planos internos de los edificios.
function creamatriz(n) {
         this.length = n
         for (var i = 0; i<=n; i++) {
             this[i] = new Image()
         }
         return this
}
function preload_planos()
{
   	var imagenes = new creamatriz(12);
	var indice = 0;
	var i;

	for ( i=2; i<=7; i++) {
		imagenes[indice++].src = "../plano"+i+"/plano"+i+".gif";
	}
	for ( i=2; i<=5; i++) {
		imagenes[indice++].src = "../plano"+i+"/plano"+i+"m.gif";
	}
}

//-------------------------------------------------------->
// FUNCION DE DETECTAR EL NAVEGADOR.
function detecta_navegador()
{
	if ( document.all ) {
		// Navegador MicroSoft
		msie = true;
	}
	else if ( document.layers ) {
		// Navegador de la familia Netscape 4 y similares.
		ns4 = true; 
		nombrevisible = "show";
		nombrescondido = "hide";
	}
	else {
		// Navegador compliant DOM (Document Object Model).
		domc = true;
	}
	return false;
}
// ------------------------------------------------------>
// Abre una ventana cargando un URL dado por "adonde" en cuyo nombre 
// ha de figurar el string 'XX', que será reemplazado por '600', '800' o '1000'
// dependiendo de la resolución del video.
function salta_auto( adonde )
{
	var sw = screen.width;
	var res;
	var cual;
	var pos;

	// Si no se sabe la velocidad de conexión, es que ni hay cookie,
	// ni el usuario ha esperado a que baje la portada. Hace falta
	// que espere un poquito.
	if ( velocidad == 0 ) {
		alert('Espere a que acabe de bajar la portada. Gracias'); 
		return false; 
	} 

	if (sw > 800) 
		res = "1000";
	else if (sw <= 800)
		res = "800";
	else
		res = "600";

	cual = adonde.replace( /XX/gi, res );
	cual = cual.replace( /XX/gi, res ); // ESTA ES POR EL KONQUEROR
	cual = cual+'?';
	window.open( cual, "langrewin", "toolbar=0, location=0, directories=0, menuBar=0, scrollbars=1, resizable=1, left=1, top=1");
}
// ------------------------------------------------------>
// Fuerza la recarga de otra página (donde) en la ventana en curso, apagando
// el botón de turno (cual), salvo que ya se esté en la misma, en cuyo caso
// da un mensaje de aviso.
function vetea(donde, cual)
{
	if ( donde != nombre ) {
//		apaga_boton(cual);
		document.location = donde;
	}
	else {
		alert ( "Ya está Ud. en la página solicitada" );
	}
	return false;
}
// ------------------------------------------------------>
// Recarga la pagina si se redimensiona la ventana. Es por bugs en NetScape
// y Konqueror que descolocan toda la página al estirar o encoger la ventana.
function waNetscapeResize() {
	location.reload ();
	return false;
}

// ================= FUNCIONES DE ROTULITO FLOTANTE ==============
// =============== QUE APARECE Y SE MUEVE CON EL RATON ===========

// Mover capa móvil con el ratón.
function mouseMove(el) {

  if ( ns4 ) {
     x=el.pageX; 
     y=el.pageY;
  }
  else if ( msie ) {
     x=event.x; 
     y=event.y;
  }
  else {
     x=el.pageX; 
     y=el.pageY;
  }
  nautilus.left = x-100;
  nautilus.top = y-100;
}
// ------------------------------------------------------>
// Activar visibilidad de capa móvil 'c' (que debe ser el ID de un DIV)
// Asignamos a 'nautilus' el elemento que corresponda, según el tipo
// de navegador, de forma que a la hora de hacerla desaparecer no 
// haya que hacer referencia de nuevo al elemento de que se trata.

function emerge(c) {
	if (ns4){
		nautilus = document.layers[c];
	} 
	else if (msie) {
		nautilus = document.all[c].style
	}
	else {
		nautilus = document.getElementById(c).style
	}
	nautilus.visibility=nombrevisible;
	document.onmousemove = mouseMove
}
// ------------------------------------------------------>
// Desactivar visibilidad de capa móvil (nautilus).
function sumerge() {

	nautilus.visibility = nombrescondido;

	// Anular evento al esconder la capa flotante.
	if (ns4) {
		releaseEvents(Event.MOUSEMOVE)
	}
	document.onmousemove=""
}
// ------------------------------------------------------>
function estilo() {

	var sw = screen.width;

	if (sw > 800) {
		estilo1000();
	}
	else if (sw <= 800) {
		estilo800();
	}
	return false;
}
// ------------------------------------------------------------->
function estilo800() {
	document.write("<STYLE text/css>");
	document.write( ".botones { HEIGTH: 13px; border: solid #000000 1px; PADDING: 1px; font-weight: bold; text-decoration: none; color: #FFFFA7; ");
	if (ns4) {
		document.write( " font-family: verdana; background-color: #E0E0E0; TOP: 3px; font-size: 55%; }");
		// FIN DE DEFINICION DE .botones
 		document.write( "A:link {text-decoration: none; font-family: verdana; color: #5050CC }");
 		document.write( "A:visited {text-decoration: none; font-family: verdana; color: #5050CC} ");
		document.write( "DIV { font-family: 'verdana'; font-size: 70%; } ");
		document.write("U {color: #AE5700; font-family: verdana; font-size: 115%; font-weight: bold;}");
		document.write(".espostit {POSITION: absolute; PADDING: 1px; TOP: 30px; LEFT: 5px; WIDTH: 225px; font-family: verdana; font-size: 55%; text-align: left; background-color: #FFFFDD; border: solid #9999DD 1px; padding: 3px}");
		document.write( ".tablas { font-family: verdana; font-size: 80%; background-color: #FFFFDD; border: solid #AAAAFF 1px; padding: 3px} " );
	     document.write( ".quienes1 { font-family: verdana; font-size: 75%} " );
	}
	else if ( (navigator.userAgent).indexOf( "Konqueror/2" ) > 0 ) {
		document.write( " font-family: arial; background-color: #A0A0A0; TOP: 7px;  font-size: 110%; cursor: hand}");
		// FIN DE DEFINICION DE .botones
 		document.write( "A:link {text-decoration: none; font-family: verdana; color: #5050CC }");
 		document.write( "A:visited {text-decoration: none; font-family: verdana; color: #5050CC} ");
		document.write( "DIV { font-family: 'verdana'; font-size: 70%; } ");
		document.write("U {color: #AE5700; font-family: verdana; font-size: 145%; font-weight: bold;}");
		document.write(".espostit {POSITION: absolute; PADDING: 1px; TOP: 50px; LEFT: 10px; WIDTH: 265px; font-family: verdana; font-size: 95%; text-align: justify; }");
		document.write( ".tablas { font-family: verdana; font-size: 80%; background-color: #FFFFDD; border: solid #AAAAFF 1px; padding: 3px} " );
	     document.write( ".quienes1 { font-family: verdana; font-size: 75%} " );
	}
	else {  // MSIE
		document.write( " font-family: verdana; background-color: #6672A6; TOP: 7px;  font-size: 65%; cursor: hand}");
		// FIN DE DEFINICION DE .botones
 		document.write( "A:link {text-decoration: none; font-family: verdana; color: #5050CC }");
 		document.write( "A:visited {text-decoration: none; font-family: verdana; color: #5050CC} ");
		document.write( "DIV { font-family: 'verdana'; font-size: 70%; } ");
		document.write( "U {color: #AE5700; font-family: verdana; font-size: 110%; font-weight: bold;}");
		document.write( ".espostit {POSITION: absolute; PADDING: 1px; TOP: 35px; LEFT: 5px; WIDTH: 225px; font-family: verdana; font-size: 65%; text-align: left; background-color: #FFFFDD; border: solid #AAAAFF 1px; padding: 3px }");
		document.write( ".tablas { font-family: verdana; font-size: 80%; background-color: #FFFFDD; border: solid #AAAAFF 1px; padding: 3px} " );
	     document.write( ".quienes1 { font-family: verdana; font-size: 75%} " );
	}
	document.write("</style>")
}
// -------------------------------------------------------------------->
function estilo1000(){
	document.write("<STYLE text/css>");
	document.write( ".botones { HEIGTH: 17px; border: solid #000000 1px; PADDING: 3px; font-weight: bold; text-decoration: none; color: #FFFFA7; ");
	if (ns4) { // NetScape 4 y similares
		document.write( " font-family: verdana; background-color: #E0E0E0; TOP: 4px; font-size: 70%; }");
		// FIN DE DEFINICION DE .botones
 		document.write( "A:link {text-decoration: none; font-family: 'Arial'; font-weight: bold}");
 		document.write( "A:visited {text-decoration: none; color: #0000C8} ");
		document.write( "DIV { font-family: 'verdana'; font-size: 75%} ");
		document.write( "U {color: #AE5700; font-family: verdana; font-size: 105%; font-weight: bold;}");
	     document.write( ".rotulos { color: #0000C8; font-family: arial; font-weight: bold; font-size: 80%} " );
		document.write( ".espostit {POSITION: absolute; PADDING: 1px; TOP: 50px; LEFT: 10px; WIDTH: 265px; font-family: verdana; font-size: 75%; text-align: justify; background-color: #FFFFDD; border: solid #9999DD 1px; padding: 3px }");
		document.write( ".nautilus {position:absolute; width:170; height: 60; left-padding:3; font-family: verdana; font-size: 70%; background-color: #F8F8C0 ; border: solid blue 1px; padding: 3px; visibility:hidden; }" );
		document.write( ".tablas { font-family: verdana; font-size: 80%; background-color: #FFFFDD; border: solid #AAAAFF 1px; padding: 3px} " );
	     document.write( ".quienes1 { font-family: verdana; font-size: 75%} " );
	}
	else if ( (navigator.userAgent).indexOf( "Konqueror/2" ) > 0 ) {
		document.write( " font-family: arial; background-color: #6672A6; TOP: 7px;  font-size: 110%; cursor: hand }");
		// FIN DE DEFINICION DE .botones
		document.write( "A:link { text-decoration: none }" );
		document.write( "A:visited { text-decoration: none }" );
		document.write( "DIV { font-family: verdana; font-size: 110%; } ");
		document.write( "U {color: #AE5700; font-family: verdana; font-size: 120%; font-weight: bold;}");
	     document.write( ".rotulos { color: #0000C8; font-family: verdana; font-weight: bold; font-size: 120%} " );
		document.write( ".espostit {POSITION: absolute; PADDING: 1px; TOP: 50px; LEFT: 10px; WIDTH: 265px; font-family: verdana; font-size: 95%; text-align: justify; background-color: #FFFFDD; border: solid #9999DD 1px; padding: 3px  }");
		document.write( ".nautilus {position:absolute; width:170px; height: 60px; left-padding:3; font-family: verdana; font-size: 70%; background-color: #F8F8C0 ; border: solid blue 1px; padding: 3px; visibility:hidden; }" );
		document.write( ".tablas { font-family: verdana; font-size: 80%; background-color: #FFFFDD; border: solid #AAAAFF 1px; padding: 3px} " );
	     document.write( ".quienes1 { font-family: verdana; font-size: 140%} " );
	}
	else if ( navigator.appName == 'Opera') {
		document.write( " font-family: verdana; background-color: #6672A6; TOP: 9px;  font-size: 75%; cursor: hand }");
		// FIN DE DEFINICION DE .botones
		document.write( "A:link {text-decoration: none; font-family: 'Arial'; font-weight: bold}");
		document.write( "A:visited {text-decoration: none; color: #0000C8} ");
		document.write( "DIV { font-family: 'verdaba'; font-size: 95%; } ");
	     document.write( ".rotulos { color: #0000C8; font-family: arial; font-weight: bold; font-size: 95%} " );
		document.write( ".espostit {POSITION: absolute; PADDING: 1px; TOP: 50px; LEFT: 10px; WIDTH: 265px; font-family: verdana; font-size: 70%; text-align: left; background-color: #FFFFDD; border: solid #AAAAFF 1px; padding: 3px }");
		document.write( ".nautilus {position:absolute; width:170; height: 50; left-padding:3; font-family: verdana; font-size: 70%; background-color: #F8F8C0 ; border: solid blue 1px; padding: 3px; visibility:hidden; }" );
		document.write( ".tablas { font-family: verdana; font-size: 60%; background-color: #FFFFDD; border: solid #AAAAFF 1px; padding: 3px} " );
	     document.write( ".quienes1 { font-family: verdana; font-size: 80%} " );
	}
	else { // MSIE
		document.write( " font-family: verdana; background-color: #6672A6; TOP: 9px;  font-size: 75%; cursor: hand}");
		// FIN DE DEFINICION DE .botones
		document.write( "A:link { text-decoration: none }" );
		document.write( "A:visited { text-decoration: none }" );
		document.write( "DIV { font-family: verdana; font-size: 75%; } ");
		document.write( "U {color: #AE5700; font-family: verdana; font-size: 120%; font-weight: bold;}");
	     document.write( ".rotulos { color: #0000C8; font-family: arial; font-weight: bold; font-size: 90%} " );
		document.write( ".espostit {POSITION: absolute; PADDING: 1px; TOP: 50px; LEFT: 10px; WIDTH: 265px; font-family: verdana; font-size: 70%; text-align: left; background-color: #FFFFDD; border: solid #AAAAFF 1px; padding: 3px }");
		document.write( ".nautilus {position:absolute; width:170; height: 50; left-padding:3; font-family: verdana; font-size: 70%; background-color: #F8F8C0 ; border: solid blue 1px; padding: 3px; visibility:hidden; }" );
		document.write( ".tablas { font-family: verdana; font-size: 80%; background-color: #FFFFDD; border: solid #AAAAFF 1px; padding: 3px}" );
	     document.write( ".quienes1 { font-family: verdana; font-size: 80%} " );
	}
	document.write("</style>")
}

