var MensajeCamposOblig = 'Los campos marcados con * deben de estar cumplimentados obligatoriamente';
var MensajeEMail = 'La dirección de E-Mail introducida no es valida'

function OpenWinGaudeamus() {
   if (screen.height > 600) {
      window.open('http://www.sek.net/gaudeamus2007/default.asp?alt=620', 'Gaudeamus', 'width=720,height=650,top=20,left=50,resizable=no,scrollbars=no'); 
      }
   else {
      window.open('http://www.sek.net/gaudeamus2007/default.asp?alt=500', 'Gaudeamus', 'width=720,height=520,top=10,left=50,resizable=no,scrollbars=no'); 
      }
   }
function OpenWinGaudeamus2000() {
   if (screen.height > 600) {
      window.open('http://www.sek.net/gaudeamus2000/default.asp?alt=620', 'Gaudeamus', 'widht=720,height=650,top=20,left=50,scrollbars=yes'); 
      }
   else {
      window.open('http://www.sek.net/gaudeamus2000/default.asp?alt=520', 'Gaudeamus', 'widht=720,height=550,top=20,left=50,scrollbars=yes'); 
      }
   }
function OpenWinGaudeamus2001() {
   if (screen.height > 600) {
      window.open('http://www.sek.net/gaudeamus2001/default.asp?alt=620', 'Gaudeamus', 'widht=720,height=650,top=20,left=50,resizable=yes,scrollbars=yes'); 
      }
   else {
      window.open('http://www.sek.net/gaudeamus2001/default.asp?alt=520', 'Gaudeamus', 'widht=720,height=550,top=20,left=50,resizable=yes,scrollbars=yes'); 
      }
   }
function OpenWinGaudeamus2002() {
   if (screen.height > 600) {
      window.open('http://www.sek.net/gaudeamus2002/default.asp?alt=620', 'Gaudeamus', 'widht=720,height=650,top=20,left=50,resizable=yes,scrollbars=yes'); 
      }
   else {
      window.open('http://www.sek.net/gaudeamus2002/default.asp?alt=520', 'Gaudeamus', 'widht=720,height=550,top=20,left=50,resizable=yes,scrollbars=yes'); 
      }
   }
function OpenWinGaudeamus2003() {
   if (screen.height > 600) {
      window.open('http://www.sek.net/gaudeamus2003/principal.asp?alt=620', 'Gaudeamus', 'widht=720,height=650,top=20,left=50,resizable=yes'); 
      }
   else {
      window.open('http://www.sek.net/gaudeamus2003/principal.asp?alt=520', 'Gaudeamus', 'widht=720,height=550,top=20,left=50,resizable=yes'); 
      }
   }
function OpenWinGaudeamus2004() {
   if (screen.height > 600) {
      window.open('http://www.sek.net/gaudeamus2004/principal.asp?alt=620', 'Gaudeamus', 'widht=720,height=650,top=20,left=50,resizable=yes'); 
      }
   else {
      window.open('http://www.sek.net/gaudeamus2004/principal.asp?alt=520', 'Gaudeamus', 'widht=720,height=550,top=20,left=50,resizable=yes'); 
      }
   }
function OpenWinGaudeamus2005() {
   if (screen.height > 600) {
      window.open('http://www.sek.net/gaudeamus2005/default.asp?alt=620', 'Gaudeamus', 'width=720,height=650,top=20,left=50,resizable=no,scrollbars=no'); 
      }
   else {
      window.open('http://www.sek.net/gaudeamus2005/default.asp?alt=500', 'Gaudeamus', 'width=720,height=520,top=10,left=50,resizable=no,scrollbars=no'); 
      }
   }
function OpenWinGaudeamus2006() {
   if (screen.height > 600) {
      window.open('http://www.sek.net/gaudeamus2006/default.asp?alt=620', 'Gaudeamus', 'width=720,height=650,top=20,left=50,resizable=no,scrollbars=no'); 
      }
   else {
      window.open('http://www.sek.net/gaudeamus2006/default.asp?alt=500', 'Gaudeamus', 'width=720,height=520,top=10,left=50,resizable=no,scrollbars=no'); 
      }
   }



