var RunningIE4
RunningIE4 = (msieversion() >=4);

function msieversion() {
	var ua = window.navigator.userAgent
	var msie = ua.indexOf ( "MSIE " )
	if ( msie > 0 ) {		// is Microsoft Internet Explorer; return version number
		return parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) ) }
	else
		return 0	// is other browser
}

//Función para ocultar o revelar secciones
var cursection = null

function switch_sections (text_section_name) {

if (RunningIE4) {

// Because Navigator won't let you use an object name in a function call (because it doesn't
// recognise objects), this version passes the object name as a string. I then extract
// a reference to the object by indexing the collection of objects 'document.all' with
// the string parameter.

var clicked_section = document.all(text_section_name)

if (cursection != null ) {  // 'none' means all sections are currently closed.
   cursection.style.display = 'none';}

if (clicked_section != cursection) {

   // the next statement is necessary in this version because IE4 won't override
   // a display property value that's been set by a cascading style sheet (see below)!

   clicked_section.className = ""; // Switch off CLASS style enforcement for spans in IE4

   clicked_section.style.display = "";   
   cursection = clicked_section ; 
   } else {
   cursection = null } // Indicate that all sections are currently closed.
} }

/*     Calculate Easter Sunday

     Written originaly in Java by Gregory N. Mirsky

     Source: 2nd Edition by Peter Duffett-Smith. It was originally from
     Butcher's Ecclesiastical Calendar, published in 1876. This
     algorithm has also been published in the 1922 book General
     Astronomy by Spencer Jones; in The Journal of the British
     Astronomical Association (Vol.88, page 91, December 1977); and in
     Astronomical Algorithms (1991) by Jean Meeus.

     This algorithm holds for any year in the Gregorian Calendar, which
     (of course) means years including and after 1583.

        a=year%19
        b=year/100
        c=year%100
        d=b/4
        e=b%4
        f=(b+8)/25
        g=(b-f+1)/3
        h=(19*a+b-d-g+15)%30
        i=c/4
        k=c%4
        l=(32+2*e+2*i-h-k)%7
        m=(a+11*h+22*l)/451
        Easter Month =(h+l-7*m+114)/31  [3=March, 4=April]
        p=(h+l-7*m+114)%31
        Easter Date=p+1     (date in Easter Month)

     Note: Integer truncation is already factored into the
     calculations. Using higher percision variables will cause
     inaccurate calculations. 
*/

/*
   Nota de Jorge Puente:
   No me pregunten por qué la fórmula anterior no usa las letras "j", "n" y "o",
   así aparecía en el listado de Java. Asimismo la línea que dice "Using higher
   percision variables" se tomó tal como aparece en el listado, pero debe ser
   "Using higher precision variables"
*/

function Pascua() {
  var Hoy = new Date(), EsteAnho, MesPascua, DomingoPascua;
  
  if (Hoy.getFullYear() < 1900) {
    EsteAnho = Hoy.getFullYear() + 100; }
  else {
    EsteAnho = Hoy.getFullYear(); }

  var a = EsteAnho % 19;
  var b = Math.floor(EsteAnho / 100);
  var c = EsteAnho % 100;
  var d = Math.floor(b / 4);
  var e = b % 4;
  var f = Math.floor((b + 8) / 25);
  var g = Math.floor((b - f + 1) / 3);
  var h = (19 * a + b - d - g + 15) % 30;
  var i = Math.floor(c / 4);
  var k = c % 4;
  var l = (32 + 2 * e + 2 * i - h - k) % 7;
  var m = Math.floor((a + 11 * h + 22 * l) / 451);
  MesPascua = Math.floor((h + l - 7 * m + 114) / 31);
  var p = (h + l - 7 * m + 114) % 31;
  DomingoPascua = p + 1;

    var finCuaresma = new Date(EsteAnho, MesPascua-1, DomingoPascua);
    var inicioCuaresma2 = new Date(finCuaresma - (46 * 24 * 60 * 60 * 1000));
//  Debido a que en ocasiones el Domingo de Pascua cae en el horario de verano y el Miércoles de Ceniza no,
//  JavaScript "quita" una hora extra por la diferencia de horario y reporta el Miércoles de Ceniza como el
//  martes a las 23:00:00 en lugar del miércoles a las 00:00:00
//  Por eso fue necesario agregar alguna forma de obtener dicha diferencia.
//  Para la Ciudad de México la función getTimezoneOffset() reporta 300 (5 horas * 60 minutos) para el
//  horario de verano y 360 (6 horas * 60 minutos) para el horario normal. Al hacer la diferencia entre los dos
//  valores (Cuaresma y FechaPascua) obtenemos el valor que hay que agregar al reportado por JavaScript para
//  el miércoles de Ceniza. En caso de que ambas fechas "caigan" en el horario normal la diferencia será 0 y
//  por lo tanto no se agregará nada a la fecha del Miércoles de Ceniza.
    var inicioCuaresma = new Date(inicioCuaresma2 - (finCuaresma.getTimezoneOffset() - inicioCuaresma2.getTimezoneOffset()) * 60 * 1000);

  if ((Hoy.getTime() <= finCuaresma) && (Hoy.getTime() >= inicioCuaresma)) {
    document.write ('<small><A href="#" onClick = "window.open(');
    document.write ("'cuaresma.htm','cuaresma','height=245,width=396,resizable=1,scrollbars=yes')");
    document.write ('" onMouseOver="cambiaColorEnlace(this)" onMouseOut="regresaColorEnlace(this)"');
    document.writeln ('>Aviso de Cuaresma</a></small></font>');
  }
}

// Calcula y presenta la fecha de hoy
function fecha()
{

  var nombre_mes = new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
  var nombre_dia = new Array("Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado");
  var hoy = new Date();

  document.write(nombre_dia[hoy.getDay()], " ");
  document.write(hoy.getDate(), " de ");
  document.write(nombre_mes[hoy.getMonth()], " de ");
  if (hoy.getFullYear() < 2000) document.write(hoy.getFullYear() + 100);
  else document.write(hoy.getFullYear());
}
