<!--------------------------------INICIO FUNCIONES ADMIN------------------------------------>
var error;
var error_nm;
var error_ap;
var error_dn;
var error_ns;
var error_fn;
var error_nk;
var error_pw;
var error_cp;
var error_tt;
var error_lc;
var errormsg;

//--------------------------Customise-------------------------------
var isnomReq=true; // True if Name field required else False
var isapeReq=true; // True if Address field required else False
var isdniReq=true; // True if Name DNI required else False
var issocReq=true; // True if Name socio required else False
var isnacReq=true; // True if Name nacim required else False
var isnicReg=true; // True if Name username required else False
var ispasReg=true; // True if Name password required else False
var ispa2Reg=true; // True if Name password required else False
var istitReq=true; // True if Name titulacion required else False
var islicReq=true; // True if Name licencia required else False
//------------------------------------------------------------------

function reset_error(){
 error_nm=false;
 error_ap=false;
 error_dn=false;
 error_ns=false;
 error_fn=false;
 error_nk=false;
 error_pw=false;
 error_cp=false;
 error_tt=false;
 error_lc=false;
 errormsg='Se han econtrado los siguientes errores:\n_____________________________\n\n';
}
// ..................................... nombre
function validate_nombre()
{
 if(isnomReq)
 {
  if(document.User.txtfirstname.value=="")
  {
   errormsg+='El nombre no puede quedar en blanco.\n';
   error_nm=true;
   document.User.txtfirstname.focus();
  }
 }
}

// ..................................... apellido
 function validate_apellido()
{
 if(isapeReq)
 {
  if(document.User.txtlastname.value=="")
  {
   errormsg+='El apellido no puede quedar en blanco.\n';
   error_ap=true;
      if(!error_nm)
    {
    document.User.txtlastname.focus();
   }
  }
 } 
}

// ..................................... DNI
 function validate_dni() 
{
 if(isdniReq)
 {
  if(document.User.txtDNI.value=="")
  {
   errormsg+='El NIF no puede quedar en blanco.\n';
   error_dn=true;
   if((!error_n)&&(!error_ad))
   {   
   document.User.txtDNI.focus();
   }
  }
 }
}

// ..................................... socio
  function validate_socio()
{
 if(issocReq)
 {
  if(document.User.txtsocio.value=="")
  {
   errormsg+='El número de socio no puede quedar en blanco.\n';
   error_ns=true;
      if((!error_n)&&(!error_ad)&&(!error_dn))
   {  
   document.User.txtsocio.focus();
   }
  }
 }
}
// ..................................... nacimiento
 function validate_fechaNacim()
{
 if(isnacReq)
 {
  if(document.User.txtnacim.value=="")
  {
   errormsg+='La fecha de nacimiento no puede quedar en blanco.\n';
   error_fn=true;
         if((!error_n)&&(!error_ad)&&(!error_dn)&&(!error_ns))
   {  
   document.User.txtnacim.focus();
   }
  }
 }
}
// ..................................... Dirección
 function validate_direccion() 
{
 if(isdniReq)
 {
  if(document.User.txtdireccion.value=="")
  {
   errormsg+='La dirección no puede quedar en blanco.\n';
   error_dr=true;
         if((!error_n)&&(!error_ad)&&(!error_dn)&&(!error_ns)&&(!error_fn)&&(!error_dr))
   {   
   document.User.txtDNI.focus();
   }
  }
 }
}
// ..................................... CP
 function validate_cp() 
{
 if(isdniReq)
 {
  if(document.User.txtcp.value=="")
  {
   errormsg+='El CP no puede quedar en blanco.\n';
   error_cp=true;
         if((!error_n)&&(!error_ad)&&(!error_dn)&&(!error_ns)&&(!error_fn)&&(!error_dr)&&(!error_cp))
   {   
   document.User.txtDNI.focus();
   }
  }
 }
}

