var incrementoTexto=4;
var incrementoTextoAutomatico=0;
var incrementoCapa=6;
var incrementoCapaAutomatico=0;
var saltoFotogramaCapa=6;
var tic=100;
var tac=5000;
var toc=750;
var tuc=25;
var oFoto=new Object();
var oContador=new Object();
var alto=0;
var cuadroAltaResolucion;
var idActual=0;
var idMax=0;
var tipoCuadro="r";
var movimientoBloqueado=false;

function esExplorer()
{
  if(navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win")!=-1))
  {
    return true;
  }
  else
  {
    return false;
  }
}

function maximizar(anchoMinimo,altoMinimo)
{
  //alert("["+window.screen.availWidth+"x"+window.screen.availHeight+"]\n["+window.innerWidth+"x"+window.innerHeight+"]");
  //anchoDisponible=window.screen.availWidth
  //altoDisponible=window.screen.availHeight
	ancho=esExplorer()?top.document.body.clientWidth:top.window.innerWidth;
	alto=esExplorer()?top.document.body.clientHeight:top.window.innerHeight;
	if (ancho<anchoMinimo||alto<altoMinimo)
	{
		top.window.moveTo(0,0);
		top.window.resizeTo(window.screen.availWidth, window.screen.availHeight);
	}
}

function maximizar788x412()
{
  maximizar(788,412);
}

window.onresize=maximizar788x412;
alto=esExplorer()?top.document.body.clientHeight:top.window.innerHeight;

function verificarFrames(inicio)
{
  if(top==self)
  {
    top.location=inicio;
  }
}

function verificarFramesFrames(inicio)
{
  if(top==parent)
  {
    top.location=inicio;
  }
}

function verificarFramesFramesFrames(inicio)
{
  if(top==parent.parent)
  {
    top.location=inicio;
  }
}

function capaVacia(idCapa,izquierda,arriba,ancho,alto,zeta,visible,clase)
{
  document.write("<div id=\""+idCapa+"\" class=\""+clase+"\" style=\"position:absolute;top:"+arriba+"px;left:"+izquierda+"px;width:"+ancho+"px;height:"+alto+"px;z-index:"+zeta+";visibility:"+(visible?"visible":"hidden")+";\">&nbsp;</div>");
}

function fotoPNG(idFoto,nombre,izquierda,arriba,ancho,alto,zeta,visible)
{
  document.write("<div id=\""+idFoto+"\" style=\"position:absolute;top:"+arriba+"px;left:"+izquierda+"px;width:"+ancho+"px;height:"+alto+"px;z-index:"+zeta+";visibility:"+(visible?"visible":"hidden")+";");
  if(esExplorer())
  {
    document.write("filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=image src='"+nombre+"')\">");
  }
  else
  {
    document.write("\"><img src=\""+nombre+"\" id=\"f"+idFoto+"\" border=\"0\" width=\""+ancho+"\" height=\""+alto+"\" lowsrc=\"img/pixel.gif\">");
  }
  document.write("</div>");
}

function fotoBoton(idFoto,reposo,sobre,pulsado,izquierda,arriba,ancho,alto,zeta,funcionClick,funcionSobre,funcionReposo,visible)
{
  cargarFoto(reposo,ancho,alto);
  cargarFoto(sobre,ancho,alto);
  cargarFoto(pulsado,ancho,alto);
  document.write("<div id=\""+idFoto+"\" name=\""+idFoto+"\" onClick=\""+funcionClick+"\" onMouseOver=\"cambiarFoto('"+idFoto+"',oFoto['"+sobre+"']);"+funcionSobre+"\" onMouseDown=\"cambiarFoto('"+idFoto+"',oFoto['"+pulsado+"'])\" onMouseUp=\"cambiarFoto('"+idFoto+"',oFoto['"+sobre+"'])\" onMouseOut=\"cambiarFoto('"+idFoto+"',oFoto['"+reposo+"']);"+funcionReposo+"\" style=\"position:absolute;top:"+arriba+"px;left:"+izquierda+"px;width:"+ancho+"px;height:"+alto+"px;z-index:"+zeta+";cursor:pointer;visibility:"+(visible?"visible":"hidden")+";");
  if(esExplorer())
  {
    document.write("filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=image src='"+reposo+"')\">");
  }
  else
  {
    document.write("\"><img src=\""+reposo+"\" id=\"f"+idFoto+"\" border=\"0\" lowsrc=\"img/pixel.gif\">");
  }
  document.write("</div>");
}

function fotoEnlace(idFoto,reposo,sobre,pulsado,izquierda,arriba,ancho,alto,zeta,funcionClick,funcionSobre,funcionReposo,visible)
{
  cargarFoto(reposo,ancho,alto);
  cargarFoto(sobre,ancho,alto);
  cargarFoto(pulsado,ancho,alto);
  //document.write("<a href=\""+enlace+eval(parametro)+"\" target=\""+destino+"\">");
  //document.write("<a href=\"javascript"+funcionClick+"\" target=\"_blank\">");
  document.write("<a href=\"#\">");
  document.write("<div id=\""+idFoto+"\" name=\""+idFoto+"\" onClick=\""+funcionClick+"\" onMouseOver=\"cambiarFoto('"+idFoto+"',oFoto['"+sobre+"']);"+funcionSobre+"\" onMouseDown=\"cambiarFoto('"+idFoto+"',oFoto['"+pulsado+"'])\" onMouseUp=\"cambiarFoto('"+idFoto+"',oFoto['"+sobre+"'])\" onMouseOut=\"cambiarFoto('"+idFoto+"',oFoto['"+reposo+"']);"+funcionReposo+"\" style=\"position:absolute;top:"+arriba+"px;left:"+izquierda+"px;width:"+ancho+"px;height:"+alto+"px;z-index:"+zeta+";cursor:pointer;visibility:"+(visible?"visible":"hidden")+";");
  if(esExplorer())
  {
    document.write("filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=image src='"+reposo+"')\">");
  }
  else
  {
    document.write("\"><img src=\""+reposo+"\" id=\"f"+idFoto+"\" border=\"0\" lowsrc=\"img/pixel.gif\">");
  }
  document.write("</div>");
  document.write("</a>");
}

function precargarFotos(prefijo,sufijo,cantidad,ancho,alto)
{
  for(i=0;i<cantidad;i++)cargarFoto(prefijo+(i)+sufijo,ancho,alto);
}

function cargarFoto(nombreFoto,ancho,alto)
{
  if(oFoto[nombreFoto]==undefined)
  {
    oFoto[nombreFoto]=new Image(ancho,alto);
    oFoto[nombreFoto].src=nombreFoto;
  }
  //alert(oFoto[nombreFoto].src);
  //return oFoto[nombreFoto];
}

function cambiarFoto(idFoto,nuevaFoto)
{
  if(nuevaFoto.complete)
  {
    if(esExplorer())
    {
      document.getElementById(idFoto).style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=image src='"+nuevaFoto.src+"')"
    }
    else
    {
      document.getElementById("f"+idFoto).src=nuevaFoto.src;
    }
  }
}

