/*
******************************************************** 
 Restricted use is hereby granted (commercial and 
 personal OK) as long as you keep this copyright notice: 
 Created by uMenu 1.02 
 Found in: http://mysoft.s5.com/ 
 Copyright 2002, Mysoft, Inc. All rights reserved. 
*********************************************************
*/
/*
================================================================
   This script is registered to: EAGLE
================================================================
*/
REGISTERED = true;
uMenuIDE_Ver = "1.00";

var cDefCap="#FFFFFF", fDefCap="Arial", fDefCapS=12, cDefMenu="#FFFFFF", fDefMenu="Arial", fDefMenuS=10, PRJ_sTemplate="Temp.html";
document.write('\
<style type="text/css">\
.clCap {cursor:hand; text-decoration:none; color:'+cDefCap+'; font-family:"'+fDefCap+'"; font-size:'+fDefCapS+'pt;}\
.clMenu {text-decoration:none; color:'+cDefMenu+'; font-family:"'+fDefMenu+'"; font-size:'+fDefMenuS+'pt;}\
');
var numOfMenus=4,scrIN=20,scrOUT=10,IDE=0,iSelectedMenu=0,errs="",rn=140,old_pageYOffset=0,widthChk,heightChk;
var PR = new Array (numOfMenus);
var MTC = new Array ("<CENTER><b><FONT FACE=\"Arial\" SIZE=\"2\" COLOR=\"#000080\">Sobre la Misión</FONT></b></CENTER>\
","<CENTER><b><FONT FACE=\"Arial\" SIZE=\"2\" COLOR=\"#000080\">Ex-Misioneros</FONT></b></CENTER>\
","<CENTER><b><FONT FACE=\"Arial\" SIZE=\"2\" COLOR=\"#000080\">Recursos</FONT></b></CENTER>\
","<CENTER><b><FONT FACE=\"Arial\" SIZE=\"2\" COLOR=\"#000080\">Sobre este Sitio</FONT></b></CENTER>\
");
var MTCH = new Array (17,17,17,17);
var MTM = new Array ("<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"ubicacionf.htm\">Ubicación Geográfica<BR></A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"hisroriaf.htm\">Breve Historia de la Misión<BR></A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"presidentf.htm\">Presidentes de la Misión<BR></A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"tipsf.htm\">Tips si vas a la MMTG</A></b></font>\
\
\
\
\
","<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"consulexmis.htm\">Consultas Ex-MMTG<BR></A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"reg_ini.htm\">Registrar sus Datos<BR></A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"news.htm\">Ver Noticias<BR></A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"postnews.htm\">Publicar Noticias<BR></A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"testimonio.htm\">Testimonios de la Misión<BR></A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"contribuya.htm\">Participe en esta sección</A></b></font>","<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"mail.htm\">Correo Electrónico<BR></A></b></font> \
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"signbook.htm\">Se buscan Ex-MMTG<BR></A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"signbook2.htm\">Solicitar busq. Ex-MMTG<BR></A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"misiones.htm\">Misiones Mexicanas</A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"recursosf.htm\">Sitios de Interés General</A></b></font>","<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"acercade.htm\">Sobre esta Página Web<BR></A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"autor.htm\">Acerca del Autor<BR></A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"currentmis.htm\">De Misioneros en el Campo<BR></A></b></font>\
<IMG SRC=\"menu.gif\" BORDER=\"0\">\
<b><font face=\"Arial\" size=\"1\"><A HREF=\"http://www.mission.net/mexico/tuxtla-gutierrez/cgi-bin/guestbook/guestbook.cgi?\">Libro de Visitas y Coment.<BR></A></b></font>");
var MX = new Array (0,150,299,449);
var MY = new Array (60,60,60,60);
var MW = new Array (150,150,150,150);
var CO = new Array ("transparent","transparent","transparent","transparent");
var CC = new Array ("#C9C992","#C9C992","#C9C992","#C9C992");
var CM = new Array ("#C9C992","#C9C992","#C9C992","#C9C992");
var MA = new Array (0,0,0,0);
var FL = new Array (0,0,0,0);
var OO = new Array (0,0,0,0);