// ..................................... nick de usuario
 function validate_nick()
{
 if(isnicReq)
 {
  if(document.User.txtUsertName.value=="")
  {
   errormsg+='El nick no puede quedar en blanco.\n';
   error_nk=true;
         if((!error_n)&&(!error_ad)&&(!error_dn)&&(!error_ns)&&(!error_fn)&&(!error_dr)&&(!error_cp)&&(!error_nk))
   {  
   document.User.txtUsertName.focus();
   }
  }
 }
}
// ..................................... password
 function validate_pwd()
{
 if(ispasReq)
 {
  if(document.User.txtPassword.value=="")
  {
   errormsg+='El password no puede quedar en blanco.\n';
   error_pw=true;
         if((!error_n)&&(!error_ad)&&(!error_dn)&&(!error_ns)&&(!error_fn)&&(!error_dr)&&(!error_cp)&&(!error_nk)&&(!error_pw))
   {     
   document.User.txtPassword.focus();
   }
  }
 }
}
// ..................................... conf password
 function validate_confpwd()
{
 if(ispa2Req)
 {
  if(document.User.txtPassword2.value=="")
  {
   errormsg+='La confirmación del password no puede quedar en blaco.\n';
   error_ps=true;
         if((!error_n)&&(!error_ad)&&(!error_dn)&&(!error_ns)&&(!error_fn)&&(!error_dr)&&(!error_cp)&&(!error_nk)&&(!error_pw)&&(!error_ps))
   {   
   document.User.txtPassword2.focus();
   }
  }
 }
}
// ..................................... titulación
 function validate_titul()
{
 if(istitReq)
 {
  if(document.User.txttit.value=="")
  {
   errormsg+='La titulación de buceo no puede quedar en blanco.\n';
   error_tt=true;
         if((!error_n)&&(!error_ad)&&(!error_dn)&&(!error_ns)&&(!error_fn)&&(!error_dr)&&(!error_cp)&&(!error_nk)&&(!error_pw)&&(!error_ps)&&(!error_tt))
   {      
   document.User.txttit.focus();
   }
  }
 }
}
// ..................................... licencia
 function validate_lic()
{
 if(islicReq)
 {
  if(document.User.txtlicencia.value=="")
  {
   errormsg+='La fecha de licencia o seguro no puede quedar en blanco.\n';
   error_lc=true;
         if((!error_n)&&(!error_ad)&&(!error_dn)&&(!error_ns)&&(!error_fn)&&(!error_dr)&&(!error_cp)&&(!error_nk)&&(!error_pw)&&(!error_cp)&&(!error_tt)&&(!error_lc))
   {   
   document.User.txtlicencia.focus();
   }
  }
 }
}
// ..................................... 
function validate()
{
 validate_nombre();
 validate_apellido();
 validate_dni();
 validate_socio();
 validate_fechaNacim();
 validate_direccion();
 validate_cp();
 validate_nick();
 validate_pwd();
 validate_confpwd();
 validate_titul();      
 validate_lic();

 if(error_nm||error_ap||error_dn||error_ns||error_fn||error_nk||error_dr||error_cp||error_pw||error_ps||error_tt||error_lc)
 {
  error=true;
 }
 else
 {
  error=false;
 }
 if(!error)
 {
  document.User.submit();
 }
 else
 {
  alert(errormsg);
 }
}
// ..................................... fin script de avisos de errores 


// ..................................... comprueba que no estan vacios los campos en add 
function invalid() {
if (document.User.txtfirstname.value=="") {
alert("El campo Nombre no puede quedar en blanco.");
document.User.txtfirstname.focus();
return false;
}
if (document.User.txtlastname.value=="") {
alert("El campo Apellido no puede quedar en blanco.");
document.User.txtlastname.focus();
return false;
}
if (document.User.txtnacim.value=="") {
alert("Falta completar la fecha de nacimiento.");
document.User.txtnacim.focus();
return false;
}
if (document.User.txtdireccion.value=="") {
alert("La dirección no puede quedar en blanco.");
document.User.txtdireccion.focus();
return false;
}
if (document.User.txtpoblacion.value=="") {
alert("La población no puede quedar en blanco.");
document.User.txtpoblacion.focus();
return false;
}
if (document.User.txtprov.value=="") {
alert("La provincia no puede quedar en blanco.");
document.User.txtprov.focus();
return false;
}
if (document.User.txtcp.value=="") {
alert("El C.P. no puede quedar en blanco.");
document.User.txtcp.focus();
return false;
}
if (document.User.txtUsertName.value=="") {
alert("Debe indicar un Nick de Usuario.");
document.User.txtUsertName.focus();
return false;
}
if (document.User.txtDNI.value=="") {
alert("El DNI no puede quedar en blanco.");
document.User.txtDNI.focus();
return false;
}
if (document.User.txtPassword.value != document.User.txtPassword2.value) {
alert("Los Password no coinciden en ambos campos.");
return false;
}
if (document.User.txtPassword.value=="") {
alert("Es necesario un Password para guardar los datos.");
document.User.txtPassword.focus();
return false;
}
if (document.User.txtsocio.value=="") {
alert("Hay un problema con el Número de Socio.");
document.User.txtsocio.focus();
return false;
}
if (document.User.txttit.value=="") {
alert("Debe seleccionar una titulación de buceo.");
document.User.txttit.focus();
return false;
}
if (document.User.txtlicencia.value=="") {
alert("Debe indicar la fecha de vencimiento del seguro de buceo.");
document.User.txtlicencia.focus();
return false;
}
}

// ..................................... comprobar que no estan vacios los campos de editar perfil 
function invalid2() {
if (document.Profile.txtusername.value=="") {
alert("Es necesario indicar un Nick de Usuario.");
document.Profile.txtusername.focus();
return false;
}
if (document.Profile.txtFirstName.value=="") {
alert("El campo Nombre no puede quedar en blanco.");
document.Profile.txtFirstName.focus();
return false;
}
if (document.Profile.txtLastName.value=="") {
alert("El campo Apellido no puede quedar en blanco.");
document.Profile.txtLastName.focus();
return false;
}
if (document.Profile.txtDNI.value=="") {
alert("El DNI no puede quedar en blanco.");
document.Profile.txtDNI.focus();
return false;
}
if (document.Profile.txtAim.value=="") {
alert("Hay un problema con el Número de Socio.");
document.Profile.txtAim.focus();
return false;
}
if (document.Profile.txtnacim.value=="") {
alert("Falta completar la fecha de nacimiento.");
document.Profile.txtnacim.focus();
return false;
}
if (document.Profile.txtTIT.value=="") {
alert("Especificar titulación actual de buceo.");
document.Profile.txtTIT.focus();
return false;
}
if (document.Profile.txtdireccion.value=="") {
alert("Es necesario indicar una dirección.");
document.Profile.txtdireccion.focus();
return false;
}
if (document.Profile.txtprov.value=="") {
alert("Es necesario indicar la provincia.");
document.Profile.txtprov.focus();
return false;
}
if (document.Profile.txtLocation.value=="") {
alert("Es necesario indicar la población.");
document.Profile.txtLocation.focus();
return false;
}
if (document.Profile.txtcp.value=="") {
alert("Es necesario indicar el Código Postal.");
document.Profile.txtcp.focus();
return false;
}
if (document.Profile.txtLicencia.value=="") {
alert("Es necesaria la fecha de vencimiento del seguro de buceo.");
document.Profile.txtLicencia.focus();
return false;
}
if (document.Profile.txtvenc_ptr.value=="") {
alert("El campo Patron no puede quedar en blanco.");
document.Profile.txtvenc_ptr.focus();
return false;
}
}

