//Esta línea de abajo es para evitar que pueda cargarse una pagina sin su frameset
if (top.location.href==document.location.href)	top.location.href="/home.html"

//inicializamos los menus flotantes en el frame principal
function makeMenus(){
	if(parent.frmMenuPrinc){
		if(parent.frmMenuPrinc.oCFMenu){
			if(parent.frmMenuPrinc.oCFMenu.frameString2){
				document.open()
				document.write(parent.frmMenuPrinc.oCFMenu.frameString)
				document.write(parent.frmMenuPrinc.oCFMenu.frameString2)
				document.close()
				parent.frmMenuPrinc.oCFMenu.refresh()
			}
		}
	}
}

//advertimos al menu principal que no hay ninguna pagina cargada
function unload(timer){
	if(parent.frmMenuPrinc){
		if(parent.frmMenuPrinc.oCFMenu){
			parent.frmMenuPrinc.oCFMenu.loaded=0
		}
	}
	clearTimeout(timer)
}

makeMenus()
window.onunload=unload;

//debemos controlar que navegador se utiliza para el reposicionamiento del menu de herramientas
function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.opera=!(this.ie5 || this.ie4 || this.ns4 || this.ns5) && this.dom
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
var bw=new checkBrowser()

//en realidad no es estrictamente un preload, mas bien para nombrar las imagenes
function preloadImg(imgName, imgURL){
  if (document.images){
    eval(imgName + " = new Image()");
    eval(imgName + ".src = imgURL");
    }
}

preloadImg("HomeOff", "http://www.opsis.org.ve/imagenes/boton_home_off.gif");
preloadImg("HomeOn",  "http://www.opsis.org.ve/imagenes/boton_home_on.gif");
preloadImg("MapaOff", "http://www.opsis.org.ve/imagenes/boton_mapa_off.gif");
preloadImg("MapaOn", "http://www.opsis.org.ve/imagenes/boton_mapa_on.gif");
preloadImg("ContactoOff",  "http://www.opsis.org.ve/imagenes/boton_contacto_off.gif");
preloadImg("ContactoOn",  "http://www.opsis.org.ve/imagenes/boton_contacto_on.gif");
preloadImg("BuscarOff", "http://www.opsis.org.ve/imagenes/boton_home_off.gif");
preloadImg("BuscarOn", "http://www.opsis.org.ve/imagenes/boton_home_on.gif");


function displayImg(imgObjName, imgTagName) {
  if (document.images)
  	document[imgTagName].src = eval(imgObjName + ".src");
}

function onColor(oObject,color){
	if (bw.dom){
		if(oObject.style)oObject.style.backgroundColor=color;
	}
	else if (bw.ns4)oObject.bgColor=color
}

function offColor(oObject,color) {
	if (bw.dom){
		if(oObject.style) oObject.style.backgroundColor="#00638f";
	}
	else if (bw.ns4)oObject.bgColor="#00638f"
}

function decideVis(menu){
	if(bw.ie4||bw.ie5)oAux=eval("document.all['ayuda']")
		else oAux=eval("document.layers['ayuda']")
	auxMenu=eval("parent.frmMenuPrinc.menu"+menu)
	if(!bw.ns4)	hAux=eval(menu+'H') 		
		else {
			anchAux=eval('document.layers["menuHerramientas"].document.anchors')
			linksAux=eval('document.layers["menuHerramientas"].document.links')
			var numAux=-1
			for(i=0;i<linksAux.length;i++){
				auxString=anchAux[i].name
				if(auxString.indexOf(menu)>-1){
					numAux=i
					break
				}
			}
			hAux=eval('linksAux['+numAux+']')
		}
//	hAux.onmouseover=new Function("over('"+menu+"')");
	hAux.onmouseout=new Function("out('"+menu+"')");
	auxImg=menu+"On"
	displayImg(auxImg,menu)
	auxMenu.accion()		
	oAux.onmouseover=new Function("over('"+menu+"')");
	oAux.onmouseout=new Function("out('"+menu+"')");
}

function out(menuV){
	auxMenu=eval("parent.frmMenuPrinc.menu"+menuV)
	auxImg=menuV+"Off"
	if (auxMenu) auxMenu.invisible()
	displayImg(auxImg,menuV)	
}

function over(menuV){
	auxMenu=eval("parent.frmMenuPrinc.menu"+menuV)
	auxImg=menuV+"On"
	if (auxMenu) auxMenu.visible()
	displayImg(auxImg,menuV)
}


//Rutina para reposicionar el menú de herramientas
//Netscape no reconoce onScroll, por lo que habrá que ir reposicionando continuamente (aunque no se haya movido)
function reposition(auxY){
	if(bw.dom||bw.ie4){
		y=document.body.scrollTop
		if(document.all['menuHerramientas'])
			document.all['menuHerramientas'].style.top=y-2
//		out()
	}
		else if(bw.ns4){
			y=parseInt(pageYOffset)
			if ((y-auxY)!=0 && document.menuHerramientas) {
				document.menuHerramientas.top=(y-2)
				document.ayuda.top=(y+13)
			}
			timer=setTimeout("reposition()",1)
		}
}

//hace que al navegar horizontalmente en el frame principal, se cargue el menu de arriba correspondiente
function links(url1,url2){
	if(url1!=0){
		document.location.href=url1
		if (url2!=0){
			string=top['frmMenu'].location.href
			check=string.indexOf(url2)
			if (check<0){
				top['frmMenu'].location.href=url2
			}
		}
	}
}

//en Netscape, al redimensionar la pagina, hay que volver a cargarla
function resizeHandler() {
  if(bw.ns4){
	if (top.innerWidth != origWidth || top.innerHeight != origHeight) {
		origWidth = innerWidth;
		origHeight = innerHeight;
		top['frmMenuPrinc'].location.href = top['frmMenuPrinc'].document.location.href;
		top['frmMenu'].location.href = top['frmMenu'].document.location.href;
		top['frmPrinc'].location.href = top['frmPrinc'].document.location.href;
		}       
  }
  else 	document.all['menuHerramientas'].style.left=parseInt(parent.frmPrinc.document.body.clientWidth)-226
}


if (!bw.ns4){
	window.onscroll=reposition;
	top.window.status="Bienvenidos a OPSIS"
}

var	origWidth = window.top.innerWidth;
var	origHeight = window.top.innerHeight;

if (bw.ns4) {
	window.top.captureEvents(Event.RESIZE);
	window.top.onResize = resizeHandler;
	parent.frmPrinc.onLoad=reposition(parseInt(pageYOffset));
}

//Funcion que permite subrayar un hipervinculo. 
//Para llamarlo se utiliza onMouseOver="subraya(this,0)" para subrayar
//y onMouseOut="subraya(this,1)" para devolverlo a su estado normal
function subraya(obj,clase){
	bName = navigator.appName;
	if(bName == "Microsoft Internet Explorer") {
		auxObj=eval(obj)
		if(clase)
			auxObj.style.textDecoration="none"
			else auxObj.style.textDecoration="underline"
	}
	return false;		
}