ie=document.all?1:0;
ns=document.layers?1:0;

if (ie)
{
	for (i=0; i<numOfMenus; i++)
	{
		if (OO[i]==0)
		document.write('\
		#owner'+i+' {background-color:'+CO[i]+'; TOP:'+MY[i]+'; LEFT:'+MX[i]+'; WIDTH:'+MW[i]+'; clip:rect(0,'+MW[i]+',500,0); POSITION:absolute; VISIBILITY:hidden; Z-INDEX:2;}\
		#cap'+i+' {background-color:'+CC[i]+'; POSITION:absolute; TOP:0; LEFT:0; VISIBILITY: visible; Z-INDEX: 3; WIDTH:'+MW[i]+'; HEIGHT:'+MTCH[i]+'; clip:rect(0,'+MW[i]+','+MTCH[i]+',0);}\
		#menu'+i+' {background-color:'+CM[i]+'; POSITION:absolute; TOP:-10; LEFT:0; VISIBILITY: hidden; Z-INDEX: 1; WIDTH:'+MW[i]+';}\
		');
		else
		document.write('\
		#owner'+i+' {background-color:'+CO[i]+'; TOP:'+MY[i]+'; LEFT:'+MX[i]+'; HEIGHT:'+MW[i]+'; clip:rect(0,500,'+MW[i]+',0); POSITION:absolute; VISIBILITY:hidden; Z-INDEX:2;}\
		#cap'+i+' {background-color:'+CC[i]+'; POSITION:absolute; TOP:0; LEFT:0; VISIBILITY: visible; Z-INDEX: 3; HEIGHT:'+MW[i]+'; WIDTH:'+MTCH[i]+'; clip:rect(0,'+MTCH[i]+','+MW[i]+',0);}\
		#menu'+i+' {background-color:'+CM[i]+'; POSITION:absolute; TOP:0; LEFT:-10; VISIBILITY: hidden; Z-INDEX: 1; HEIGHT:'+MW[i]+';}\
		');
	}
}

document.write('</style>');

function doRepos()
{

 for (i=0; i<numOfMenus; i++)
   if (FL[i])
	if (ie)
	{
		document.all['owner'+i].style.top = MY[i] + document.body.scrollTop;

	}else{
		if (document.layers['owner'+i])		
			document['owner'+i].top = MY[i] + pageYOffset;
	}
}

function checkScroll()
{
	if (old_pageYOffset!=pageYOffset)
	{
		old_pageYOffset=pageYOffset;
		doRepos();
	}
}

function getMenuHeight(lIndex){
if (OO[lIndex]==0)
{
	if (ie || document['owner'+lIndex].layers['menu'+lIndex])
		return ( (ie) ? document.all['menu'+lIndex].offsetHeight : document['owner'+lIndex].layers['menu'+lIndex].clip.height );
	else
		setTimeout("getMenuHeight("+lIndex+")",50);
}
else
{
	if (ie || document['owner'+lIndex].layers['menu'+lIndex])
		return ( (ie) ? document.all['menu'+lIndex].offsetWidth : document['owner'+lIndex].layers['menu'+lIndex].clip.width );
	else
		setTimeout("getMenuHeight("+lIndex+")",50);
}
}

