// Function NewWindow: Abre una ventana nueva (pop up)
// Parámetros:
// 		myurl - dirección que se abrirá en esta ventana
// 		myname - nombre de esta ventana
// 		w - ancho
// 		h - alto
// 		scroll - indica si tiene scroll


function NewWindow(myurl,myname, w, h, scroll) {
var winl = (screen.width)  ? (screen.width - w) / 2 : 0;
var wint = (screen.height) ? (screen.height - h) / 2 :0 ;
winprops='height='+h+',width='+w+',top='+wint+',left='+winl+', scrollbars='+scroll+',resizable';
winnewsub =window.open(myurl,myname,winprops);
if (parseInt(navigator.appVersion) >= 4) { winnewsub.window.focus(); }
}


/* funcioón que devuelve una cadena sin espacios por delante y por detrás */
function ignoreSpaces(string) {
  var temp = "";
  string = '' + string;
  splitstring = string.split(" ");
  for(i = 0; i < splitstring.length; i++)
	temp += splitstring[i];
  return temp;
}

function y2k(number) {
  return (number < 1000) ? number + 1900 : number;
}


function checkEmail2(Texto) {
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Texto)){
	return (true);
  }
/*  var mensaje="La direción de correo introducida no es correcta.\n"
  mensaje += "Es posible que haya introducido caracteres no válidos.\n"
  mensaje += "Por favor, escríbala de nuevo."
  alert(mensaje);*/
  return (false);
}


function isDate (day,month,year) {
// checks if date passed is valid
// will accept dates in following format:
// isDate(dd,mm,ccyy), or
// isDate(dd,mm) - which defaults to the current year, or
// isDate(dd) - which defaults to the current month and year.
// Note, if passed the month must be between 1 and 12, and the
// year in ccyy format.
  var today = new Date();
  year = ((!year) ? y2k(today.getYear()):year);
  month = ((!month) ? today.getMonth():month-1);
  if (!day) return false;
  var test = new Date(year,month,day);
  if ( (y2k(test.getYear()) == year) &&
	 (month == test.getMonth()) &&
	 (day == test.getDate()) )
	return true;
  else
	return false;
}


