document.onkeypress = null;

// - IMAGENES - 

  var browserOK = false;
  var pics;

  browserOK = true;
  pics = new Array();

var objCount = 0; // number of (changing) images on web-page

function preload(name, first, second) {  
  if (browserOK) {     
    pics[objCount] = new Array(3);
    pics[objCount][0] = new Image();
    pics[objCount][0].src = first;
    pics[objCount][1] = new Image();
    pics[objCount][1].src = second;
    pics[objCount][2] = name;
    objCount++;
  }
}

function on(name){
  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      if (document.images[pics[i][2]] != null)
        if (name != pics[i][2]) { 
          // set back all other pictures
          document.images[pics[i][2]].src = pics[i][0].src;
        } else {
           // show the second image because cursor moves across this image
           document.images[pics[i][2]].src = pics[i][1].src;
           //alert(document.images[pics[i][2]].src);
        }
    
    }   
    
  }
}

function off(){
  if (browserOK) {
     for (i = 0; i < objCount; i++) {
      // set back all pictures
      if (document.images[pics[i][2]] != null) 
        document.images[pics[i][2]].src = pics[i][0].src;
    }
  }
}

var pong;
function makeArray(n){
  this.length = n;
  for (i=1;i<=n;i++){
    this[i]=0;
  }
  return this;
}

// - MOSTRAR LA FECHA - 

function mostrarFecha() {
  var this_month = new makeArray(12);
  this_month[0]  = "Enero";
  this_month[1]  = "Febrero";
  this_month[2]  = "Marzo";
  this_month[3]  = "Abril";
  this_month[4]  = "Mayo";
  this_month[5]  = "Junio";
  this_month[6]  = "Julio";
  this_month[7]  = "Agosto";
  this_month[8]  = "Septiembre";
  this_month[9]  = "Octubre";
  this_month[10] = "Noviembre";
  this_month[11] = "Diciembre";

  var this_day_e = new makeArray(7);
  this_day_e[0]  = "Domingo";
  this_day_e[1]  = "Lunes";
  this_day_e[2]  = "Martes";
  this_day_e[3]  = "Miércoles";
  this_day_e[4]  = "Jueves";
  this_day_e[5]  = "Viernes";
  this_day_e[6]  = "Sábado";

  var today = new Date();
  var day   = today.getDate();
  var month = today.getMonth();
  var year  = today.getYear();
  var dia = today.getDay();
    if (year < 1000) {
       year += 1900; }
  return( " " + this_day_e[dia] + ", " + day + " de " + this_month[month] + " " + year);
}

// - TEXTO EN LA BARRA DE ESTADO -

//variable con el texto a mostrar
var texto = "Bienvenidos a Castellar de la Muela"
//variable con la posicion en el texto. poner siempre a 0
var pos = 0

//creo una funcion para cambiar el texto de la barra de estado
function textoEstado(){
   //incremento la posicion en 1 y extraigo el texto a mostrar en este momento.
   pos = pos + 1
   textoActual = texto.substring(0,pos)
   //pongo el texto que quiero mostrar en la barra de estado del navegador
   window.status = textoActual
   //Llamamos otra vez a esta funcion para que continue    mostrando texto
   if (pos == texto.length){
      //si hemos llegado al final, vuelvo al principio y hago un retardo superior
      pos = 0
      setTimeout("textoEstado()",1500)
   } else{
      //si no hemos llegado al final, sigo con la funcion con un retardo minimo.
      setTimeout("textoEstado()",100)
   }

}
 function abreVentana(url)
 { 
	var options = 'toolbar=no, location=no, directories=no, status=yes, menubar=no, resizable=no, scrollbars=no,width=805,height=512';
	window.open(url,'ventana',options);
 }		

// Funciones de las fotos

function Visor(foto,estilo)
{
	if (estilo==1)
	{
		// window.document.all.imagen.width=650;
		window.document.all.imagen.width=573;
		window.document.all.imagen.height=430;
	}
	else
	{
		window.document.all.imagen.width=300;
		window.document.all.imagen.height=430;					
	}
	
	var long = foto.src.length;
	var nombre = foto.src.substr(0,long - 4);
	
	window.document.all.imagen.src = nombre + '_gr.jpg';
	window.document.all.txtValor.value = foto.title;
	window.document.all.txtValor.width = 700;
	window.document.all.fotos.style.visibility = 'hidden';
	window.document.all.visor.style.visibility = 'visible';
	//window.document.all.tablaImg.style.height = 525;
}

function Volver()
{
	window.document.all.fotos.style.visibility = 'visible';
	window.document.all.imagen.src = "imagenes/cargando.gif";
	window.document.all.visor.style.visibility = 'hidden';
	//window.document.all.tablaImg.style.height = 625;
}

function viewFoto(foto)
{
 	var options = 'toolbar=no, location=no, directories=no, status=yes, menubar=no, resizable=no, scrollbars=no,width=800,height=550';
	window.open('visorfoto.aspx?imagen=' + foto,'ventana',options);
}

function setWindowToHalf()
{
	window.moveTo((screen.availWidth / 2) - (document.body.clientWidth / 2),(screen.availHeight / 2) - (document.body.clientHeight / 2));
} 