// 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;
}


/* Función que hace aparecer una playa ocultando la que ya está a la vista*/
function AparecePlaya(num,numPlayas){
	//oculto las otras capas
	for (cont=1;cont<=5;cont++){
		if (num!=cont){
			Effect.Fade('playa' + cont);
		}
	}
	//muestro la playa que quiero
	Effect.Appear('playa' + num,0.90);
}

/* Función que comprueba el campo de búsqueda de la página de inicio */
function ComprobarBusqueda(txt_introduzca){
	if (ignoreSpaces(document.getElementById('frm_buscar').buscar.value) == ""){
		alert(txt_introduzca);
		document.getElementById('frm_buscar').buscar.focus();
		return false;
	}
}

/* Función que carga un cover y marca en la lista de covers el que se ha cargado*/
function CargaCover(rutaCover,nombreCover,tipoCover,idEnlace){
	if (tipoCover =="I"){ //introduzco una imagen
		document.getElementById('flash_inicio').innerHTML = "<img src=\"" + rutaCover + "\" alt=\"" + nombreCover + "\" />";//            "<%=URLImagen%>" width="<%=Width%>" height="<%=Height%>" alt="">;
	}
	else{ //introduzco un flash
	var flash;
	flash = "<object type=\"application/x-shockwave-flash\" data=\"" + rutaCover + "\" width=\"474\" height=\"219\">";
	flash += "<param name=\"movie\" value=\"" + rutaCover + "\" />";
	flash += "<param name=\"quality\" value=\"high\" />";
	flash += "<param name=\"menu\" value=\"false\" />";
	flash += "</object>";
		document.getElementById('flash_inicio').innerHTML = flash;
	}
	// desmarco todos los números de cover
	var enlaces=document.getElementById('barra_numerada').getElementsByTagName('A');
	for(a=0;a<enlaces.length;a++){
		enlaces[a].className = '';
	}
	
	//A continuación marcaré el número del cover cargado
	document.getElementById('enlace' + idEnlace).className = 'selected';
}

/* Función que carga un cover y prepara las vables. de entorno para cargar el siguiente*/
function CarruselCovers(){
	CargaCover(arrayURLs[coverActual],arrayNombres[coverActual],arrayTipos[coverActual],arrayIDEnlace[coverActual]);
	coverActual++;
	if (coverActual>numCovers){
		coverActual = 1;
	}
}