// ..................................... activa campo con un checkbox 
function marcar(){
marca_2();
marca_3();
}
function marca_2(){
if(document.User.txtpatron.checked){
document.User.venPtr.disabled=false
document.User.venPtr.style.backgroundColor='#FFFFFF'
document.User.venPtr.value=a1
document.User.venPtr.focus()
}
else{
document.User.venPtr.disabled=true
document.User.venPtr.style.backgroundColor='#D6D3CE'
a1=document.User.venPtr.value
document.User.venPtr.value=""
}
}
function marca_3(){
if(document.Profile.Patron.checked){
document.Profile.txtvenPtr.disabled=false
document.Profile.txtvenPtr.style.backgroundColor='#FFFFFF'
document.Profile.txtvenPtr.value=a1
document.Profile.txtvenPtr.focus()
}
else{
document.Profile.txtvenPtr.disabled=true
document.Profile.txtvenPtr.style.backgroundColor='#D6D3CE'
a1=document.Profile.txtvenPtr.value
document.Profile.txtvenPtr.value=""
}
}

// ..................................... limpia campos para insertar datos 
function limpiar()
{
if (document.User.txtUsertName.value == "Nick")
document.User.txtUsertName.value = "";
}
function limpiar2()
{
if (document.User.txtEmail.value == "Email")
document.User.txtEmail.value = "";
}

// ..................................... no operativo --  imagen de precarga
function precarga() {
imagenes = document.images;
cargadas = true;
for (var i = 0; i < imagenes.length; i ++)
cargadas = cargadas & imagenes.complete;
if (cargadas)
document.body.style.visibility = "visible";
else
setTimeout("precarga()", 100);
}
<!--------------------------------------FIN ADMIN------------------------------------------->


<!----------------------------------INICIO AVISOS USER-------------------------------------->
function TheFormCheck() {
if (document.Profile.txtPassword.value != document.Profile.txtPassword2.value) {
alert("Los Password no coinciden.  Por favor vuelva a intentarlo.");
return false;
}
if (document.Profile.txtPassword.value=="") {
alert("El Password está en blanco.  Por favor vuelva a intentarlo.");
document.Profile.txtPassword.focus();return false
}
}
function inval() {
if (document.User2.txtBody1.value=="") {
alert("El Nº de Socio no puede quedar en blanco. Por favor vuelva a intentarlo.");
document.User2.txtBody1.focus();return false;
}
if (document.User2.txtBody2.value=="") {
alert("El Nº de Salida no puede quedar en blanco. Por favor vuelva a intentarlo.");
document.User2.txtBody1.focus();return false
}
}
<!--------------------------------------FIN USER-------------------------------------------->


<!-----------------------------INICIO FUNCIONES EDIT_SOCIO---------------------------------->

// .....................................  comprueba que no estén vacios los campos 
function val_edtSoc() {
if (document.form1.Nombre.value=="") {
alert("Debe indicar el nombre del socio.");
document.form1.Nombre.focus();
return false;
}
if (document.form1.socio.value=="") {
alert("Debe asignarse un Número de Socio.");
document.form1.socio.focus();
return false;
}
if (document.form1.DNI.value=="") {
alert("Debe introducir el NIF del socio.");
document.form1.DNI.focus();
return false;
}
if (document.form1.TIT.value=="") {
alert("No ha indicado la titulación de buceo.");
document.form1.TIT.focus();
return false;
}
if (document.form1.txtlicencia.value=="") {
alert("No ha indicado la fecha de vencimiento del seguro.");
document.form1.txtlicencia.focus();
return false;
}
}

// .....................................  activa un campo al marcar el checkbox 
function marcar(){
marca_1();
}
function marca_1(){
if(document.form1.Patron.checked){
document.form1.txtvenPtr.disabled=false
document.form1.txtvenPtr.style.backgroundColor='#FFFFFF'
document.form1.txtvenPtr.value=a1
document.form1.txtvenPtr.focus()
}
else{
document.form1.txtvenPtr.disabled=true
document.form1.txtvenPtr.style.backgroundColor='#D6D3CE'
a1=document.form1.txtvenPtr.value
document.form1.txtvenPtr.value=""
}
}
<!-----------------------------------FIN EDIT_SOCIO------------------------------------------>


<!------------------------------INICIO AVISOS ALQUILERES------------------------------------->

