function AbreVentana(URL_Ventana, OpcionesVentana, Ancho, Alto, Centrada, PosX, PosY) {
//  Ancho = win_Ancho;
//  Alto = win_Alto;
  if (Centrada) {
    PosX = (screen.availWidth - Ancho)/2;
    PosY = (screen.availHeight - Alto)/2;
    }

  if (OpcionesVentana == '')
    OpcionesVentana = 'width=' + Ancho;
  else
    OpcionesVentana += ',width=' + Ancho;

  OpcionesVentana += ',height=' + Alto + ',left=' + PosX + ',top=' + PosY;

  var win=window.open(URL_Ventana, "win", OpcionesVentana);
  win.resizeTo(Ancho+30, Alto+60);

  return win;
}
 
function RedimensionarVentana(){
	var tot = document.documentElement;
	var h = tot.offsetHeight+60>screen.height-30? screen.height-30 : tot.offsetHeight+60;
	var w = tot.offsetWidth+30>screen.width? screen.width : tot.offsetWidth+30;
	//window.sizeToContent();
	sizeToContent();
	//self.resizeTo(w,h);
	CentrarVentana(w,h);
}
 
function sizeToContent() {
  body=document.getElementsByTagName('body')[0];
  if(body.clientHeight<body.scrollHeight)
    window.resizeTo(300, 200+(body.scrollHeight-body.clientHeight))  
}

function CentrarVentana(ancho, alto){
	var izquierda = (screen.width) ? (screen.width-ancho)/2 : 100;
	var arriba = (screen.height) ? (screen.height-alto)/2 : 100;
	self.moveTo(izquierda, arriba);
}

/* FUNCION PARA RECARGAR EL FRAME DE LAS MINIATURAS */
function refreshFrame(valor_id, valor_ref) {
	document.getElementById('miniaturas').src = "components/ficha_ampliada/c-miniaturas-s1.php?valor_id="+valor_id+"&valor_ref="+valor_ref;
}

/* FUNCION PARA IMPRIMIR EL FRAME DE LAS MINIATURAS */
function iprint(iframeid) {  
 var iframe = window.frames[iframeid]
 iframe.focus();
 iframe.print();  
}  


/* FUNCION PARA INTERCAMBIAR IMAGENES */
function cargaImagen(id, imagen) {
	parent.document.getElementById(id).src = imagen;
}