function mostrarFotoPrecargada(idFoto,nombreNuevaFoto)
{
  if(oFoto[nombreNuevaFoto].complete)
  {
    top.frames['contenido'].frames['Rosario_Clavarana_Caballero_pintura'].frames['Rosario_Clavarana_Caballero_oleo'].document.getElementById(idFoto).src=oFoto[nombreNuevaFoto].src;
  }
  else
  {
    setTimeout("mostrarFotoPrecargada('"+idFoto+"','"+nombreNuevaFoto+"')",toc);
  }
}

function rotarFotos(idFoto,prefijo,sufijo,cantidad)
{
  oContador[prefijo]=(oContador[prefijo]+1)%cantidad;
  //alert(prefijo+oContador[prefijo]+sufijo);
  cambiarFoto(idFoto,oFoto[prefijo+oContador[prefijo]+sufijo]);
  setTimeout("rotarFotos('"+idFoto+"','"+prefijo+"','"+sufijo+"',"+cantidad+")",tac);
}

function cambiarContenido(pagina,destino)
{
  eval(destino+".location='"+pagina+"'");
}

function inicioTexto(idTexto,izquierda,arriba,ancho,alto,zeta,visible)
{
  document.write("<div id=\""+idTexto+"\" class=\"textoEnlace\" style=\"position:absolute;left:"+izquierda+"px;top:"+arriba+"px;width:"+ancho+"px;height:"+alto+"px;z-index:"+zeta+";clip:rect(0px "+ancho+"px "+alto+"px 0px);visibility:"+(visible?"visible":"hidden")+";\">");
}

function finTexto()
{
  document.write("</div>");
}

function subirTexto(idTexto)
{
  var rectangulo=document.getElementById(idTexto).style.clip.split(" ");
  document.getElementById(idTexto).style.clip="rect("+(parseInt(rectangulo[0].substring(5,rectangulo[0].length))+incrementoTexto)+"px "+parseInt(rectangulo[1])+"px "+(parseInt(rectangulo[2])+incrementoTexto)+"px "+parseInt(rectangulo[3])+"px)";
  document.getElementById(idTexto).style.top=""+(parseInt(document.getElementById(idTexto).style.top)-incrementoTexto)+"px";
}

function bajarTexto(idTexto)
{
  var rectangulo=document.getElementById(idTexto).style.clip.split(" ");
  var rectangulo0=parseInt(rectangulo[0].substring(5,rectangulo[0].length));
  if(rectangulo0!=0)
  {
    document.getElementById(idTexto).style.clip="rect("+(rectangulo0-incrementoTexto)+"px "+parseInt(rectangulo[1])+"px "+(parseInt(rectangulo[2])-incrementoTexto)+"px "+parseInt(rectangulo[3])+"px)";
    document.getElementById(idTexto).style.top=""+(parseInt(document.getElementById(idTexto).style.top)+incrementoTexto)+"px";
  }
}