// ..................................... comprueba que no estan los campos vacios
function cam_vac() {
if (document.sal_alq.equipo.value=="") {
alert("Seleccionar el tipo de equipo alquilado.");
document.sal_alq.equipo.focus();
return false;
}
if (document.sal_alq.numero.value=="") {
alert("Indicar el número de control.");
document.sal_alq.numero.focus();
return false;
}
if (document.sal_alq.salida.value=="") {
alert("Indicar la fecha de salida del material.");
document.sal_alq.salida.focus();
return false;
}
}
<!------------------------------------FIN ALQUILERES----------------------------------------->


<!------------------------------------INICIO VALIDAR----------------------------------------->
// Esta función realiza las siguientes comprobaciones:
// La longitud del nombre es mayor de cuatro caracteres. 
// El nombre sólo contiene caracteres del alfabeto español, no contiene números ni caracteres no alfanuméricos. 
// La edad sólo contiene números. 
// El valor de la edad está comprendido entre 18 y 30. 
// La dirección de correo incluye una arroba y su longitud es superior a cinco caracteres. 

function validar(User) {
//comprueba 50 caracteres maximo
	for(x = 1; x < 5; x++) {
		if (User.elements[x].value.length > 50) {
			alert('La cantidad máxima permitida es de 50 caracteres.')
			return false
		}
	} 
	  
  if (User.txtfirstname.value.length < 3) {
    alert("Escriba por lo menos 3 caracteres en el campo \"Nombre\".");
    User.txtfirstname.focus();
    return (false);
  }
  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ" + "abcdefghijklmnñopqrstuvwxyzáéíóú ";
  var checkStr = User.txtfirstname.value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }
  if (User.txtlastname.value.length < 3) {
    alert("Escriba por lo menos 3 caracteres en el campo \"Apellidos\".");
    User.txtlastname.focus();
    return (false);
  }
  var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ" + "abcdefghijklmnñopqrstuvwxyzáéíóú ";
  var checkStr = User.txtlastname.value;
  var allValid = true; 
  for (i = 0; i < checkStr.length; i++) {
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    }
  }    
  if (!allValid) { 
    alert("Se han incluido caracteres no permitidos en el campo \"Apellidos\"."); 
    User.txtlastname.focus(); 
    return (false); 
  } 
  var checkOK = "0123456789"; 
  var checkStr = User.edad.value; 
  var allValid = true; 
  var decPoints = 0; 
  var allNum = ""; 
  for (i = 0; i < checkStr.length; i++) { 
    ch = checkStr.charAt(i); 
    for (j = 0; j < checkOK.length; j++) 
      if (ch == checkOK.charAt(j))
        break; 
    if (j == checkOK.length) { 
      allValid = false; 
      break; 
    } 
    allNum += ch; 
  } 
  if (!allValid) { 
    alert("Escriba sólo dígitos en el campo \"Edad\".");
    User.edad.focus(); 
    return (false); 
  } 
  var chkVal = allNum; 
  var prsVal = parseInt(allNum); 
  if (chkVal != "" && !(prsVal >= "18" && prsVal <= "30")) { 
    alert("Escriba un valor mayor o igual que 18 y menor o igual que 30 en el campo \"Edad\"."); 
    User.edad.focus();
    return (false); 
  }
  if ((User.correo.value.indexOf ('@', 0) == -1)||(User.correo.value.length < 5)) { 
    alert("Escriba una dirección de correo válida en el campo \"Dirección de correo\"."); 
    return (false); 
  }
  return (true); 
} 
<!--------------------------------------FIN VALIDAR------------------------------------------->


<!-----------------------------------FUNCIÓN NETSCAPE----------------------------------------->
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
<!-------------------------------------FIN NETSCAPE-------------------------------------------> 


