var jsiomenu = new Array(); 
var ImagenActual=0;
var Finalizado=true;

jsiomenu[jsiomenu.length]="Imagenes/LaCasaP0.gif"; 
jsiomenu[jsiomenu.length]="Imagenes/LaCasaP1.gif";  
jsiomenu[jsiomenu.length]="Imagenes/LaCasaSitio.gif"; 
jsiomenu[jsiomenu.length]="Imagenes/LaCasaProvincia.gif"; 

function GetRef(etcn) {
  if (document.all) return document.all[etcn];
    else return document.getElementById(etcn);
}

function getX(ref) {
  if (document.layers) return ref.pageX;
  var x = 0;
  if (document.all) 
    while (ref.offsetParent!=null) 
	  { x+=ref.offsetLeft; ref=ref.offsetParent; } 
  x=0;	  
  return x;
}

function getY(ref) {
  if (document.layers) return ref.pageY;
  var y = 0;
  if (document.all) 
    while (ref.offsetParent!=null) 
	  { y+=ref.offsetTop; ref=ref.offsetParent; }
  y+=ref.offsetTop;
  y=0;
  return y;
} 

function InitImagen()
{
//No me deja llamarlo ya que no se ejecuta el onload al usar ajax
var ref, x, y, sy;
ref = GetRef('ref');
x = 0;// getX(ref); 
y = 0;//getY(ref);
ref = GetRef('outer');
ref.style.left = x; ref.style.top = y;
}

function Modifica(ImagenDestino)
{	
  var ref, x, y, sy;
  //Cojo la posición absoluta
  ref = GetRef('ref');
  x = getX(ref); 
  y = getY(ref);
  ref = GetRef('outer');
  ref.style.left = x; ref.style.top = y;
  if ((sx==iw>>1)||(sx==0)) 
    { 
	if (Direccion>0) 
	    document['bimg'].src = jsiomenu[ptr]; 
      else document['fimg'].src = jsiomenu[ptr]; 
    }
  sx+=Direccion; 
  if ((sx>iw>>1)||(sx<0)) {  
    if (!Primera)
	  Finalizado=true;
	else Primera=false;  
    if (Direccion>0) {
	  //La vieja va de grande a pequeña en el centro
  	  sx=0;
	  document['fimg'].src = jsiomenu[ptr];
	  ptr=ImagenDestino; if (ptr>=jsiomenu.length) ptr=0;
      } 
	else {
	  //Aparece la nueva desde el centro y pequeña	
	  sx=iw>>1;
	  document['bimg'].src = jsiomenu[ptr];
	  ptr=ImagenDestino; if (ptr>=jsiomenu.length) ptr=0;
      }
  }
  sy = sx*(ih>>1)/(iw>>1);
  ref = GetRef('icut');
  ref.style.left = sx;
  ref.style.top = sy;
  ref.style.width = iw-(sx<<1); 
  ref.style.height = ih-(sy<<1);
  ref = GetRef('ipos'); 
  ref.style.left = -(sx<<1); 
  ref.style.top = -(sy<<1);
  document['fimg'].width = iw+(sx<<1);
  document['fimg'].height = ih+(sy<<1);
  if (!Finalizado) 
    setTimeout("Modifica("+ImagenDestino+")",20,"JavaScript");	
  else ImagenActual=ImagenDestino;	
}

function Ejecuta(ImagenDestino)
{
if ((ImagenActual==ImagenDestino)||(!Finalizado))
  return;
//CAMBIO EL TITULO
switch (ImagenDestino) 
  {
  case 0:GetRef('Titulo').innerHTML='LA PLANTA BAJA'; break;
  case 1:GetRef('Titulo').innerHTML='LA PLANTA 1&ordf;'; break;
  case 2:GetRef('Titulo').innerHTML='EL SITIO'; break;
  case 3:GetRef('Titulo').innerHTML='LA PROVINCIA'; break;
  }
//--------------  
iw = 320;
ih = 241;  
if (ImagenActual<ImagenDestino) 
  Direccion=4;
else 
  Direccion=-4;

Primera=true;
if (Direccion<0) 
  sx=0; 
else (sx=iw>>1);
  
if (!Primera)
  ptr=ImagenDestino;
Finalizado=false; 
Modifica(ImagenDestino);

}

var iw = 320, ih = 241;
var Direccion=4;
var Primera=true;
var ptr = 0;
if (Direccion<0) 
  sx=0; 
else (sx=iw>>1);