//*******************************************************************************
//
function FormatTexto(Formato) {
 if (document.selection.createRange().text != '') {
  switch (Formato) {
   case 'n':
    document.selection.createRange().text = '[b]' + document.selection.createRange().text + '[/b]';
    break;
   case 'c':
    document.selection.createRange().text = '[i]' + document.selection.createRange().text + '[/i]';
    break;
   case 's':
    document.selection.createRange().text = '[u]' + document.selection.createRange().text + '[/u]';
    break;
   case 'l':
    URL=prompt('Introduzca dirección (URL)','http://');
    if (URL!=null) {
     document.selection.createRange().text = '[a]' + URL + '|' + document.selection.createRange().text + '[/a]';
    }
    break;	
  }
 }
}

//*******************************************************************************
//
function SeleccTR (tabla, fila, campo1, valor1, campo2, valor2) {
	for (i=0; i < tabla.rows.length; i++) {
		tabla.rows(i).className = 'NOSELECC';
  }
  fila.className = 'SELECC';
  campo1.value = valor1;
  campo2.value = valor2;
}

//*******************************************************************************
//
function EliminarFoto (foto, num, id, codigoCentro)	{
	if (foto != '') {
		resp = confirm ('¿Está seguro de que desea eliminar "' + foto + '"?');
		if (resp == true) {
			if (codigoCentro == 'PorDefecto') {
				document.URL = 'default.asp?car=adminWebPorDefecto&arc=EliminarFoto.asp&id=' + id + '&f=' + foto + '&n=' + num;
			}
			else {
				document.URL = 'default.asp?car=adminWeb&arc=EliminarFoto.asp&id=' + id + '&cc=' + codigoCentro + '&n=' + num + '&f=' + foto;
			}
		}
		else {
			return false;
		}
	}	
}

//*******************************************************************************
//
function Imprimir (capa) {		
	capa.style.display = 'none';
	print();
}


//*******************************************************************************
//
function quitarDisabled (formulario)	{
	for (i=0; i<formulario.all.length;i++) {
		formulario.all(i).disabled=false;
	}	
}

//*******************************************************************************
//
function MostrarOcultar (capa)	{
	if (capa.style.display == 'none') {
		capa.style.display='block'; 
	}
	else {
		capa.style.display='none'; 
	}	
}

//*******************************************************************************
//
function IntercambiarMostrarOcultar (capaM, capaO)	{
	capaM.style.display='block'; 
	capaO.style.display='none'; 				
}

//*******************************************************************************
//
function MostrarTabla(elem, imagen, row) {
	 if (elem.style.display == 'none') {
		elem.style.display = '';
		imagen.src = '../../images/16_icono_up.gif';
		row.className = 'OPEN';
	 }
	 else {
	  elem.style.display = 'none';
		imagen.src = '../../images/16_icono_down.gif';
		row.className = 'CLOSE';
	 } 
}

//*******************************************************************************
//
function MostrarTabla2(elem, imagen, row) {
	 if (elem.style.display == 'none') {
		elem.style.display = '';
		imagen.src = '../images/white_up.gif';
		row.className = 'OPEN';
	 }
	 else {
	  elem.style.display = 'none';
		imagen.src = '../images/white_down.gif';
		row.className = 'CLOSE';
	 } 
}

//*******************************************************************************
// 
function MostrarTodasTablas(opc, oParent) {	
	var erTable = /Table_*/
	var erImg = /Img_*/
	var erTR = /TR_*/
 var oObject = oParent.all;
 if (opc == 'exp') {
		var opcTable = 'block';
		var opcImg = '../../images/16_icono_up.gif';
		var opcTR = 'OPEN';
 }
 else {
		var opcTable = 'none';
		var opcImg = '../../images/16_icono_down.gif';
		var opcTR = 'CLOSE';
 }
	if (oObject != null){
	 if (oObject.length != null){
			for (i = 0; i < oObject.length; i++){
		 	if(erTable.test(oObject(i).id)) {	oObject(i).style.display = opcTable;	}
				if(erImg.test(oObject(i).id))			{	oObject(i).src = opcImg;	}
				if(erTR.test(oObject(i).id))				{ oObject(i).className = opcTR;	}				
   }
		}
		else {
			if(erTable.test(oObject(i).id)) {	oObject(i).style.display = opcTable;	}
			if(erImg.test(oObject(i).id))			{	oObject(i).src = opcImg;	}
			if(erTR.test(oObject(i).id))				{ oObject(i).className = opcTR;	}				
		}
	}
}

