var v_text = "Esta aplicación está disponible solamente a través del Intranet Corporativo.";

if (document.URL.toUpperCase().substr(0,5) == 'HTTPS')
{
	v_path = "../images/";
}
else
{
	v_path = "images/";
}

function launch_window(url, name, str)
{
	str = str + ',resizable=yes,status=yes,toolbar=yes,scrollbars=yes';
	window.open(url, name, str);
}

function changeBG(tdid, thecolor1, thecolor2, thesize)
{
	document.getElementById(tdid).style.color = thecolor1;
	document.getElementById(tdid).style.backgroundColor = thecolor2;

	if (thesize == '1')
	{
		document.getElementById(tdid).style.border = '#E7EFCE solid 1px';
		document.getElementById(tdid).style.borderColor = '#005000';
	}
	else
	{
		document.getElementById(tdid).style.border = '#FFFFE5 solid 0px';
	}
}

function gen_com(theyear, thecnt)
{
	var v_today = new Date();
	var v_year = v_today.getFullYear();
	for (cntr=1; cntr<19; cntr++)
	{
		i = cntr + '-N';
		document.getElementById(i).innerHTML  = '<p style=text-align:left>&nbsp;</p>';
		j = cntr + '-T';
		document.getElementById(j).innerHTML  = '<p style=text-align:left>&nbsp;</p>';
	}
	if (theyear == null)
	{
		theyear = document.forms[0].elements[0].id.substr(0,4);
		z = 0;
		for (cntr = 0; cntr < document.forms[0].elements.length; cntr++)
		{
			if (document.forms[0].elements[cntr].id.substr(0,4) == theyear )
			{
				z++;
			}
		}

		thecnt = z / 2;
	}
	document.getElementById('table_header').innerHTML = '<p style=text-align:left;color:black;>Comunicados:&nbsp;<b>' + theyear + '</b></p>';
	for (cntr=1; cntr<thecnt+1; cntr++)
	{
		x = theyear + '-' + cntr + '-N';
		i = cntr + '-N';
		document.getElementById(i).innerHTML = document.getElementById(x).value;
		x = theyear + '-' + cntr + '-T';
		i = cntr + '-T';
		document.getElementById(i).innerHTML = document.getElementById(x).value;
	}
}

function gen_rep(theyear, thecnt)
{
	for (cntr=1; cntr<5; cntr++)
	{
		x = cntr + '-X';
		switch (cntr)
		{
		case 1:
			document.getElementById(x).innerHTML  = '<p style=text-align:left;>Estadísticas</p>';
			break;
		case 2:
			document.getElementById(x).innerHTML  = '<p style=text-align:left;>Estados Financieros</p>';
			break;
		case 3:
			document.getElementById(x).innerHTML  = '<p style=text-align:left;>Gráficas</p>';
			break;
		case 4:
			document.getElementById(x).innerHTML  = '<p style=text-align:left;>Flujo de Caja</p>';
			break;
		}
		for (colscnt=1; colscnt<13; colscnt++)
		{
			x = cntr + '-' + colscnt;
			document.getElementById(x).innerHTML  = '<p style=text-align:left;>&nbsp;&nbsp;&nbsp;</p>';
		}
	}
	if (theyear == null)
	{
		theyear = document.forms[0].elements[0].id.substr(0,4);
	}

	z = 0;
	for (cntr = 0; cntr < document.forms[0].elements.length; cntr++)
	{
		if (document.forms[0].elements[cntr].id.substr(0,4) == theyear )
		{
			z++;
		}
	}

	thecnt = z / 4;
	document.getElementById('table_header').innerHTML =  '<p style=text-align:left;color:black;>Informes:&nbsp;<b>' + theyear + '</b></p>';

	for (cntr = 1; cntr < thecnt + 1; cntr++)
	{
		for (colscnt = 1; colscnt < 4 + 1; colscnt++)
		{
			x = theyear + '-' + cntr + '-' + colscnt;
			y = colscnt + '-' + cntr;
			document.getElementById(y).innerHTML  = document.getElementById(x).value;
		}
	}
}

function gotoUrl(mystring)
{
	var mypos = mystring.indexOf("#");
	var myurl = mystring;
	if (mypos >= 0)
	{
		myurl = mystring.substr(0,mypos);
	}
	location=myurl;
}