<!-------------------------------INICIO FUNCIÓN CALENDARIO------------------------------------>  
// Flooble Dynamic  Calendar. 
	// Copyright (c) 2004 by Animus Pactum Consulting Inc.
	//---------------------------------------------------------------------
	// You may use this code freely on your site as long as you do not make
	// modifications to it other than editing the stylesheet settings to 
	// make it fit your design. You may not remove this notice or any links
	// to flooble.com.
	// More information about this script is available at
	//    http://www.flooble.com/scripts/calendar.php
	//--Global Stuff-------------------------------------------------------
	
	var fc_ie = false;
	if (document.all) { fc_ie = true; }
	
	var calendars = Array();
	var fc_months = Array('Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic');
	var fc_openCal;

	var fc_calCount = 0;
	
	function getCalendar(fieldId) {
		return calendars[fieldId];
	}
	
	function displayCalendarFor(fieldId) {
		var formElement = fc_getObj(fieldId);
		displayCalendar(formElement);
	}
	
	function displayCalendar(formElement) {
		if (!formElement.id) {
			formElement.id = fc_calCount++;
		} 
		var cal = calendars[formElement.id];
		if (typeof(cal) == 'undefined') {
			cal = new floobleCalendar();
			cal.setElement(formElement);
			calendars[formElement.id] = cal;
		}
		if (cal.shown) {
			cal.hide();
		} else {
			cal.show();
		}
	}
	
	function display3FieldCalendar(de, me, ye) {
		if (!de.id) { de.id = fc_calCount++; }
		if (!me.id) { me.id = fc_calCount++; }
		if (!ye.id) { ye.id = fc_calCount++; }
		var id = de.id + '-' + me.id + '-' + ye.id;
		var cal = calendars[id];
		if (typeof(cal) == 'undefined') {
			cal = new floobleCalendar();
			cal.setElements(de, me, ye);
			calendars[id] = cal;
		}
		if (cal.shown) {
			cal.hide();
		} else {
			cal.show();
		}
	}

	//--Class Stuff--------------------------------------------------
	function floobleCalendar() {
		// Define Methods
		this.setElement = fc_setElement;
		this.setElements = fc_setElements;
		this.parseDate = fc_parseDate;
		this.generateHTML = fc_generateHTML;
		this.show = fc_show;
		this.hide = fc_hide;
		this.moveMonth = fc_moveMonth;
		this.setDate = fc_setDate;
		this.formatDate = fc_formatDate;
		this.setDateFields = fc_setDateFields;
		this.parseDateFields = fc_parseDateFields;
		
		this.shown = false;
	}
	
	function fc_setElement(formElement) {
		this.element = formElement;
		this.format = this.element.title;
		this.value = this.element.value;
		this.id = this.element.id;
		this.mode = 1;
	}
	
	function fc_setElements(dayElement, monthElement, yearElement) {
		this.dElement = dayElement;
		this.mElement = monthElement;
		this.yElement = yearElement;
		this.id = this.dElement.id + '-' + this.mElement.id + '-' + this.yElement.id;
		this.element = this.dElement;
		if (fc_absoluteOffsetLeft(this.mElement) < fc_absoluteOffsetLeft(this.element)) {
			this.element = this.mElement;
		}
		if (fc_absoluteOffsetLeft(this.yElement) < fc_absoluteOffsetLeft(this.element)) {
			this.element = this.yElement;
		}
		if (fc_absoluteOffsetTop(this.dElement) > fc_absoluteOffsetTop(this.element)) {
			this.element = this.dElement;
		}
		if (fc_absoluteOffsetTop(this.mElement) > fc_absoluteOffsetTop(this.element)) {
			this.element = this.mElement;
		}
		if (fc_absoluteOffsetTop(this.yElement) > fc_absoluteOffsetTop(this.element)) {
			this.element = this.yElement;
		}

		this.mode = 2;
	}
	
	function fc_parseDate() {
		if (this.element.value) {
			this.date = new Date();
			var out = '';
			var token = '';
			var lastCh, ch;
			var start = 0;
			lastCh = this.format.substring(0, 1);
			for (i = 0; i < this.format.length; i++) {
				ch = this.format.substring(i, i+1);
				if (ch == lastCh) { 
					token += ch;
				} else {
					fc_parseToken(this.date, token, this.element.value, start);
					start += token.length;
					token = ch;
				}
				lastCh = ch;
			}
			fc_parseToken(this.date, token, this.element.value, start);

		} else {
			this.date = new Date();
		}
		if ('' + this.date.getMonth() == 'NaN') {
			this.date = new Date();
		}
	}	
	
	function fc_parseDateFields() {
		this.date = new Date();
		if (this.dElement.value) this.date.setDate(fc_getFieldValue(this.dElement));
		if (this.mElement.value) this.date.setMonth(fc_getFieldValue(this.mElement) - 1);
		if (this.yElement.value) this.date.setFullYear(fc_getFieldValue(this.yElement));
		if ('' + this.date.getMonth() == 'NaN') {
			this.date = new Date();
		}
	}
	
	function fc_setDate(d, m, y) {
		this.date.setYear(y);
		this.date.setMonth(m);
		this.date.setDate(d);
		if (this.mode == 1) {
			this.element.value = this.formatDate();
		} else {
			this.setDateFields();
		}
		this.hide();
	}
	
	function fc_setDateFields() {
		fc_setFieldValue(this.dElement, fc_zeroPad(this.date.getDate()));
		fc_setFieldValue(this.mElement, fc_zeroPad(this.date.getMonth() + 1));
		fc_setFieldValue(this.yElement, this.date.getFullYear());
	}
	
	function fc_formatDate() {
		var out = '';
		var token = '';
		var lastCh, ch;
		lastCh = this.format.substring(0, 1);
		for (i = 0; i < this.format.length; i++) {
			ch = this.format.substring(i, i+1);
			if (ch == lastCh) { 
				token += ch;
			} else {
				out += fc_formatToken(this.date, token);
				token = ch;
			}
			lastCh = ch;
		}
		out += fc_formatToken(this.date, token);
		return out;
	}
	
	function fc_show() {
		if (typeof(fc_openCal) != 'undefined') { fc_openCal.hide(); }
	
		if (this.mode == 1) {
			this.parseDate();
		} else {
			this.parseDateFields();
		}
		this.showDate = new Date(this.date.getTime());
		if (typeof(this.div) != 'undefined') {
			this.div.innerHTML = this.generateHTML();
		}
		
		if (typeof(this.div) == 'undefined') {
			this.div = document.createElement('DIV');
			this.div.style.position = 'absolute';
			this.div.style.display = 'none';
			this.div.className = 'fc_main';
			this.div.innerHTML = this.generateHTML();
			this.div.style.left = fc_absoluteOffsetLeft(this.element);
			this.div.style.top = fc_absoluteOffsetTop(this.element) + this.element.offsetHeight + 1;
			document.body.appendChild(this.div);
		}
		this.div.style.display = 'block';
		this.shown = true;
		fc_openCal = this;
	}
	
	function fc_generateHTML() {
		var html = '<TABLE><TR><TD CLASS="fc_head2" COLSPAN="6"><DIV STYLE="float: right"></DIV>Seleccionar Fecha:</TD><TD CLASS="fc_date2" onMouseover="this.className = \'fc_dateHover\';" onMouseout="this.className=\'fc_date\';" onClick="getCalendar(\'' + this.id + '\').hide();"><img src="comunicados/cancel.gif"></TD></TR>';
		html += '<TR><TD CLASS="fc_date" onMouseover="this.className = \'fc_dateHover\';" onMouseout="this.className=\'fc_date\';" onClick="getCalendar(\'' + this.id + '\').moveMonth(-12);"><img src="imagenes/zq2.gif"></TD><TD CLASS="fc_date" onMouseover="this.className = \'fc_dateHover\';" onMouseout="this.className=\'fc_date\';" onClick="getCalendar(\'' + this.id + '\').moveMonth(-1);"><img src="imagenes/zq1.gif"></TD><TD COLSPAN="3" CLASS="fc_wk" style="color: #990000; font-weight: bold;">' + fc_months[this.showDate.getMonth()] + ' ' + fc_getYear(this.showDate) + '</TD><TD CLASS="fc_date" onMouseover="this.className = \'fc_dateHover\';" onMouseout="this.className=\'fc_date\';" onClick="getCalendar(\'' + this.id + '\').moveMonth(1);"><img src="imagenes/der1.gif"></TD><TD CLASS="fc_date" onMouseover="this.className = \'fc_dateHover\';" onMouseout="this.className=\'fc_date\';" onClick="getCalendar(\'' + this.id + '\').moveMonth(12);"><img src="imagenes/der2.gif"></TD></TR>';
		html += '<TR><TD WIDTH="14%" CLASS="fc_wk">Lu</TD><TD WIDTH="14%" CLASS="fc_wk">Ma</TD><TD WIDTH="14%" CLASS="fc_wk">Mi</TD><TD WIDTH="14%" CLASS="fc_wk">Ju</TD><TD WIDTH="14%" CLASS="fc_wk">Vi</TD><TD class="fc_wknd" WIDTH="14%">Sa</TD><TD class="fc_wknd" WIDTH="14%">Do</TD></TR>';
		html += '<TR>';
		var dow = 0;
		var i, style;
		var totald = fc_monthLength(this.showDate);
		for (i = 0; i < fc_firstDOW(this.showDate); i++) {
			dow++;
			html += '<TD> </TD>';
		}
		for (i = 1; i <= totald; i++) {
			if (dow == 0) { html += '<TR>'; }
			if (this.showDate.getMonth() == this.date.getMonth() && this.showDate.getYear() == this.date.getYear() && this.date.getDate() == i) { 
				style = ' style="color: #990000; font-weight: bold;"';
			} else {
				style = '';
			}
			html += '<TD CLASS="fc_date" onMouseover="this.className = \'fc_dateHover\';" onMouseout="this.className=\'fc_date\';" onClick="getCalendar(\'' + this.id + '\').setDate(' + i + ', ' + this.showDate.getMonth() + ', ' + this.showDate.getFullYear() + ');" ' + style + '>' + i + '</TD>';
			dow++;
			if (dow == 7) {
				html += '</TR>';
				dow = 0;
			}
		}
		if (dow != 0) {
			for (i = dow; i < 7; i++) {
				html += '<TD> </TD>';
			}
		}
		html +='</TR>';
		html += '</TABLE>';
		return html;
	}
	
	function fc_hide() {
		if (this.div != false) {
			this.div.style.display = 'none';
		}
		this.shown = false;
		fc_openCal = undefined;
	}
	
	function fc_moveMonth(amount) {
		var m = this.showDate.getMonth();
		var y = fc_getYear(this.showDate);
		if (amount == 1)  {
			if (m == 11)  {
				this.showDate.setMonth(0);
				this.showDate.setYear(y + 1);
			} else {
				this.showDate.setMonth(m + 1);
			}
		} else if (amount == -1)  {
			if (m == 0)  {
				this.showDate.setMonth(11);
				this.showDate.setYear(y - 1);
			} else {
				this.showDate.setMonth(m - 1);
			}
		} else if (amount == 12) {
			this.showDate.setYear(y + 1);
		} else if (amount == -12) {
			this.showDate.setYear(y - 1);
		}
		this.div.innerHTML = this.generateHTML();
	}
	
	//--Utils-------------------------------------------------------------
	function fc_absoluteOffsetTop(obj) {
     	var top = obj.offsetTop;
     	var parent = obj.offsetParent;
     	while (parent != document.body) {
     		top += parent.offsetTop;
     		parent = parent.offsetParent;
     	}
     	return top;
     }
     
     function fc_absoluteOffsetLeft(obj) {
     	var left = obj.offsetLeft;
     	var parent = obj.offsetParent;
     	while (parent != document.body) {
     		left += parent.offsetLeft;
     		parent = parent.offsetParent;
     	}
     	return left;
     }
     
     function fc_firstDOW(date) {
     	var dow = date.getDay();
     	var day = date.getDate();
 		if (day % 7 == 0) return dow;
     	return (7 + dow - (day % 7)) % 7; 
     }
     
     function fc_getYear(date) {
     	var y = date.getYear();
     	if (y > 1900) return y;
     	return 1900 + y;
     }
     
     function fc_monthLength(date) {
		var month = date.getMonth();
		var totald = 30;
		if (month == 0 
			|| month == 2
			|| month == 4
			|| month == 6
			|| month == 7
			|| month == 9
			|| month == 11) totald = 31;
		if (month == 1) {
			var year = date.getYear();
			if (year % 4 == 0 && (year % 400 == 0 || year % 100 != 0))
		 		totald = 29;
			else
				totald = 28;
		}
		return totald;
     }
     
     function fc_formatToken(date, token) {
		var command = token.substring(0, 1);
		if (command == 'y' || command == 'Y') {
			if (token.length == 2) { return fc_zeroPad(date.getFullYear() % 100); }
			if (token.length == 4) { return date.getFullYear(); } 
		}
		if (command == 'd' || command == 'D') {
			if (token.length == 2) { return fc_zeroPad(date.getDate()); }
		}
		if (command == 'm' || command == 'M') {
			if (token.length == 2) { return fc_zeroPad(date.getMonth() + 1); }
			if (token.length == 3) { return fc_months[date.getMonth()]; } 
		}
		return token;
     }
     
     function fc_parseToken(date, token, value, start) {
		var command = token.substring(0, 1);
		var v;
		if (command == 'y' || command == 'Y') {
			if (token.length == 2) { 
				v = value.substring(start, start + 2);
				if (v < 70) { date.setFullYear(2000 + parseInt(v)); } else { date.setFullYear(1900 + parseInt(v)); } 
			}
			if (token.length == 4) { v = value.substring(start, start + 4); date.setFullYear(v);} 
		}
		if (command == 'd' || command == 'D') {
			if (token.length == 2) { v = value.substring(start, start + 2); date.setDate(v); }
		}
		if (command == 'm' || command == 'M') {
			if (token.length == 2) { v = value.substring(start, start + 2); date.setMonth(v - 1); }
			if (token.length == 3) { 
				v = value.substring(start, start + 3);
				var i;
				for (i = 0; i < fc_months.length; i++) {
					if (fc_months[i].toUpperCase() == v.toUpperCase()) { date.setMonth(i); }
				}
			} 
		}
     }
     
     function fc_zeroPad(num) {
		if (num < 10) { return '0' + num; }
		return num;
     }

	function fc_getObj(id) {
		if (fc_ie) { return document.all[id]; } 
		else { return document.getElementById(id);	}
	}

      function fc_setFieldValue(field, value) {
                if (field.type.substring(0,6) == 'select') {
                        var i;
                        for (i = 0; i < field.options.length; i++) {
                                if (fc_equals(field.options[i].value, value)) {
                                        field.selectedIndex = i;
                                }
                        }
                } else {
                        field.value = value;
                }
      }

      function fc_getFieldValue(field) {
                if (field.type.substring(0,6) == 'select') {
                        return field.options[field.selectedIndex].value;
                } else {
                        return field.value;
                }
      }
      
      function fc_equals(val1, val2) {
      		if (val1 == val2) return true;      		
      		if (1 * val1 == 1 * val2) return true;
      		return false;
      }
	  