//*******************************************************************************
//
function ConstruirValidarFecha (campo, formulario, texto) {
	var fecha
	if (eval(formulario + '.' + campo + 'Dia.value') != '' || eval(formulario + '.' + campo + 'Mes.value') != '' || eval(formulario + '.' + campo + 'Agno.value') != '') {
	 	fecha = eval(formulario + '.' + campo + 'Dia.value') + '/' + eval(formulario + '.' + campo + 'Mes.value') + '/' + eval(formulario + '.' + campo + 'Agno.value')
 		eval(formulario + '.' + campo + '.value=fecha');
	 	if (IsDate (fecha, '/') == 0)  {
			alert ('La ' + texto + ' introducida no es válida');
			return false;
		}
	} 
}


//*******************************************************************************
// 
function ValidaLongTextArea(texto, numCar) {
	textoInicio = texto.value	
	if (textoInicio.length >= numCar) {
		texto.value = textoInicio.substring (0, numCar);
	}	
}

//**************************************************************************
// Sólo números en caja de texto
// UTILIZACIÓN:
// NO permite decimales --> onkeypress="onlyDigits(event,'noDec')"
// SI permite decimales	--> onkeypress="onlyDigits(event,'decOK')"
var isIE = document.all?true:false;
var isNS = document.layers?true:false;
function onlyDigits(e,decReq) {
var key = (isIE) ? window.event.keyCode : e.which;
var obj = (isIE) ? event.srcElement : e.target;
var isNum = (key > 47 && key < 58) ? true:false;
var dotOK = (key==46 && decReq=='decOK' && (obj.value.indexOf(".")<0 || obj.value.length==0)) ? true:false;
window.event.keyCode = (!isNum && !dotOK && isIE) ? 0:key;
e.which = (!isNum && !dotOK && isNS) ? 0:key;
return (isNum || dotOK);
}

//*******************************************************************************
// Función que nos va a contar el número de caracteres y de palabras del area de texto
// de un formulario
function wordCount(texto,campo) {

	textoArea = texto.value;
	numeroCaracteres = textoArea.length;

	// Eliminamos los caracteres en blanco del inicio y del final. Usamos expresiones regulares
	inicioBlanco = /^ / // El ^ indica principio de cadena
	finBlanco = / $/ // El $ indica final de cadena
	variosBlancos = /[ ]+/g // El global (g) es para obtener todas las posibles combinaciones

	textoArea = textoArea.replace(inicioBlanco,"");
	textoArea = textoArea.replace(finBlanco,"");
	textoArea = textoArea.replace(variosBlancos," ");

	// Creamos un array con las diferentes palabras. Teniendo en cuenta que la separación
	// entre palabras es el espacio en blanco.
	textoAreaDividido = textoArea.split(" ");
	numeroPalabras = textoAreaDividido.length;

	if (textoArea.length == 0) {
		campo.value = '0 caracteres 0 palabras';
	}
	else {
		// Mostramos los datos.
	// Tendremos en cuenta si hay que escribir en plural o en singular.
	tC = (numeroCaracteres==1)?" carácter":" caracteres";
	tP = (numeroPalabras==1)?" palabra":" palabras";
	campo.value = numeroCaracteres + tC + ' ' + numeroPalabras + tP;
	}
}

//***************************************************************************************************************
//************************************** VALIDA FECHAS **********************************************************
//***************************************************************************************************************
//El array "DaysInMonth" contiene los dias que tiene cada mes
var DaysInMonth = new Array()
DaysInMonth[0] = 31 //Los dias de Enero
DaysInMonth[1] = 0 //Los dias de Febrero se calculan mas adelante por si el año es bisiesto
DaysInMonth[2] = 31 //Los dias de Marzo
DaysInMonth[3] = 30 //Los dias de Abril
DaysInMonth[4] = 31 //Los dias de Mayo
DaysInMonth[5] = 30 //Los dias de Junio
DaysInMonth[6] = 31 //Los dias de Julio
DaysInMonth[7] = 31 //Los dias de Agosto
DaysInMonth[8] = 30 //Los dias de Septiembre
DaysInMonth[9] = 31 //Los dias de Octubre
DaysInMonth[10] = 30 //Los dias de Noviembre
DaysInMonth[11] = 31 //Los dias de Diciembre

//la funcion IsInteger(Chain) chequea si "Chain" es un numero entero sin signo valido
//La variable "Chain" es una cadena de caracteres
function IsInteger(Chain)
{
var Template = /^\d+$/ //Formato de numero entero sin signo
return Template.test(Chain) //Compara "Chain" con el formato "Template"
}