function the_header(p_tab)
{
	document.write("	<div id=header>");
	document.write("		<h1>Sistema de Retiro</h1>");
	document.write("		<div id='menu'>");
	document.write("			<ul id='nav'>");
	//document.write("				<li id='inicio' class='activelink'><a href=index.htm>Inicio</a></li>");

	if (document.URL.toUpperCase().substr(0,10) == 'HTTP://WWW')
	{
		document.write("				<li id='inicio'><a href=http://www.aeepr.com/retiro>Inicio</a></li>");
	}
	else
	{
		document.write("				<li id='inicio'><a href=http://retiro>Inicio</a></li>");
	}

	document.write("				<li id='oficinas'><a href=oficinas.htm>Oficinas</a></li>");
	document.write("				<li id='biblioteca'><a href=biblioteca.htm>Biblioteca</a></li>");

	if (document.URL.toUpperCase().substr(0,10) == 'HTTP://WWW')
	{
		document.write("				<li id='portal-internet' onClick=alert(v_text);><a href=#><img valign=bottom border=0 src=images/mini_padlock.gif>&nbsp;Portal</a></li>");
		document.write("				<li id='prepa-internet'><a href=http://www.aeepr.com target=_blank>AEE</a></li>");
	}
	else
	{
		document.write("				<li id='portal-intranet' onClick=launch_window('https://retiro/portal/servicios.htm','full','menubar=no');><a href=#><img border=0 valign=bottom src=images/mini_padlock.gif>&nbsp;Portal</a></li>");
		document.write("				<li id='prepa-intranet'><a href=http://intranet target=_blank>AEE</a></li>");
	}
	document.write("			</ul>");
	document.write("		</div>");
	document.write("	</div>");
	document.getElementById(p_tab).setAttribute('className','activelink');
	document.getElementById(p_tab).setAttribute('class','activelink');
}

function the_footer()
{
	document.write("	<div id='footer'>");
	document.write("		<p>Sistema de Retiro de los Empleados de la Autoridad de Energía Eléctrica</p>");
	document.write("		<p style='font-size: 65%'>Para comentarios o sugerencias sobre nuestra página, favor dirija su correspondencia a:&nbsp;<a href=mailto:retiro@prepa.com>Sistema de Retiro</a></p>");
	document.write("		<p style='font-size: 65%'>Derechos Reservados&copy; 2001-2011 Autoridad de Energía Eléctrica.");
	document.write("	</div>");
}

function get_adobe()
{
	v_image = "	<img border=0 src=" + v_path + "getadobereader.jpg" + "></a></p>";

	document.write("	<p style='text-align:left;'>Necesita <em>Adobe Acrobat Reader</em>");
	document.write("	para accesar los documentos.  Adquiérelo aquí:</p>");
	document.write("	<p style='text-align:center;'>");

	if (document.URL.toUpperCase().substr(0,10) == 'HTTP://WWW')
	{
		document.write("	<a id=adobe_internet href=http://get.adobe.com/reader target=_blank>");
	}
	else
	{
		document.write("	<a id=adobe_intranet href=programas/adobe_reader.exe target=_blank>");
	}

	document.write(v_image);
}

function menu_biblioteca()
{
	document.write("	<p style='text-align:right;'><a href=boletin.htm>Boletín: Retiro al Día</a></p>");
	document.write("	<p style='text-align:right;'><a href=calendario.htm>Calendario Retiro</a></p>");
	document.write("	<p style='text-align:right;'><a href=comunicados.htm>Comunicados</a></p>");
	document.write("	<p style='text-align:right;'><a href=dir_telefonico.pdf target=_blank>Directorio Telefónico</a></p>");
	document.write("	<p style='text-align:right;'><a href=formularios.htm>Formularios</a></p>");
	document.write("	<p style='text-align:right;'><a href=galeria.htm>Galería Administradores</a></p>");
	document.write("	<p style='text-align:right;'><a href=informes_junta.htm>Informes a la Junta</a></p>");
	document.write("	<p style='text-align:right;'><a href=manuales.htm>Manuales</a></p>");
	document.write("	<p style='text-align:right;'><a href=procedimientos.htm>Procedimientos</a></p>");
	document.write("	<p style='text-align:right;'><a href=reglamentos.htm>Reglamentos</a></p>");
}