<!--------------------------------------FIN CALENDARIO------------------------------------------->  


<!----------------------------------COMIENZO ABRIR SALIDAS--------------------------------------->
function cam_vac2() {
if (document.formulario.Incidencias.value=="") {
alert("No ha indicado el estado de la salida.");
document.formulario.Incidencias.focus();
return false;
}
if (document.formulario.barco.value=="") {
alert("No ha seleccionado una embarcación.");
document.formulario.barco.focus();
return false;
}
if (document.formulario.destino.value=="") {
alert("No ha seleccionado un destino.");
document.formulario.destino.focus();
return false;
}
if (document.formulario.Fecha.value=="") {
alert("No ha seleccionado la fecha de la salida.");
document.formulario.Fecha.focus();
return false;
}
if (document.formulario.Hora.value=="") {
alert("No ha seleccionado la hora de salida.");
document.formulario.Hora.focus();
return false;
}
}
<!-----------------------------------FIN ABRIR SALIDAS--------------------------------------->  


<!-------------------------------------INICIO AVISOS----------------------------------------->  

// ..................................... Abrir salidas 
function NoDis() {
alert("\nIMPORTANTE!!!\nEste usuario ha sido suspendido temporalmente.\nNo disponemos del vencimiento de licencia o seguro de buceo.\n\nPor favor, ponte en contacto con la secretaría del club   \npara actualizar tus datos.  ")
window.history.back()
}
function ActLic() {
alert("\nIMPORTANTE!!!\nEste usuario ha sido suspendido temporalmente.\nDebes actualizar el vencimiento de licencia o seguro de buceo.\n\nPor favor, ponte en contacto con la secretaría del club   \npara informar del nuevo vencimiento una vez renovado.  ")
window.history.back()
}
function CamFran() {
alert("Ya existe una salida en ese horario,\ndebes cambiar la franja horaria.\n \nLas franjas standars son:\n 09:00h, 12:00h, 16:00h y 19:00h.")
window.history.back()
}
function ErrorSal() {
alert("No has podido ser incluido en la salida")
window.history.back()
}