function setMenu(lIndex){
if (OO[lIndex]==0)
{
	if (ie)
	{
		document.all['owner'+lIndex].style.visibility="visible";
		document.all['menu'+lIndex].style.top = -getMenuHeight(lIndex)+MTCH[lIndex];

	}else{
		if (document.layers['owner'+lIndex])
		{
			document.layers['owner'+lIndex].visibility="visible";
			if (document['owner'+lIndex].layers['menu'+lIndex])
			{
				document['owner'+lIndex].layers['menu'+lIndex].top = -getMenuHeight(lIndex)+MTCH[lIndex];
				
				if (MA[lIndex]==1)
				{
					document['owner'+lIndex].layers['cap'+lIndex].document.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN);
					document['owner'+lIndex].layers['cap'+lIndex].document.onmousedown=nsMouseDown;
				}
			}else{
				setTimeout("setMenu("+lIndex+")",50);
			}
		}else
			setTimeout("setMenu("+lIndex+")",50);
	}
}
else
{
	if (ie)
	{
		document.all['owner'+lIndex].style.visibility="visible";
		document.all['menu'+lIndex].style.left = -getMenuHeight(lIndex)+MTCH[lIndex];

	}else{
		if (document.layers['owner'+lIndex])
		{
			document.layers['owner'+lIndex].visibility="visible";
			if (document['owner'+lIndex].layers['menu'+lIndex])
			{
				document['owner'+lIndex].layers['menu'+lIndex].left = -getMenuHeight(lIndex)+MTCH[lIndex];
				
				if (MA[lIndex]==1)
				{
					document['owner'+lIndex].layers['cap'+lIndex].document.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN);
					document['owner'+lIndex].layers['cap'+lIndex].document.onmousedown=nsMouseDown;
				}
			}else{
				setTimeout("setMenu("+lIndex+")",50);
			}
		}else
			setTimeout("setMenu("+lIndex+")",50);
	}
}
}

function getI(x,y){
var cX, cY, cW, cH;
	
	for (i=numOfMenus-1; i>=0; i--)
	{
		if (OO[i]==0)
		{
		cX=document.layers['owner'+i].left;
		cY=document.layers['owner'+i].top;
		cW=document.layers['owner'+i].clip.width;

		if (x>=cX && x<=cX+cW && y>=cY && y<=cY+MTCH[i])
			return i;
		}
		else
		{
		cX=document.layers['owner'+i].left;
		cY=document.layers['owner'+i].top;
		cW=document.layers['owner'+i].clip.width;
		cH=document.layers['owner'+i].clip.height;
		
		if (x>=cX && x<=cX+cW && y>=cY && y<=cY+cH)
			return i;		
		}
	}
}
function nsMouseDown(e){
	mScroll(getI(e.pageX,e.pageY));
}

function hideOwner(lIndex){
	if (OO[lIndex]==0)
	{
	if (ie)
		document.all['owner'+lIndex].style.height=MTCH[lIndex];
	else
		if (document.layers['owner'+lIndex])
			document.layers['owner'+lIndex].clip.height=MTCH[lIndex];
		else
			setTimeout("hideOwner("+lIndex+")",50);
	}
	else
	{
	if (ie)
		document.all['owner'+lIndex].style.width=MTCH[lIndex];
	else
		if (document.layers['owner'+lIndex])
			document.layers['owner'+lIndex].clip.width=MTCH[lIndex];
		else
			setTimeout("hideOwner("+lIndex+")",50);	
	}
}

function showOwner(lIndex){
	if (OO[lIndex]==0)
	{
	if (ie)
		document.all['owner'+lIndex].style.height=parseInt(document.all['menu'+lIndex].offsetHeight) + MTCH[lIndex];
	else
		document.layers['owner'+lIndex].clip.height=document['owner'+lIndex].layers['menu'+lIndex].clip.height + MTCH[lIndex];
	}
	else
	{
	if (ie)
		document.all['owner'+lIndex].style.width=parseInt(document.all['menu'+lIndex].offsetWidth) + MTCH[lIndex];
	else
		document.layers['owner'+lIndex].clip.width=document['owner'+lIndex].layers['menu'+lIndex].clip.width + MTCH[lIndex];	
	}
}

function mScroll(lIndex){
  clearTimeout(PR[lIndex]);

  if(IDE) ySetSel(lIndex,1);

  svernut=getMenuHeight(lIndex);

	if (OO[lIndex]==0)
		mTop=(ie) ? document.all['menu'+lIndex].offsetTop : document['owner'+lIndex].layers['menu'+lIndex].top ;
	else
		mTop=(ie) ? document.all['menu'+lIndex].offsetLeft : document['owner'+lIndex].layers['menu'+lIndex].left ;

  if (mTop>=MTCH[lIndex])
		scrollMe(lIndex,-(svernut-MTCH[lIndex]),-scrIN);
  else
  {
  		showOwner(lIndex);
		setVis(lIndex,"visible");
  		scrollMe(lIndex,MTCH[lIndex],scrOUT);
  }
}

