/**
 * Este fichero contiene funciones JavaScript de interés general de la
 * aplicación
 * ˇˇˇˇˇASEGURARSE de que no hay referencias DIRECTAS a campos o páginas!!!!!
 */
var ag = navigator.userAgent.toLowerCase();
var js_on = true;
var ie = false;
if( typeof document.all!="undefined"&&(ag.indexOf('msie')!=-1)) {
  if (ag.indexOf('msie 4')==-1)
   ie=true;
   }
var fx = false;
if( typeof document.getElementById!="undefined"&&!ie ) {
  if( ag.indexOf('netscape6')==-1 )
   fx = true;
  if( typeof window.opera!="undefined" )
   fx = false;
  else
   if( ag.indexOf('gecko')==-1 )
    fx=false;
  }
function rand( numero ) {
  return Math.floor(Math.random()*numero);
  }

// Para las páginas de cuadros
var ancho;
var alto;
function init() {
  ancho = document.getElementById("ifr").clientWidth-20;
  alto = document.getElementById("ifr").clientHeight-20;
//alert( "Pizarra: ancho ["+ancho+"]   alto ["+alto+"]");  
}

function mostrar( dir,lang,num ) {
  ancho = parent.document.getElementById("ifr").clientWidth;
  alto = parent.document.getElementById("ifr").clientHeight-30;
//alert( "mostrar: Ancho: "+ancho+"Alto: "+alto );
  var dibujo = dir+"/img.php?lang="+lang+"&cuadro="+num;
//  alert( dibujo);
  document.getElementById("ifr").src=dibujo;
}
  
function dimensiones() {
  ancho = parent.document.getElementById("ifr").clientWidth-20;
  alto = parent.document.getElementById("ifr").clientHeight-40;
//alert( "Dim: Ancho:"+ancho+"  Alto: "+alto );
  var img_w = document.getElementById("imgn").clientWidth;
  var img_h = document.getElementById("imgn").clientHeight;
//alert( "Dim: img_w: "+img_w+"img_h: "+img_h );
  var x = 0;
  var y = 0;
  if( img_w > img_h ) {
    y = img_h * ancho / img_w;
//alert( "img_w > img_h: y: "+y );
    if( y > alto ) {
      x = img_w * alto / img_h;
      document.getElementById("imgn").width = x;
      y = alto;
//alert( "img_w > img_h [y > alto]: x: "+x+"  y: "+y );
      }
    document.getElementById("imgn").height = y;
  } else {
    x = img_w * alto / img_h;
//alert( "img_w < img_h: x: "+x );
    if( x > ancho ) {
      y = img_h * ancho / img_w;
      document.getElementById("imgn").height = y;
      x = ancho;
//alert( "img_w < img_h [x > ancho]: x: "+x+"  y: "+y );
    }
    document.getElementById("imgn").width = x;
  }
//  alert( "DIV:"+ancho+","+alto+"\nIMG:"+img_w+","+img_h+"\n"+document.getElementById("imgn").width+","+document.getElementById("imgn").height );
  }
  
function hideLoad() {
  document.getElementById("loader").style.visibility = "hidden";
  dimensiones();
  document.getElementById("imgn").style.visibility = "visible";
  document.getElementById("imagen").style.visibility = "visible";
//alert( "loader: "+(document.getElementById("loader").style.visibility) );
  }