// ..................................... Ingresos en salidas 
function ActLic2() {
alert("\nIMPORTANTE!!!\nEste usuario ha sido suspendido temporalmente.\nPor no disponer de licencia o seguro de buceo en vigor.\n\nPor favor, ponte en contacto con la secretaría del club   \npara actualizar tus datos.  ")
window.history.back()
}
function UsuSusp() {
alert("El usuario ha sido suspendido temporalmente!!!")
window.history.back()
}
function NSalida() {
alert("No se ha seleccionado un Nº de Salida")
window.history.back()
}
function ConfSal() {
alert("Esta salida está completa y no se pueden incluir más buceadores!!!")
window.history.back()
}
function ConfInv() {
var respuesta = confirm("Este socio ya está en la lista, quiere incluir un invitado?");
if (respuesta == true) {
document.forms[0].page.value = "Invitar";
} 
if (respuesta == false) {
window.history.back()
document.forms[0].page.value = "Cancelar";
}
}
function NoInv() {
alert("No es posible incluir invitados en salidas \nde buceos profundos o al Bajo de Fuera.")
window.history.back()
}
function IngNom() {
alert("Debe ingresar el nombre y apellidos del invitado")
window.history.back()
}
function IngDni() {
alert("Debe ingresar el DNI del invitado")
window.history.back()
}
function IngTit() {
alert("Debe seleccionar la titulación del invitado")
window.history.back()
}
<!--------------------------------------FIN AVISOS------------------------------------------->