function moverTextoVertical(idTexto)
{
  //alert(idTexto);
  var rectangulo=document.getElementById(idTexto).style.clip.split(" ");
  var rectangulo0=parseInt(rectangulo[0].substring(5,rectangulo[0].length));
  if(rectangulo0!=0||incrementoTextoAutomatico<0)
  {
    document.getElementById(idTexto).style.clip="rect("+(rectangulo0-incrementoTextoAutomatico)+"px "+parseInt(rectangulo[1])+"px "+(parseInt(rectangulo[2])-incrementoTextoAutomatico)+"px "+parseInt(rectangulo[3])+"px)";
    document.getElementById(idTexto).style.top=""+(parseInt(document.getElementById(idTexto).style.top)+incrementoTextoAutomatico)+"px";
  }
  if(incrementoTextoAutomatico!=0)setTimeout("moverTextoVertical('"+idTexto+"')",tic);
}

function textoArriba(idTexto)
{
  var rectangulo=document.getElementById(idTexto).style.clip.split(" ");
  document.getElementById(idTexto).style.top=""+(parseInt(document.getElementById(idTexto).style.top)+parseInt(rectangulo[0].substring(5,rectangulo[0].length)))+"px";
  document.getElementById(idTexto).style.clip="rect(0px "+parseInt(rectangulo[1])+"px "+(parseInt(document.getElementById(idTexto).style.height))+"px "+parseInt(rectangulo[3])+"px)";
}

function cambiarTexto(idTexto,nuevoTexto)
{
  document.getElementById(idTexto).innerHTML=nuevoTexto;
}

function moverCapaHorizontal(idCapa)
{
  var rectangulo=document.getElementById(idCapa).style.clip.split(" ");
  var o=document.getElementById(idCapa);
  rectangulo[0]=parseInt(rectangulo[0].substring(5,rectangulo[0].length));
  rectangulo[1]=parseInt(rectangulo[1]);
  rectangulo[2]=parseInt(rectangulo[2]);
  rectangulo[3]=parseInt(rectangulo[3]);
  //alert("["+""+"/"+rectangulo[1]+"]");
  if((incrementoCapaAutomatico>0 && parseInt(o.style.width)-rectangulo[3]-126>0) || (incrementoCapaAutomatico<0 && rectangulo[1]>126))
  {
    o.style.clip="rect("+rectangulo[0]+"px "+(rectangulo[1]+incrementoCapaAutomatico)+"px "+rectangulo[2]+"px "+(rectangulo[3]+incrementoCapaAutomatico)+"px)";
    o.style.left=""+(parseInt(o.style.left)-incrementoCapaAutomatico)+"px";
  }
  if(incrementoCapaAutomatico!=0)setTimeout("moverCapaHorizontal('"+idCapa+"')",tuc);
}

function moverCapaHorizontalCantidad(idCapa,cantidad,actual)
{
  movimientoBloqueado=true;
  var rectangulo=document.getElementById(idCapa).style.clip.split(" ");
  var o=document.getElementById(idCapa);
  rectangulo[0]=parseInt(rectangulo[0].substring(5,rectangulo[0].length));
  rectangulo[1]=parseInt(rectangulo[1]);
  rectangulo[2]=parseInt(rectangulo[2]);
  rectangulo[3]=parseInt(rectangulo[3]);
  saltoFotogramaCapa=cantidad>0?Math.abs(saltoFotogramaCapa):-Math.abs(saltoFotogramaCapa);
  if((cantidad>0 && parseInt(o.style.width)-rectangulo[3]-159>0) || (cantidad<0 && rectangulo[1]>126)) //159=126+66/2
  {
    o.style.clip="rect("+rectangulo[0]+"px "+(rectangulo[1]+saltoFotogramaCapa)+"px "+rectangulo[2]+"px "+(rectangulo[3]+saltoFotogramaCapa)+"px)";
    o.style.left=""+(parseInt(o.style.left)-saltoFotogramaCapa)+"px";
  }
  //alert("moverCapaHorizontal('"+idCapa+"',"+cantidad+","+(actual+Math.abs(saltoFotogramaCapa))+")");
  if(Math.abs(cantidad)>(actual+Math.abs(saltoFotogramaCapa)))
  {
    setTimeout("moverCapaHorizontalCantidad('"+idCapa+"',"+cantidad+","+(actual+Math.abs(saltoFotogramaCapa))+")",tuc);
  }
  else
  {
    movimientoBloqueado=false;
  }
}

function ventanaCuadroAltaResolucion(id)
{
  var opciones="toolbar=no,location=no,directories=0,status=no,menubar=no,scrollbars=yes,resizable=1,width="+screen.width+",height="+screen.height+",top=0,left=0";
  cuadroAltaResolucion=window.open("Rosario_Clavarana_Caballero_alta_resolucion.php?cuadro="+idActual,"cuadro",opciones);
}

