// JavaScript Document

function display_date() {

   date = new Date();

   var day_of_week_number = date.getDay();
   var day_of_month = date.getDate();
   var month_number = date.getMonth();
   var year = date.getYear();
   var Vfullyear = date.getFullYear();
   var day_of_week = '';
   var month = ''

   if(month_number == 0){month = 'Enero';}
   if(month_number == 1){month = 'Febrero';}
   if(month_number == 2){month = 'Marzo';}
   if(month_number == 3){month = 'Abril';}
   if(month_number == 4){month = 'Mayo';} 
   if(month_number == 5){month = 'Junio';}
   if(month_number == 6){month = 'Julio';}
   if(month_number == 7){month = 'Agosto';}
   if(month_number == 8){month = 'Septiembre';}
   if(month_number == 9){month = 'Octubre';}
   if(month_number == 10){month = 'Noviembre';}
   if(month_number == 11){month = 'Diciembre';}


   if(day_of_week_number == 0){day_of_week = 'Domingo';}
   if(day_of_week_number == 1){day_of_week = 'Lunes';}
   if(day_of_week_number == 2){day_of_week = 'Martes';}
   if(day_of_week_number == 3){day_of_week = 'Miércoles';}
   if(day_of_week_number == 4){day_of_week = 'Jueves';}
   if(day_of_week_number == 5){day_of_week = 'Viernes';}
   if(day_of_week_number == 6){day_of_week = 'Sábado';}

  var date_to_show = '<B>'+ day_of_week + '</B> ' + day_of_month + ' de ' + month + ' de ' + Vfullyear; 

   document.write( date_to_show );
}

function Pintar(src, clrOver) {
	if (!src.contains(event.fromElement)) {
		src.style.cursor = 'hand';
		src.bgColor = clrOver;
	}
}

function Despintar(src, clrIn) {
	if (!src.contains(event.toElement)) {
		src.style.cursor = 'default';
		src.bgColor = clrIn;
	}
}

function Cliquear(src) {
	if (event.srcElement.tagName=='TD'){
		src.children.tags('A')[0].click();
	}
}

function verdatos(f)
{
	if (f.value == "add")
	{
		document.all.formu.style.display = "";
		document.all.text.style.display = "none";
	}
	else
	{
		document.all.formu.style.display = "none";
		document.all.text.style.display = "";
	}

}

function isNotEmpty(elem)
{
	var str = elem.value;
    if(str == null || str.length == 0 || str == 'Ingrese su email') {
        alert("Debe ingresar su dirección de email.");
        return false;
    } else {
        return true;
    }

}

function isEMailAddr(elem)
{
    var str = elem.value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        alert("La dirección de email no es correcta.");
        return false;
    } else {
        return true;
    }
}

function isCheckedRadio(group)
{
    for (var i = 0; i < group.length; i++)
	{
		if (group[i].checked)
		{
			return true;	
		}
	}
	
	alert("Debe seleccionar suscribir o desuscribir.");
	return false;
}

function validarForm(form)
{
	if (isNotEmpty(form.email))
	{
		if (isEMailAddr(form.email))
		{
			if(isCheckedRadio(form.operacion))
			{
				return true;	
			}
		}
	}
	return false;
	
}


function pasarQuery(url)
{
	var datos = document.forms[0].q.value;
	location.href = url + "?q=" + escape(datos);
}

function focus_nombre()
{
document.getElementById("nombre").focus();
}

function borrartexto() {
	document.getElementById("texto").value="";
}

function controlmail() {
	if (document.getElementById("nombre").value==""){
       alert("No ha escrito su Nombre");
	   document.getElementById("nombre").focus();
	   return false;
	}

	if (document.getElementById("apellido").value==""){
       alert("No ha escrito su Apellido");
       document.getElementById("apellido").focus();
	   return false;
	}

	if (document.getElementById("email").value==""){
       alert("No ha escrito su direccion de E-Mail");
	   document.getElementById("email").focus();
	   return false;
	}

	if (document.getElementById("email").value.indexOf("@") == -1){
    	 alert("Direccion de E-Mail invalida.")
		 document.getElementById("email").value=""
		 document.getElementById("email").focus()
		 return false;
	}
 	else {
	     return true;
    }
}

function AbrirVentana(link,nombre,condiciones)
{
 window.open(link,nombre,condiciones);
}


function detectar_resolucion(ancho,alto){
	if ((ancho>=1024) && (alto>=768))
		{
			document.body.style.overflow='hidden';
		}
	else
		{
			document.body.style.overflow='';
		}
}