<!--BEGIN FORM VALIDATION SCRIPT --- pruebas_script_2.asp-->

/* Written by Premshree Pillai
   Created 2:22 PM 5/12/02
   http://www.qiksearch.com
   http://premshree.resource-locator.com
   qiksearch@rediffmail.com */

var alphaChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
var numChars="0123456789";
var error;
var error_n;
var error_ad;
var error_a;
var error_z;
var errormsg;

//--------------------------Customise-------------------------------
var isNameReq=true; // True if Name field required else False
var isAddressReq=true; // True if Address field required else False
var isAgeReq=false; // True if Name Age required else False
var isZipReq=true; // True if Name Zip required else False
//------------------------------------------------------------------

function reset_error()
{
 error_n=false;
 error_ad=false;
 error_a=false;
 error_z=false;
 errormsg='Following Errors Occured ::\n_____________________________\n\n';
}

function validate_name()
{
 if(isNameReq)
 {
  if(document.main.name.value=="")
  {
   errormsg+='Por favor, entra tu nombre.\n';
   error_n=true;
   document.main.name.focus();
  }
 }
 for(var i=0; i<document.main.name.value.length; i++)
 {
  for(var j=0; j<alphaChars.length; j++)
  {
   if(alphaChars.charAt(j)==document.main.name.value.charAt(i))
   {
    break;
   }
   else
   {
    if(j==(alphaChars.length-1))
    {
     errormsg+='"' + document.main.name.value.charAt(i) + '"' + ' no es un carácter válido para el nombre.\n';
     error_n=true;
    }
   }
   if(error_n)
   {
    document.main.name.select();
   }
  }
 }
}

function validate_address()
{
 if(isAddressReq)
 {
  if(document.main.address.value=="")
  {
   errormsg+='Por favor, entra tu dirección.\n';
   error_ad=true;
   if(!error_n)
   {
    document.main.address.focus();
   }
  }
 }
}

function validate_age()
{
 if(isAgeReq)
 {
  if(document.main.age.value=="")
  {
   errormsg+='Por favor, entra tu edad.\n';
   error_a=true;
   if((!error_n)&&(!error_ad))
   {
    document.main.age.focus();
   }
  }
 }
 for(var i=0; i<document.main.age.value.length; i++)
 {
  for(var j=0; j<numChars.length; j++)
  {
   if(numChars.charAt(j)==document.main.age.value.charAt(i))
   {
    break;
   }
   else
   {
    if(j==(numChars.length-1))
    {
     errormsg+='"' + document.main.age.value.charAt(i) + '"' + ' es un carácter no válido para la edad.\n';
     error_a=true;
    }
   }
   if(error_a)
   {
    if((!error_n)&&(!error_ad))
    {
     document.main.age.select();
    }
   }
  }
 }
}

function validate_zip()
{
 if(isZipReq)
 {
  if(document.main.zip.value=="")
  {
   errormsg+='Por favor, entra el código postal.\n';
   error_z=true;
   if((!error_n)&&(!error_ad)&&(!error_a))
   {
    document.main.zip.focus();
   }
  }
 }
 for(var i=0; i<document.main.zip.value.length; i++)
 {
  for(var j=0; j<numChars.length; j++)
  {
   if(numChars.charAt(j)==document.main.zip.value.charAt(i))
   {
    break;
   }
   else
   {
    if(j==(numChars.length-1))
    {
     errormsg+='"' + document.main.zip.value.charAt(i) + '"' + ' no es un carácter válido para el código postal.\n';
     error_z=true;
    }
   }
   if(error_z)
   {
    if((!error_n)&&(!error_ad)&&(!error_a))
    {
     document.main.zip.select();
    }
   }
  }
 }
}

function validate()
{
 reset_error();
 validate_name();
 validate_address();
 validate_age();
 validate_zip();

 if(error_n||error_ad||error_a||error_z)
 {
  error=true;
 }
 else
 {
  error=false;
 }
 if(!error)
 {
  document.main.submit();
 }
 else
 {
  alert(errormsg);
 }
}
<!--END FORM VALIDATION SCRIPT-->
<!--------------------------------------END REQUIRED------------------------------------------->

