
var pong;
function makeArray(n){
  this.length = n;
  for (i=1;i<=n;i++){
    this[i]=0;
  }
  return this;
}

// standard date display function with y2k compatibility
function displayDate() {
  var this_month = new makeArray(12);
  this_month[0]  = "Enero";
  this_month[1]  = "Febrero";
  this_month[2]  = "Marzo";
  this_month[3]  = "Abril";
  this_month[4]  = "Mayo";
  this_month[5]  = "Junio";
  this_month[6]  = "Julio";
  this_month[7]  = "Agosto";
  this_month[8]  = "Septiembre";
  this_month[9]  = "Octubre";
  this_month[10] = "Noviembre";
  this_month[11] = "Deciembre";

  var this_day_e = new makeArray(7);
  this_day_e[0]  = "Domingo";
  this_day_e[1]  = "Lunes";
  this_day_e[2]  = "Martes";
  this_day_e[3]  = "Miércoles";
  this_day_e[4]  = "Jueves";
  this_day_e[5]  = "Viernes";
  this_day_e[6]  = "Sábado";

  var today = new Date();
  var day   = today.getDate();
  var month = today.getMonth();
  var year  = today.getYear();
  var dia = today.getDay();
    if (year < 1000) {
       year += 1900; }
  return(this_day_e[dia] + ", "+ day + " de " + this_month[month] + " " + year);
}

function calendario(ref, formulario){
	calenwin=window.open('calendario.php?formulario='+formulario+'&form='+ref,'calendario','status=no,scrollbars=no,resizable=no,width=150,height=141');
	//alert(ref+" "+formulario);
//	alert('calendario.php?formulario='+formulario+'&form='+ref);
	calenwin.focus();
}

function validar(){
	var msg="";
	/*if(document.busca_news.cadenaBusqueda.value=="")
		 msg+="-------------------------------------------------------\nNo ha introducido cadena de búsqueda\n";
		 
	if(document.busca_news.desde.value!="" && document.busca_news.hasta.value=="")
		msg+="Falta fecha hasta\n-------------------------------------------------------";
	
	if(document.busca_news.hasta.value!="" && document.busca_news.desde.value=="")
		msg+="Falta fecha desde\n-------------------------------------------------------";
	*/
	if(document.busca_news.cadenaBusqueda.value=="" && document.busca_news.hasta.value=="" && document.busca_news.desde.value==""){
		//msg+="Falta fecha desde\n-------------------------------------------------------";
		msg+="Debe introducir algun criterio de busqueda\n-------------------------------------------------------";
	}
	if(msg=="")
		document.busca_news.submit();
	else alert(msg);
		 
		
}

function ampliar(foto,ancho,alto) {
	ancho=ancho+20;
	alto=alto+20;
	window.open("img/noticias/"+foto, "foto", "width="+ancho+",height="+alto+",resizable=yes");
}


function emailCheck (emailStr) {
/* Verificar si el email tiene el formato user@dominio. */
var emailPat=/^(.+)@(.+)$/ 

/* Verificar la existencia de caracteres. ( ) < > @ , ; : \ " . [ ] */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]" 

/* Verifica los caracteres que son válidos en una dirección de email */
var validChars="\[^\\s" + specialChars + "\]" 

var quotedUser="(\"[^\"]*\")" 

/* Verifica si la dirección de email está representada con una dirección IP Válida */ 


var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/


/* Verificar caracteres inválidos */ 

var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/*domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
alert("Email address seems incorrect (check @ and .'s)")
return false
}
var user=matchArray[1]
var domain=matchArray[2]

// Si el user "user" es valido 
if (user.match(userPat)==null) {
// Si no
alert("El nombre de usuario no es válido.")
return false
}

/* Si la dirección IP es válida */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("IP de destino inválida")
return false
}
}
return true
}

var domainArray=domain.match(domainPat)
if (domainArray==null) {
alert("El dominio parece no ser válido.")
return false
}

var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
domArr[domArr.length-1].length>3) { 

alert("La dirección debe tener 3 letras si es .com o 2 si en de algún pais.")
return false
}

if (len<2) {
var errStr="La dirección es erronea"
alert(errStr)
return false
}

// La dirección de email ingresada es Válida
return true;
}



