//funcion contra el spam
function antispam(cuenta,clase)
{
var dominio = "sercasaejido.com"
document.write("<a class='"+ clase +"' href=\"mailto:" + cuenta + "@" + dominio + "\">" + cuenta + "@" + dominio + "</a>");
}


// funciones para la fecha y hora
function fecha(){
	var mydate=new Date();
	var year=mydate.getYear();

	if (year < 1000)
		year+=1900;
		
	var day=mydate.getDay();
	var month=mydate.getMonth();
	var daym=mydate.getDate();

	if (daym<10)
	daym="0"+daym;

	var dayarray=new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sábado");
	var montharray=new Array("Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic");
	document.write(dayarray[day] + " " + daym + " " + montharray[month] + "." + year);
}

function hora(){
	if (!document.layers&&!document.all&&!document.getElementById)

	return
	var Digital=new Date()
	var hours=Digital.getHours()
	var minutes=Digital.getMinutes()
	var seconds=Digital.getSeconds()
	var dn="AM" 
	if (hours>12){
	dn="PM"
	hours=hours-12
	}

	if (hours==0)
	hours=12
	
	if (hours<=9)
	hours="0"+hours

	if (minutes<=9)
	minutes="0"+minutes

	if (seconds<=9)
	seconds="0"+seconds

	//change font size here to your desire

	myclock=hours+":"+minutes+":"+seconds

	if (document.layers){
	document.layers.liveclock.document.write(myclock)
	document.layers.liveclock.document.close()
	}
	else if (document.all)
	liveclock.innerHTML=myclock
	else if (document.getElementById)
	document.getElementById("liveclock").innerHTML=myclock
	setTimeout("hora()",1000)
}

function googlekey(keyabajo,kayarriba,domabajo,domarriba){
	var documento = self.location.href.match( /\/([^/]+)$/ )[1];
	if (document.location.href == 'http://servidor.'+ domabajo +'/'+ documento)
	{
		document.write("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;ln=en&amp;key="+ keyabajo +"' type='text/javascript'></script>");
	}
	else
	{
		if (document.location.href == 'http://'+ domarriba +'/'+ documento);
		{
			document.write("<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;ln=en&amp;key="+ kayarriba +"' type='text/javascript'></script>");
		}
	}
}

//SIMULADOR HIPOTECARIO
//----------------------------------------------------------------------------------------------
// Carga mediante AJAX 
function nuevoAjax()
{ 
		/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por 
		lo que se puede copiar tal como esta aqui */ 
		var xmlhttp=false; 
		try 
		{ 
		// Creacion del objeto AJAX para navegadores no IE 
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
		} 
		catch(e) 
		{ 
		try 
		{ 
		// Creacion del objet AJAX para IE 
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; } 
		} 
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 
		
		return xmlhttp; 
} 

function cargarcuadro()
{
	var capital;
	var interes;
	var anos;
	var capa;
	
	capital=document.getElementById("capital").value;
	interes=document.getElementById("interes").value;
	anos=document.getElementById("anos").value;

	ajax=nuevoAjax();

	num = Math.random() * 42587; 
    num = Math.round(num);
	ajax.open("GET", "./cgi-bin/cuadro.exe/cuadro?capital="+capital+"&interes="+interes+"&anos="+anos+"&periodicidad=12", true);
	ajax.onreadystatechange=function() 
	{ 
		if (ajax.readyState==1)
		{
			capa=document.getElementById("tablacuadro");
			capa.innerHTML="Cargando...";
		}
		if (ajax.readyState==4)
		{ 
			document.getElementById("tablacuadro").innerHTML=ajax.responseText;			
		} 
	}
	ajax.send(null);
}

// ----------------------------------------------------------------------------------
//Función que permite solo meter enteros en un INPUT
function esEntero(e){
	var charCode
	
	if (navigator.appName == "Netscape") // Veo si es Netscape o Explorer (mas adelante lo explicamos)
		charCode = e.which // leo la tecla que ingreso
	else
		charCode = e.keyCode // leo la tecla que ingreso
	status = charCode 
	if (charCode > 31 && (charCode < 48 || charCode > 57)) { // Chequeamos que sea un numero comparandolo con los valores ASCII
		return false
	}
return true
}