function menu_oficinas(p_sub)
{
	document.write("	<p style='text-align:right;'><a href=oficina_administrador.htm>Oficina Administradora</a></p>");

	if (p_sub == 'administrador')
	{
		document.write("	<p class=minimenu style='text-align:right;font-size:80%;'><a href=comunicados.htm>- Comunicados&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></p>");
		document.write("	<p class=minimenu style='text-align:right;font-size:80%;'><a href=informes_junta.htm>- Informes a la Junta&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></p>");
//		document.write("	<p class=minimenu style='text-align:right;font-size:80%;'><a href=otros/logros_2008.pdf target=_blank>- Logros Año 2008&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></p>");
//		document.write("	<p class=minimenu style='text-align:right;font-size:80%;'><a href=otros/progreso_de_metas_2009.pdf target=_blank>- Metas 2009&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></p>");
	}

	document.write("	<p style='text-align:right;'><a href=junta_sindicos.htm>Junta de Síndicos</a></p>");
	document.write("	<p style='text-align:right;'><a href=dept_pensiones.htm>Pensiones y Beneficios</a></p>");

	if (p_sub == 'pensiones')
	{
		document.write("	<p class=minimenu style='text-align:right;font-size:80%;'><a href=acreditacion_tiempo.htm>- Acreditación de Tiempo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></p>");
		document.write("	<p class=minimenu style='text-align:right;font-size:80%;'><a href=tipos_pension.htm>- Tipos de Pensión&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></p>");
		document.write("	<p class=minimenu style='text-align:right;font-size:80%;'><a href=beneficios_jubilacion.htm>- Beneficios por Jubilación&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></p>");
	}

	document.write("	<p style='text-align:right;'><a href=dept_prestamos.htm>Préstamos</a></p>");

	if (p_sub == 'prestamos')
	{
		document.write("	<p class=minimenu style='text-align:right;font-size:80%;'><a href=calculadora_hipotecaria.htm>- Calculadora Hipotecaria&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></p>");
		document.write("	<p class=minimenu style='text-align:right;font-size:80%;'><a href=secc_hipotecarios.htm>- Préstamos Hipotecarios&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></p>");
		document.write("	<p class=minimenu style='text-align:right;font-size:80%;'><a href=propiedades.htm>- Propiedades a la venta&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></p>");
	}

	document.write("	<p style='text-align:right;'><a href=dept_contabilidad.htm>Contabilidad y Finanzas</a></p>");
}

function loan_calc()
{
	P = document.calc.principal.value * 1;
	I = document.calc.interes.value * 1;
	T = document.calc.termino.value * 1;

	if (T <= 0 || P <= 0 || I <= 0)
	{
		document.calc.principal.focus();
		window.alert("No inserte números menores o igual a cero.");
	}
	else
	{
		if (isNaN(T) == true || isNaN(P) == true  || isNaN(I) == true)
		{
			document.calc.principal.focus();
			window.alert("No inserte comas, letras u otros caracteres no numéricos.");
		}
		else
		{
			t1 = T * 12;
			t2 = (I / 100 / 12);
			t3 = (1 + t2);
			t4 = Math.pow(t3,t1);
			t5 = Math.pow(t3,t1);
			t5 = t5 - 1;
			t6 = t4 / t5;
			pago = (P * t2 * t6);

			if (pago > 0)
			{
				pago = Math.round(pago * 100) / 100;
			}
			else
			{
		        document.calc.principal.focus();
				window.alert("No entre letras o números menores o igual a cero.");
				pago = (0.00);
			}

// Desplega el resultado
			document.getElementById('mensualidad').style.display = '';
			document.getElementById('nota').style.display = '';
			document.calc.pago.value = pago;
		}

	}

// //var princ = document.calc.loan.value;
// //var term  = document.calc.months.value;
// //var intr   = document.calc.rate.value / 1200;
// //document.calc.pay.value = princ * intr / (1 - (Math.pow(1/(1 + intr), term)));

}

function loan_reset()
{
	document.getElementById('mensualidad').style.display = 'none';
	document.getElementById('nota').style.display = 'none';
	document.calc.reset();
}
// End -->