//La funcion "IsDay(Day, Month)" chequea si "Day" es un numero de dia valido para el mes "Month"
//Las variables "Day" y "Month" son cadenas de caracteres
function IsDay(Day, Month)
{
if (Day.substring(0,1) == 0) {
	Day = Day.substring (1,2)		
}
if (IsInteger(Day) && IsMonth(Month)) //Si "Day" es un numero entero valido y "Month" es un numero de mes valido
{
return (parseInt(Day)>0 && parseInt(Day)<=DaysInMonth[Month - 1]) ? 1 : 0 //Si "Day" esta entre 1 y los dias que tiene el mes "Month" devuelve verdadero si no devuelve falso
}
else return 0 //Si "Day" no es un numero entero valido o "Month" no es un numero de mes valido devuelve falso
}

//La funcion "IsMonth(Month)" chequea si "Month" es un numero de mes valido
//La variable "Month" es una cadena de caracteres
function IsMonth(Month)
{
if (Month.substring(0,1) == 0) {
	Month = Month.substring (1,2)		
}
if (IsInteger(Month)) //Si "Month" es un número entero valido
{
return (parseInt(Month)>0 && parseInt(Month)<=12) ? 1 : 0 //Si "Month" esta entre 1 y 12 devuelve verdadero si no devuelve falso
}
else return 0 //Si "Month" no es un numero entero valido devuelve falso
}

//La funcion "IsYear(Year)" chequea si "Year" es un numero de año valido
//La variable "Year" es una cadena de caracteres
function IsYear(Year)
{
if (IsInteger(Year)) //Si "Year" es un numero entero valido
{
return (Year.length == 4) ? 1 : 0 //Si "Year" tiene cuatro digitos devuelve verdadero si no devuelve falso
}
else return 0 //Si "Year" no es un numero entero valido devuelve falso
}

//La funcion IsLeapYear(Year) chequea si "Year" es un año es bisiesto
//La variable "Year" es una cadena de caracteres
function IsLeapYear(Year)
{
if (IsInteger(Year)) //Si "Year" es un numero entero valido
{
return ((Year % 4 == 0 && Year % 100 != 0) || (Year % 400 == 0)) ? 1 : 0// Si "Year" es un año es bisiesto devuelve verdadero si no devuelve falso
}
else return 0 //Si "Year" no es un numero entero valido devuelve falso
}

//La funcion IsDate(YourDate, YourDateSeparator) chequea si "YourDate" es una fecha valida con el separador de fecha "YourDateSeparator"
//Las variables "YourDate" y "YourDateSeparator" son cadenas de caracteres
function IsDate(YourDate, YourDateSeparator)
{
var IsAllOK = 1 //Variable iniciada como verdadera para saber si todas las validaciones fueron correctas
var YourDateParts = new Array() //Variable donde se almacenaran las partes de la fecha (dia, mes y año) tras haber eliminado el separador de la fecha
YourDateParts = YourDate.split(YourDateSeparator) //Se crean las partes de la fecha (dia, mes y año) eliminando el separador de la fecha
var Day = YourDateParts[0] //El dia corresponde al primer elemento del array
var Month = YourDateParts[1] //El mes corresponde al segundo elemento del array
var Year = YourDateParts[2] //El año corresponde al tercer elemento del array
if (IsYear(Year) && !IsLeapYear(Year)) //Si "Year" es un numero de año valido y no es bisiesto
{
DaysInMonth[1] = 28 //Como "Year" no es bisiesto Febrero tiene entonces 28 dias
}
else if (IsYear(Year) && IsLeapYear(Year)) //Si "Year" es un numero de año valido y es bisiesto
{
DaysInMonth[1] = 29 //Como "Year" es bisiesto Febrero tiene entonces 29 dias
}
else IsAllOK = 0 //Si "Year" no es un numero de año valido la variable pasa a ser falsa
IsAllOK = (IsMonth(Month)) ? IsAllOK : 0 //Si "Month" es un numero de mes valido la variable se queda como esta si no pasa a ser falsa
IsAllOK = (IsDay(Day, Month)) ? IsAllOK : 0 //Si "Day" es un numero de dia valido para el mes "Month" la variable se queda como esta si no pasa a ser falsa
return IsAllOK //Finalmente se devuelve el valor de la variable como verdadero o falso
}

//**********EOF****************************************************************