// ----------------------------------------------------------------------------------
//Función que permite solo meter decimales en un INPUT
function esDecimal(campo,e){
	var charCode,i,decimales
	decimales = 0
	
	if (navigator.appName == "Netscape") // Veo si es Netscape o Explorer (mas adelante lo explicamos)
		charCode = e.which // leo la tecla que ingreso
	else
		charCode = e.keyCode // leo la tecla que ingreso
	status = charCode 
	//No deja escribir caracteres que no sean numeros, punto o coma
	if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 44 && charCode != 46) {
		return false;
	}
	else{
		for (i=0;i<campo.value.length;i++){
			if ((campo.value.charAt(i)==".") || (campo.value.charAt(i)==",")){
				decimales = 1;
			}
		}
		if (decimales == 1){
			if ((charCode == 44) || (charCode == 46)){
				return false;
			}
			else{
				return true;	
			}
		}
		else{
			return true;	
		}
	}
}


var opcion;


function actualizar_menu(){

	var boton;
	var boton_url;
	
	var boton_promocion = document.getElementById('bot_promocion');
	var boton_informacion = document.getElementById('bot_informacion');
	var boton_memoria = document.getElementById('bot_memoria');	
	var boton_planos = document.getElementById('bot_planos');
	var boton_perspectivas = document.getElementById('bot_perspectivas');
	var boton_imagenes = document.getElementById('bot_imagenes');
	
	boton_promocion.className = "menu_promociones";
	boton_informacion.className = "menu_promociones";
	boton_memoria.className = "menu_promociones";
	boton_planos.className = "menu_promociones";
	boton_perspectivas.className = "menu_promociones";
	boton_imagenes.className = "menu_promociones";
	
	boton = "bot_"+ opcion;
	boton_url = document.getElementById(boton);
	boton_url.className = "menu_promociones_on";
	boton_url.onClick = "";
	boton_url.onmouseover = "";
	boton_url.onmouseout = "";
}




function promocion(capa){
	
	opcion = capa;
	
	var capa_promocion = document.getElementById('promocion');
	var capa_informacion = document.getElementById('informacion');
	var capa_memoria = document.getElementById('memoria');	
	var capa_planos = document.getElementById('planos');
	var capa_perspectivas = document.getElementById('perspectivas');
	var capa_imagenes = document.getElementById('imagenes');
	
	actualizar_menu();
	
	if (capa == "promocion")
	{
		capa_promocion.style.display='';
		capa_informacion.style.display='none';
		capa_memoria.style.display='none';
		capa_planos.style.display='none';
		capa_perspectivas.style.display='none';
		capa_imagenes.style.display='none';						
	}
	if (capa == "informacion")
	{
		capa_promocion.style.display='none';
		capa_informacion.style.display='';
		capa_memoria.style.display='none';
		capa_planos.style.display='none';
		capa_perspectivas.style.display='none';
		capa_imagenes.style.display='none';						
	}
	if (capa == "memoria")
	{
		capa_promocion.style.display='none';
		capa_informacion.style.display='none';
		capa_memoria.style.display='';
		capa_planos.style.display='none';
		capa_perspectivas.style.display='none';
		capa_imagenes.style.display='none';						
	}
	if (capa == "planos")
	{
		capa_promocion.style.display='none';
		capa_informacion.style.display='none';
		capa_memoria.style.display='none';
		capa_planos.style.display='';
		capa_perspectivas.style.display='none';
		capa_imagenes.style.display='none';						
	}
	if (capa == "perspectivas")
	{
		capa_promocion.style.display='none';
		capa_informacion.style.display='none';
		capa_memoria.style.display='none';
		capa_planos.style.display='none';
		capa_perspectivas.style.display='';
		capa_imagenes.style.display='none';						
	}				
	if (capa == "imagenes")
	{
		capa_promocion.style.display='none';
		capa_informacion.style.display='none';
		capa_memoria.style.display='none';
		capa_planos.style.display='none';
		capa_perspectivas.style.display='none';
		capa_imagenes.style.display='';						
	}	
}