function mOpen(lIndex){
	clearTimeout(PR[lIndex]);
	showOwner(lIndex);
	setVis(lIndex,"visible");
	scrollMe(lIndex,MTCH[lIndex],scrOUT);
}

function mClose(lIndex){
	var bDo=1;

	if (ie)
	{
		var cX = event.clientX + document.body.scrollLeft;
		var cY = event.clientY + document.body.scrollTop;
		var mX = document.all['owner'+lIndex].offsetLeft;
		var mY = document.all['owner'+lIndex].offsetTop;
		var mW = document.all['owner'+lIndex].offsetWidth;
		
		if (OO[lIndex]==0)
		{
		if(cX < mX+mW && cX > mX+1 && cY < getMenuHeight(lIndex)+mY+MTCH[lIndex] && cY > mY+1)
			bDo=0;
		}
		else
		{
		if(cY < mY+MW[lIndex] && cX > mX+1 && cX < getMenuHeight(lIndex)+mX+MTCH[lIndex] && cY > mY+1)
			bDo=0;
		}		
	}

	if (bDo)
	{
		clearTimeout(PR[lIndex]);
		svernut=getMenuHeight(lIndex);
		scrollMe(lIndex,-(svernut-MTCH[lIndex]),-scrIN);
	}
}

function scrollMe(lIndex,tar,step){
	if (OO[lIndex]==0)
		mTop=(ie) ? document.all['menu'+lIndex].offsetTop : document['owner'+lIndex].layers['menu'+lIndex].top ;
	else
		mTop=(ie) ? document.all['menu'+lIndex].offsetLeft : document['owner'+lIndex].layers['menu'+lIndex].left ;

	if ( (mTop<tar && step>0) || (mTop>tar && step<0) )
	{
		mTop+=step;

		if ( (mTop>tar && step>0) || (mTop<tar && step<0) )
			mTop=tar;

		if (OO[lIndex]==0)
		{
			if (ie)
				document.all['menu'+lIndex].style.top = mTop;
			else
				document['owner'+lIndex].layers['menu'+lIndex].top = mTop;
		}
		else
		{
			if (ie)
				document.all['menu'+lIndex].style.left = mTop;
			else
				document['owner'+lIndex].layers['menu'+lIndex].left = mTop;		
		}
		
		PR[lIndex]=setTimeout('scrollMe('+lIndex+','+tar+','+step+')',50);
	}
	else if (step<0)
	{
		hideOwner(lIndex);
		setVis(lIndex,"hidden");
	}
}

function resizeFix()
{
	if (widthChk != window.innerWidth || heightChk != window.innerHeight)
		document.location.reload();
}

