/*
Pasandole a estas dos funciones el ancho y el alto de la nueva ventana a abrir, y la ventana
respecto de la cual queremos obtener el centrado, nos devuelven las posiciones X y Y a poner en
left y top respectivamente.
*/

function abrirImagen(img){
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}

function Controlla(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    verFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}

function verFoto(img){	
	anchoVentana = foto1.width;
	altoVentana = foto1.height+44;
	popupSinScroll("/secciones/general/imagen.asp?src=" + img,altoVentana,anchoVentana);
}

function obtenerObjeto(Id)                                                                 
{                 
  var obj = null;                                                                                                       
  // Netscape 6,7 y Explorer 5                                                         
  if (document.getElementById) {                                                       
	obj = document.getElementById(Id);                                                                                                                                                                                          
  }                                                                                    
  // Explorer 4                                                                        
  else if (document.all) {                                                             
	obj = document.all[Id];                                                      
  }                                                                                    
  // Netscape 4                                                                        
  else if (document.layers) {                                                          
	obj = document.layers[Id];                                                   
  }      
  return obj;      
}
	
function lanzacentrado(url, nombre, atributos, ancho, alto)
{
            if(ancho>screen.availWidth) ancho=screen.availWidth;
            if(alto>screen.availHeight) alto=screen.availHeight;
                var str = ",height=" + alto + ",innerHeight=" + alto;
            str += ",width=" + ancho + ",innerWidth=" + ancho;
            if (window.screen)
            {
                        var ah = screen.availHeight - 30;
                        var aw = screen.availWidth - 10;
                        var xc = (aw - ancho) / 2;
                        var yc = (ah - alto) / 2;
                        str += ",left=" + xc + ",screenX=" + xc;
                        str += ",top=" + yc + ",screenY=" + yc;
//                      str += ",left=0,screenX=0";
//                      str += ",top=0,screenY=0";
            }
            atributos=atributos + str;
//          alert("Atributos -->"+atributos);
            popventana = window.open(url, nombre, atributos);
            popventana.focus();
}

function popup(url,alto,ancho)
{ 
            props = "status=0,scrollbars=1";
            lanzacentrado(url, "popup", props, ancho, alto);
}
