// JavaScript Document

function gestionFrames() {
	//onLoad="gestionFrames();"
	pagina=buscarParametro("pagina");
	//menu=buscarParametro("menu");
	
	//document.write("hola "+pagina+" "+menu+" "+"adios");
	
	if (pagina!="") {
		parent.frames.mainFrame.document.location.href=pagina;
	} 
	/*
	if (menu!="") {
		parent.frames.izq.document.location.href=menu;
	}
	*/
}

function autoCargarFrames () { //(menu) {
	//onLoad="autoCargarFrames('men_viH.html');"
	if (window == top) {
		//top.location.replace("inicio.html?menu="+menu+"&pagina="+document.URL);
		top.location.replace("inicio.html?pagina="+document.URL);
	}
}


function centrarDiv(id,continente) {
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
if (continente!=null) {
	d=continente;
}
//<DIV STYLE="position:absolute; top:50px; left:40px; width:400px; height:300px; background-color:blue; color:red; font-size:20; text-align:center; border:thin dotted; border-width: 50px;"> add some text here! </DIV>
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	
	var altoPagina = ns ? top.innerHeight : (d.documentElement && d.documentElement.clientHeight) ? 
		d.documentElement.clientHeight : d.body.clientHeight;
		
	var anchoPagina = ns ? top.innerWidth :	(d.documentElement && d.documentElement.clientWidth) ? 
		d.documentElement.clientWidth : d.body.clientWidth;
	
	if (anchoPagina<parseInt(el.style.width))
		el.style.left=0;
	else
		el.style.left=(anchoPagina/2-parseInt(el.style.width)/2)+"px";
	
	if (altoPagina<parseInt(el.style.height))
		el.style.top=0;
	else
		el.style.top=(altoPagina/2-parseInt(el.style.height)/2)+"px";
	
	//alert(el.id+":("+(el.style.width)+","+el.style.height+")->("+anchoPagina+","+altoPagina+")->("+el.style.left+","+el.style.top+") ["+ns+"]");
}

function mostrarFicha(idDiv,idFrame,posicion,ruta) { //px,py
//mostrarFicha('divFicha','frFicha','centro','GARBI/garbiOK.html')
	var obj;
  
	obj=window.parent.document.getElementById(idDiv);
	if (obj.style) {
		obj=obj.style;
		obj.visibility='visible';
	} else {
		obj.visibility='show';
	}
	if (posicion=='centro')
		centrarDiv(idDiv,window.parent.document);
	/*else {
		obj.top=py;
		obj.left=px;	
	}*/
	window.parent.document.getElementById(idFrame).src=ruta;	
}

function inerciaV(id, yini,yfin,factor) {
	if (factor==null) factor=15;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	var px = document.layers ? "" : "px";
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	window[id + "_obj"] = el;
	if(d.layers) el.style=el;
	
	if (yini==0 && yfin==0) {
		el.yini = el.yact = -parseFloat(el.style.height);
		el.yfin = parseFloat(el.style.top);
	} else {	
		el.yini = el.yact = yini;
		el.yfin = yfin;
	}
	
	el.posicionar=function(x,y){
		//this.style.left=x+px;
		this.style.top=y+px;
	};
	
	el.generarInercia=function() {	
		this.yact += (this.yfin - this.yact)/factor;
		this.posicionar(0, this.yact);
		if (this.yfin != this.yact)	setTimeout(this.id + "_obj.generarInercia()", 40);
	}
	return el;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  ventana=window.open(theURL,winName,features);
  ventana.focus();  
}