function makeUmenu(){
if (ie)
{
  if (IDE)
    document.body.scroll='no';

	for (i=0; i<numOfMenus; i++)
	{
		var ieMouseOut='', ieMouseOver='', ieMouseDown='';
		if (MA[i]==0)
		{
			ieMouseOut=' onMouseOut="mClose('+i+')"';
			ieMouseOver=' onMouseOver="mOpen('+i+')"';
			if(IDE) ieMouseDown=' onMouseDown="ySetSel('+i+',1)"';
		}else
			ieMouseDown=' onMouseDown="mScroll('+i+')"';

		document.write('\
		<div id="owner'+i+'"'+ieMouseOut+'>\
			<div id="cap'+i+'" class="clCap"'+ieMouseOver+ieMouseDown+'>'+MTC[i]+'</div>\
			<div id="menu'+i+'" class="clMenu">'+MTM[i]+'</div>\
		</div>\
		');
	}
}else{
	widthChk = window.innerWidth;
	heightChk = window.innerHeight;
	window.onResize = resizeFix;
	
	setInterval("checkScroll()",50);
	
	for (i=0; i<numOfMenus; i++)
	{
		var nsO='', nsC='', nsM='';
		var nsMouseOut='', nsMouseOver='';		
		if (MA[i]==0)
		{
			nsMouseOut=' onMouseOut="mClose('+i+')"';
			nsMouseOver=' onMouseOver="mOpen('+i+')"';
		}
		
		if (CO[i]!='transparent')
			nsO=' bgColor='+CO[i];
		if (CC[i]!='transparent')
			nsC=' bgColor='+CC[i];
		if (CM[i]!='transparent')
			nsM=' bgColor='+CM[i];
		
		if (OO[i]==0)		
		document.write('\
		<layer name="owner'+i+'"'+nsO+nsMouseOut+' LEFT='+MX[i]+' TOP='+MY[i]+' Z-INDEX=2 VISIBILITY=hidden>\
			<layer name="cap'+i+'" class="clCap"'+nsC+nsMouseOver+' Z-INDEX=1 HEIGHT='+MTCH[i]+' WIDTH='+MW[i]+'>'+MTC[i]+'</layer>\
			<layer name="menu'+i+'" class="clMenu"'+nsM+' Z-INDEX=0 VISIBILITY=hidden WIDTH='+MW[i]+'>'+MTM[i]+'</layer>\
		</layer>\
		');
		else
		document.write('\
		<layer name="owner'+i+'"'+nsO+nsMouseOut+' LEFT='+MX[i]+' TOP='+MY[i]+' Z-INDEX=2 VISIBILITY=hidden>\
			<layer name="cap'+i+'" class="clCap"'+nsC+nsMouseOver+' Z-INDEX=1 HEIGHT='+MW[i]+' WIDTH='+MTCH[i]+'>'+MTC[i]+'</layer>\
			<layer name="menu'+i+'" class="clMenu"'+nsM+' Z-INDEX=0 VISIBILITY=hidden HEIGHT='+MW[i]+'>'+MTM[i]+'</layer>\
		</layer>\
		');		
	}
}
	for (i=0; i<numOfMenus; i++)
	{
		hideOwner(i);
		setMenu(i);
	}

	if ( (rn>>2!=35) && (document.location.protocol!='file:') )	
	{
		w1=window.open("","win1","scrollbars=1,status=0,left=0,top=250,width=600,height=260");
		w1.document.write ('<HTML>Please Register!<SCRIPT LANGUAGE=\'JavaScript\'>setTimeout(\'document.location="http://mysoft.s5.com/umenu/reg.html"\',800);</SCRIPT></HTML>');
		w1.document.close();
	}
	
	if(IDE && numOfMenus>0)
	{
		ySetSel(iSelectedMenu,0);
		mOpen(iSelectedMenu);
	}
}

function errorHandler(msg, url, line)
{
	if (IDE)
		setTitle('!uMenuIDE:ERROR(' + msg + '@' + url + '@' + line + ')');
	else
	{
		w2=window.open("","win2","scrollbars=1,status=0,left=230,top=210,width=500,height=200");
		errs+=msg + ' - ' + url + ' - ' + line + '<BR>';
		w2.document.write ('<HTML><B>Error!</B> Possible reasons:<BR><B>1.</B> HTML code which you entered inside a menu or caption is illegal.<BR>'+
		'<B>2.</B> Unreliable Internet Connection. Please Reload the Page.<BR>'+
		'<B>3.</B> This could be a bug. Please send your <I>Umenuscript.js</I> to the <A HREF="mailto:uhfx@yahoo.com">author.</A><BR>'+
		'<BR><FORM><INPUT TYPE=button onClick="opener.location.reload();self.close()" VALUE="Reload Page"></FORM><NOBR>'+
		errs+'</NOBR></HTML>');
		w2.document.close();		
	}
	
	return true;
}

function setVis(i,vis)
{
	if (ie)
		document.all['menu'+i].style.visibility = vis;
	else
		document['owner'+i].layers['menu'+i].visibility = vis;
}

window.onerror = errorHandler;
if (ie)
	window.onscroll = doRepos;
