function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf('#')!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v3.0
var p,i,x;  if(!d) d=document; if((p=n.indexOf('?'))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




//DOCENCIA: 1 Y 2 CICLO

//-----------------------------------------------------------------------
// Verifica que se introduce los criterios de busqueda
//-----------------------------------------------------------------------
function verifica_form_busqueda_docencia(){
	if (document.busqueda.asg.value=="" && document.busqueda.ud.value=="valor0")
		alert("Tienes que indicar el código o el nombre de la asignatura o elegir una Unidad Docente!");
	else
		document.busqueda.submit();
	return true;
}


function aparece_apost(cadena){
	if(cadena.indexOf("'")>=0)
		return true;
	else
		return false;
}

function submit_form(f,caja,valor){
	eval(f+"."+caja+".value="+valor);
	eval(f+".submit()");
	return true;
}

function submit_form2(f,caja,valor){	
	eval(f+"."+caja+".value='"+valor+"'");
	eval(f+".submit()");
	return true;
}


//************** GESTION PLANTILLA-MODIFICACION PLANTILLA **************************************************
function mostrar_ayuda(){
	open("http://www.dsic.upv.es/docs/procedimientos/altamiembrohlp.htm","","");
}

function login_alta_miembro2(accion){
	if ((accion=="buscar") && ((document.buscarMiembro.login.value).length==0)){
		alert("Debe introducir el login del becario o colaborador");
	}else{	
		if (accion=="buscar"){
			document.buscarMiembro.action="modificar_miembro.pl";
		}
		if (accion=="nuevo"){
			document.buscarMiembro.action="entrar_datos_miembro.pl";
		}
		document.buscarMiembro.accion.value=accion;
		document.buscarMiembro.submit();
	}
}

function verificaFormMiembro2(destino){
  var err=0;
  if ((document.Miembro.dni.value).length==0 || (document.Miembro.dni.value).length>14){
	alert("Debe introducir el dni como máximo con 14 caracteres.");  
	err=1;
  } 
  if ((document.Miembro.nom.value).length==0){
	alert("Debe introducir el nombre");  
	err=1;
  }
  if ((document.Miembro.nom.value).length>20){
	alert("El nombre no puede contener más de 20 caracteres.");  
	err=1;
  }  
  if ((document.Miembro.ap1.value).length==0){
	alert("Debe introducir el primer apellido");  
	err=1;
  }
  if ((document.Miembro.ap1.value).length>20){
	alert("El primer apellido no puede contener más de 20 caracteres.");  
	err=1;
  }  
  if ((document.Miembro.ap2.value).length>20){
	alert("El segundo apellido no puede contener más de 20 caracteres.");  
	err=1;
  }   
  if (document.Miembro.relacionDepto.value==0){
	alert("Debe indicar el tipo de relación con el departamento."); 	
  	err=1;
  }
  if (document.Miembro.responsable.value==0){
	alert("Debe indicar el responsable"); 	
  	err=1;
  }        
  if ((document.Miembro.fecha_alta.value).length>0){
	res=esFechaOk(document.Miembro.fecha_alta.value);
	if (res>0){
		alert("La fecha de alta es incorrecta");
		document.Miembro.fecha_alta.focus();		
		err=1;
	}
  }else{
	alert("Debe introducirse la fecha de alta del contrato");  
	err=1;
  }
  if ((document.Miembro.fecha_baja.value).length>0)  {
	res=esFechaOk(document.Miembro.fecha_baja.value);
	if (res>0){
		alert("La fecha de baja es incorrecta");
		document.Miembro.fecha_baja.focus();					
		err=1;
	}
  }else{
	alert("Debe introducirse la fecha de baja del contrato"); 
	err=1;  
  }
  if ((document.Miembro.llaves.checked) && (document.Miembro.cod_desp.value==0)){
	alert("Debe indicar la ubicación"); 	
  	err=1;
  }  
  if (!(document.Miembro.llaves.checked) && (document.Miembro.cod_desp.value!=0)){
	alert("Debe marcar que solicita llaves si selecciona una ubicación"); 	
  	err=1;
  }   
      
  if (err==0){
	document.Miembro.action=destino;
	document.Miembro.submit();
  }
}

function ActualizaExtensiones2(destino){
	document.Miembro.action=destino;
	document.Miembro.accion.value="muestraExtension";
  	document.Miembro.submit();		
}

function ActualizaExtensiones2(destino){
	document.Miembro.action=destino;
	document.Miembro.accion.value="muestraExtension";
  	document.Miembro.submit();		
}


//--------------------------------------------------------------------------------------------


//************** GESTION PLANTILLA-MODIFICACION PLANTILLA **************************************************
function abrir_ayuda(){
	 open("http://www.dsic.upv.es/docs/procedimientos/altamiembrohlp.htm","");	
}

function login_alta_miembro(accion){
	if ((accion=="buscar") && ((document.datos.login.value).length==0)){
		alert("Debe introducir el login de la persona");
	}else{	
		document.datos.accion.value=accion;
		document.datos.submit();
	}
}

function login_bajas_plantilla(accion){
	if ((accion=="buscar") && ((document.datos.login.value).length==0)){
		alert("Debe introducir el login de la persona");
	}else{	
		document.datos.accion.value=accion;
		document.datos.submit();
	}
}

function login_gestion_plantilla(accion){
	if ((accion=="buscar") && (((document.datos.login[document.datos.login.selectedIndex]).value).length==0)){
		alert("Debe seleccionar una persona de la lista");
	}else{	
		document.datos.accion.value=accion;
		document.datos.submit();
	}
}


function esBisiesto(anyo){
	var x=(anyo % 400);
	var y=(anyo % 4);
	var z=(anyo % 100);		
	if (y==0){
		return 1;}
	else if (z!=0){
		return 0;}
	else if (x==0) {
		return 1;}				
	else{
		return 0;} 
}

function codMes(mes){
 if ((mes==1) || (mes==3) || (mes==5) || (mes==7) || (mes==8) || (mes==10) || (mes==12)){
 	return 1;
 }
 if ((mes==4) || (mes==6) || (mes==9) || (mes==11)){
 	return 2;
 } 
 if (mes==2){
 	return 3;
 }  
}
function esFechaOk(fecha){
	var err=0;
	//Descomponemos la fecha en dia,mes,anyo
	var my_fecha=fecha;	
	var pos=my_fecha.indexOf("/");	
	var my_dia=my_fecha.substring(0,pos);
	if (isNaN(my_dia)){
		err=1;
	}

	var my_fecha=my_fecha.substring(pos+1,my_fecha.length);
	var pos=my_fecha.indexOf("/");	
	var my_mes=my_fecha.substring(0,pos);
	if (isNaN(my_mes)){
		err=1;
	}else{
		my_mes=codMes(my_mes);
	}	
	
	var my_anyo=my_fecha.substring(pos+1,my_fecha.length);
	if (isNaN(my_anyo)){
		err=1;
	}

	if (err==0){
	 switch (my_mes){
	   case 1:
		if (my_dia<1 || my_dia>31){err=2;}
		break;
	   case 2:
		if (my_dia<1 || my_dia>30){err=3;}
		break;
	   case 3:
		if (esBisiesto(my_anyo)==1){if (my_dia<1 || my_dia>29){err=4;}				
		}else{if (my_dia<1 || my_dia>28){err=4;}}
		break;
	   }
	}

	return err;	
}

function ActualizaExtensiones(accion){
	if (accion=="grabar"){
		document.datos.accion.value="muestraExtensionG";
	}
	if (accion=="modificar"){
		document.datos.accion.value="muestraExtensionM";
	}
  	document.datos.submit();		
}

function ActualizaDatosEspacio(){
	document.datos.accion.value="mostrar";
  	document.datos.submit();		
}

function verificaFormMiembro(accion){
  var err=0;
  if ((document.datos.dni.value).length==0){
	alert("Debe introducir el dni.");  
	err=1;
  }
  if ((document.datos.dni.value).length>15){
	alert("El dni debe contener como máximo 15 caracteres.");  
	err=1;
  }  
  if ((document.datos.nom.value).length==0){
	alert("Debe introducirse el nombre");  
	err=1;
  }
  if ((document.datos.nom.value).length>20){
	alert("El nombre no puede contener más de 20 caracteres.");  
	err=1;
  }  
  if ((document.datos.ap1.value).length==0){
	alert("Debe introducirse el primer apellido");  
	err=1;
  }
  if ((document.datos.ap1.value).length>20){
	alert("El primer apellido no puede contener más de 20 caracteres.");  
	err=1;
  }  
  if ((document.datos.ap2.value).length>20){
	alert("El segundo apellido no puede contener más de 20 caracteres.");  
	err=1;
  }   
  if (document.datos.relacionDepto.value==0){
	alert("Debe indicar el tipo de relación con el departamento."); 	
  	err=1;
  }
  if (document.datos.responsable.value==0){
	alert("Debe indicar el responsable"); 	
  	err=1;
  }        
  if ((document.datos.fecha_alta.value).length>0){
	res=esFechaOk(document.datos.fecha_alta.value);
	if (res>0){
		alert("La fecha de alta es incorrecta");
		document.datos.fecha_alta.focus();		
		err=1;
	}
  }else{
	alert("Debe introducirse la fecha de alta del contrato");  
	err=1;
  }
  if ((document.datos.fecha_baja.value).length>0)  {
	res=esFechaOk(document.datos.fecha_baja.value);
	if (res>0){
		alert("La fecha de baja es incorrecta");
		document.datos.fecha_baja.focus();					
		err=1;
	}
  }else{
	alert("Debe introducirse la fecha de baja del contrato"); 
	err=1;  
  }
  if ((document.datos.llaves.checked) && (document.datos.cod_desp.value==0)){
	alert("Debe indicar la ubicación"); 	
  	err=1;
  }  
  if (!(document.datos.llaves.checked) && (document.datos.cod_desp.value!=0)){
	alert("Debe marcar que solicita llaves si selecciona una ubicación"); 	
  	err=1;
  }   
      
  if (err==0){
  	document.datos.accion.value=accion; 
  	document.datos.submit();
  }
  
}


function verificaFormPlantilla(accion,n){
  var err=0;
  var becario=n;
  if ((document.datos.dni.value).length==0){
	alert("Debe introducirse el dni");  
	err=1;
  }
  if ((document.datos.nom.value).length==0){
	alert("Debe introducirse el nombre");  
	err=1;
  }
  if ((document.datos.ap1.value).length==0){
	alert("Debe introducirse el primer apellido");  
	err=1;
  }
  if (document.datos.ctg.value==0){
	alert("Debe indicar el tipo de relación con el departamento."); 	
  	err=1;
  }
  if (becario>0){
	  if (document.datos.responsable.value==0){
		alert("Debe indicar el responsable"); 	
	  	err=1;
	  }        
	  if ((document.datos.fecha_alta.value).length>0){
		res=esFechaOk(document.datos.fecha_alta.value);
		if (res>0){
			alert("La fecha de alta es incorrecta");
			document.datos.fecha_alta.focus();		
			err=1;
		}
	  }else{
		alert("Debe introducirse la fecha de alta del contrato");  
		err=1;
	  }
	  if ((document.datos.fecha_baja.value).length>0)  {
		res=esFechaOk(document.datos.fecha_baja.value);	
		if (res>0){
			alert("La fecha de baja es incorrecta");
			document.datos.fecha_baja.focus();					
			err=1;
		}
	  }else{
		alert("Debe introducirse la fecha de baja del contrato"); 
		err=1;  
	  }
  }
  
  //if (document.datos.cod_desp.value=="0000" and document.datos.extension.value==0){
//	alert("Debe seleccionar una extensión telefónica"); 	
//  	err=1;
 // }   
      
  if (err==0){
  	document.datos.accion.value=accion; 
  	document.datos.submit();
  }
  
}

function verificaFormAltaPlantilla(accion){
  var err=0;
  var res=0;
  if ((document.datos.dni.value).length==0){
	alert("Debe introducirse el dni");  
	err=1;
  }
  if ((document.datos.nom.value).length==0){
	alert("Debe introducirse el nombre");  
	err=1;
  }
  if ((document.datos.ap1.value).length==0){
	alert("Debe introducirse el primer apellido");  
	err=1;
  }
  if (document.datos.ctg.value==0){
	alert("Debe indicar el tipo de relación con el departamento."); 	
  	err=1;
  }
  
  if ((document.datos.fecha_caducidad.value).length>0){
	res=esFechaOk(document.datos.fecha_caducidad.value);
	if (res>0){
		alert("La fecha de caducidad es incorrecta");
		document.datos.fecha_caducidad.focus();		
		err=1;
	}
  }
  
  if (err==0){
  	document.datos.accion.value=accion; 
  	document.datos.submit();
  }
  
}



function verificaFormCongreso(accion){
  var err=0;
  if ((document.datosCong.descripcion.value).length==0){
	alert("Debe introducirse la descripción");  
	err=1;
  }
  if ((document.datosCong.descripcion.value).length>20){
	alert("La descripción introducida no debe superar los 20 caracteres");  
	err=1;
  }  
  if (document.datosCong.responsable.value==0){
	alert("Debe indicar el responsable"); 	
  	err=1;
  }        
  if ((document.datosCong.fecha_alta.value).length>0){
	res=esFechaOk(document.datosCong.fecha_alta.value);
	if (res>0){
		alert("La fecha de alta es incorrecta");
		document.datosCong.fecha_alta.focus();		
		err=1;
	}
  }else{
	alert("Debe introducirse la fecha de alta de la cuenta.");  
	err=1;
  }
  if ((document.datosCong.fecha_baja.value).length>0)  {
	res=esFechaOk(document.datosCong.fecha_baja.value);
	if (res>0){
		alert("La fecha de baja es incorrecta");
		document.datosCong.fecha_baja.focus();					
		err=1;
	}
  }else{
	alert("Debe introducirse la fecha de baja de la cuenta."); 
	err=1;  
  }
  if (err==0){
  	document.datosCong.accion.value=accion; 
  	document.datosCong.submit();
  }
  
}

function verificaFormUsuario(accion){
  var err=0;
  if ((document.datosUsuario.nom.value).length==0 || (document.datosUsuario.ap1.value).length==0 || (document.datosUsuario.ap2.value).length==0){
	alert("Debe introducirse el nombre y los apellidos de la persona");  
	err=1;
  }  
  if ((document.datosUsuario.motivo.value).length==0){
	alert("Debe introducirse el motivo");  
	err=1;
  }
  if ((document.datosUsuario.motivo.value).length>20){
	alert("El motivo no debe superar los 20 caracteres");  
	err=1;
  }  
  if (document.datosUsuario.responsable.value==0){
	alert("Debe indicar el responsable"); 	
  	err=1;
  }        
  if ((document.datosUsuario.fecha_alta.value).length>0){
	res=esFechaOk(document.datosUsuario.fecha_alta.value);
	if (res>0){
		alert("La fecha de alta es incorrecta");
		document.datosUsuario.fecha_alta.focus();		
		err=1;
	}
  }else{
	alert("Debe introducirse la fecha de alta de la cuenta.");  
	err=1;
  }
  if ((document.datosUsuario.fecha_baja.value).length>0)  {
	res=esFechaOk(document.datosUsuario.fecha_baja.value);
	if (res>0){
		alert("La fecha de baja es incorrecta");
		document.datosUsuario.fecha_baja.focus();					
		err=1;
	}
  }else{
	alert("Debe introducirse la fecha de baja de la cuenta."); 
	err=1;  
  }
  if (err==0){
  	document.datosUsuario.accion.value=accion; 
  	document.datosUsuario.submit();
  }
  
}

//************** GESTION PLANTILLA-SOLICITAR SERVICIOS **************************************************
function validarSolicitudServicios(){
 var err=0;
  
  if (document.solicitud_servicios.miembro.value==0){
  	alert ("Seleccione un miembro de la lista");
  	err=1;
  } 
  if ((document.solicitud_servicios.llaves[1].checked) && (document.solicitud_servicios.otros_accesos.value=="")){
  	alert ("Indique los accesos a los que desea permisos");
  	err=1;
  }
  
  if (err==0){
 	document.solicitud_servicios.accion.value="solicitar";
	document.solicitud_servicios.submit();
  }
}



//--------------------Gestión llaves----------------------------------

function verificaGestionLlaves(){
  var err=0;
  var res=0;
  var i=0;
  var fecha;

  var tot=document.datos.total.value;
 
  
  //Verifica las fechas de entrega
  if (tot>1){
	  for (i=0;i<tot;i++){  	
	  	if ((document.datos.fechaEntrega[i].value).length>0){
	  		res=esFechaOk(document.datos.fechaEntrega[i].value);
			if (res>0){err=1};
		}
	  }
  }else{
	  if ((document.datos.fechaEntrega.value).length>0){
	  	res=esFechaOk(document.datos.fechaEntrega.value);
		if (res>0){err=1};
	  }
  }
  
  //Verifica las fechas de devolucion
  if (tot>1){
	  for (i=0;i<tot;i++){
	  	if ((document.datos.fechaDevolucion[i].value).length>0){
	  		res=esFechaOk(document.datos.fechaDevolucion[i].value);
			if (res>0){err=1};
		}
	  }
  }else{
	  if ((document.datos.fechaDevolucion.value).length>0){
	  	res=esFechaOk(document.datos.fechaDevolucion.value);
		if (res>0){err=1};
	  }
  }
  
  if (err==0){
  	document.datos.accion.value="grabar"; 
  	document.datos.submit();
  }else{
  	alert("Alguna de las fechas es incorrecta");
  }
}

function borrarEntradaHistoricoLlaves(){
  	document.datos.accion.value="borrar"; 
  	document.datos.submit();
}

//--------------------------------------------------------------------------------

function iluminar(f){
	if(is_opera){
		//form=document.getElementById(f);
		//form.modificar.disabled=false;
		//form.eliminar.disabled=false;
	}
	else{
		f.modificar.disabled=false;
		f.eliminar.disabled=false;
	}
	return true;
}

//************************************* PERFILES **************************************************

function openperfil(){
	open("https://www.dsic.upv.es/mapa/espanyol/intranet/perfil.pl","perfil","scrollbars=yes,toolbar=no,menubar=no,width=250,height=250");
}


function agenIdent(cod){
	switch(cod){
		case 0: return 'tecnico';
			break;
		case 1: return 'director';
			break;
		case 2: return 'subdocente';
			break;
		case 3: return 'subinfra';
			break;
		case 4:	return 'subinves';
			break;
		case 5: return 'subcal';
			break;
		case 6: return 'secretario';
			break;
		case 7: return 'admin';
			break;
		case 8: return 'profe';
			break;
		case 9: return 'respud';
			break;
		case 10:return 'respasg';
			break;
		case 11:return 'respwebinves';
			break;			
	   			
	}
}

function canvi_perfil(f,codi){
	f.noucodi.value=codi;
	f.submit();
	return true;
}

//*************************************** GESTION ACCIONES ******************************************

function gestion_acciones(){
	 open("gestionacciones.pl","gestionacciones","toolbar=no,menubar=no,width=640,height=480");	
}

function anyadir_accion(f,caja,valor){
	if(eval(f+".desc.value")=="")
		alert("La descripción no es correcta!");
	//else if(!fecha_correcta(eval(f+".fecha.value"))
	//	alert("La fecha no es correcta!");
	else{
		submit_form(f,caja,valor);
	}
        return true;
}

function eliminar_accion(f,caja,valor){
     
	if(eval(f+".acc.selectedIndex")>=0){
		respuesta=confirm("Esta a punto de eliminar una acción. Esta seguro?");
		if(respuesta==true)
       			submit_form(f,caja,valor);
	}
	else 
		alert("No has elegido ninguna acción!");
	return true;
}

function modificar_accion(f,caja,valor){
	 if(eval(f+".acc.selectedIndex")>=0)
                submit_form(f,caja,valor);
        else
                alert("No has elegido ninguna acción!");
        return true;
}


//*************************************** GESTION TABLON ******************************************

function gestion_tablon(){
	 open("tablon/tablongestion.pl","tablongestion","toolbar=no,menubar=no,width=640,height=480");	
}

function gestionar_anuncio(accion){
	var err=0;

	if(accion == 1){
		document.listanun.action="entrar_nuevo_anuncio.pl";
	}else if (accion == 2){
		if(document.listanun.anuncio.selectedIndex>=0){
			respuesta = confirm("Esta a punto de eliminar un anuncio. Esta seguro?");
			if (respuesta==false){
	       			err=1;
	       		}
		}else{
			alert("No has elegido ningun anuncio!");
			err=1;
		}
		document.listanun.accion.value="2";
		document.listanun.action="tablongestion.pl";
	}
	else if (accion == 3){
		document.listanun.action="modificar_anuncio.pl";
	}
	if (err==0){
		document.listanun.submit();
	}
}

function verifica_form_anuncio(){
	var err=0;
	if ((document.nuevoanuncio.titulo.value).length==0){
		alert("Falta introducir el titulo del anuncio!");
		document.nuevoanuncio.titulo.focus();
		err=1;		
	}
        if ((document.nuevoanuncio.fechacad.value).length>0){
		if (!fecha_correcta(document.nuevoanuncio.fechacad,"Fecha de caducidad incorrecta")){
			document.nuevoanuncio.fechacad.focus();
			err=1;
		}
	}
	if (err==0){
	  	document.nuevoanuncio.submit();
	}
}

function verifica_form_mod_anuncio(){
	var err=0;
	
	if ((document.modanuncio.titulo.value).length==0){
		alert("Falta introducir el titulo del anuncio!");
		document.modanuncio.titulo.focus();
		err=1;		
	}
        if ((document.modanuncio.fechacad.value).length>0){
		if (!fecha_correcta(document.modanuncio.fechacad,'Fecha de caducidad incorrecta')){
			document.modanuncio.fechacad.focus();
			err=1;
		}
	}
	if (err==0){
	  	document.modanuncio.submit();
	}
}

function anyadir_documento(anuncio){	
	document.modanuncio.action="entrar_nuevo_doc.pl";
	document.modanuncio.submit();
}

function eliminar_documento(anuncio){
	var err=0;

	if(document.modanuncio.docs.selectedIndex>=0){
		respuesta = confirm("Esta a punto de eliminar el documento. Esta seguro?");
		if (respuesta==false){
	       		err=1;
	       	}
	}else{
		alert("No has seleccionado ningun documento!");
		err=1;
	}
	if (err==0){
		document.modanuncio.accion.value="eliminar_doc";
		document.modanuncio.action="modificar_anuncio.pl";
		document.modanuncio.submit();
	}
}
function verifica_form_doc_anuncio(){
	var err=0;
	
	if ((document.nuevodoc.titulo.value).length==0){
		alert("Falta introducir el titulo del documento!");
		document.nuevodoc.titulo.focus();
		err=1;		
	}
	if ((document.nuevodoc.documento.value).length==0){
		alert("Debe seleccionar un documento!");
		err=1;		
	}	
	if (err==0){
	  	document.nuevodoc.submit();
	}
}


function anyadir_anuncio(f,caja,valor){
	var err=0;
	
	if(eval(f+".titulo.value")==""){
		alert("Falta introducir el titulo del anuncio!");
		eval(f+".titulo.focus()");
		err=1;		
	}
        if ((eval(f+".fechacad.value")).length>0){
		if (!fecha_correcta(eval(f+".fechacad"),'Fecha de caducidad incorrecta')){
			eval(f+".fechacad.focus()");
			err=1;
		}
	}
	if (err==0){
	  	submit_form(f,caja,valor);
	}
        return true;
}

function eliminar_anuncio(f,caja,valor){
     
	if(eval(f+".anuncio.selectedIndex")>=0){
		respuesta=confirm("Esta a punto de eliminar un anuncio. Esta seguro?");
		if(respuesta==true)
       			submit_form(f,caja,valor);
	}
	else
		alert("No has elegido ningun anuncio!");
	return true;
}

function modificar_anuncio(f,caja,valor){
	 if(eval(f+".anuncio.selectedIndex")>=0)
                submit_form(f,caja,valor);
        else
                alert("No has elegido ningun anuncio!");
        return true;
}

function ilumina_destino(){
	if(document.nuevoanuncio.correo.checked==true){
		document.nuevoanuncio.destinocorreo.disabled=false;
	}
	else{
		document.nuevoanuncio.destinocorreo.disabled=true;
	}
}

//****************************** VISOR ***************************

function ancho(path){
 	imagen=new Image;
 	imagen.src=path;
 	return imagen.width;
 }
 	
 function alto(path){
 	imagen=new Image;
 	imagen.src=path;
 	return imagen.height;
 }

function visor(filename)
{ 
 	window.parent.imagex=ancho(filename);
  	window.parent.imagey=alto(filename);
  	window.parent.imagename=filename;
  	open('http://www.dsic.upv.es/mapa/espanyol/visor.pl','VISOR','scrollbars,status,resizable');
  	//viewer.opener=window;
  	//viewer.focus();
 }

//******************************** GESTIÓN INFORMES DOCENTES ******************************


function Inf_Doc(){
	this.pclaves=new Array();
	this.codigo="";
	this.noucodigo="";
	this.titulo="";
	this.autor="";
	this.anyo="";
	this.fichero="";
}


function gestion_inf_doc(){
	open("gestioninfdoc.pl","gestioninfdoc","toolbar=no,menubar=no,width=640,height=480");	
}

function codigo_valido(codigo,tipo){
	codigo=String(codigo);
	
	// Trim
	num_car=codigo.length;
	pos=0;
	while(codigo.charAt(pos)==" "){
		codigo=codigo.substring(pos+1,num_car)
		num_car=codigo.length;
		pos++;
	}
	num_car=codigo.length;
	while(codigo.charAt(num_car-1)==" "){
		codigo=codigo.substring(0,num_car-1)
		num_car=codigo.length;
	}
	//--
	
	num_car=codigo.length;
	switch(tipo){
		case 0: // informe docente
			if(codigo.substring(0,8)!="DSIC-DD/") return false;
			if(codigo.substring(num_car-3,num_car-2)!="/") return false;
			break;
		case 1: // informe de investigacion
			if(codigo.substring(0,8)!="DSIC-II/") return false;
                        if(codigo.substring(num_car-3,num_car-2)!="/") return false;
                        break;
	
	}		
	return true;
}

function anyadir_informe_docente(f,caja,valor){
        if(eval(f+".codigo.value")==""){
                alert("Falta introducir el codigo del informe!");
		eval(f+".codigo.focus()");
	}
        else if(eval(f+".titulo.value")==""){
                alert("Falta introducir el titulo del informe!");
		eval(f+".titulo.focus()");
	}
        else if(eval(f+".autor.value")==""){
                alert("Falta introducir el autor del informe!");
		eval(f+".autor.focus()");
	}
	else if((valor==3 && !codigo_valido(eval(f+".codigo.value"),0)) || (valor==5 && !codigo_valido(eval(f+".noucodigo.value"),0)) ){
		alert("El codigo no es correcto");
		if(valor==3) eval(f+".codigo.focus()");
		else eval(f+".noucodigo.focus()");
	}
	else if(eval(f+".anyo.value").length!=4){
                alert("El anyo no es correcto");
                eval(f+".anyo.focus()");
        }
	else{
		var num=window.opener.inf_doc.pclaves.length;
		for(i=0;i<num;i++){
                        eval(f+".pclaves.options[i].selected=true");
                }
		vaciar_informe_doc();
                submit_form(f,caja,valor);
        }
        return true;
}

function eliminar_inf_doc(f,caja,valor){

        if(eval(f+".informe.selectedIndex")>=0){
                respuesta=confirm("Esta a punto de eliminar un informe docente. Esta seguro?");
                if(respuesta==true)
                        submit_form(f,caja,valor);
        }
        else
                alert("No has elegido ningun informe!");
        return true;
}

function modificar_inf_doc(f,caja,valor){
         if(eval(f+".informe.selectedIndex")>=0)
                submit_form(f,caja,valor);
        else
                alert("No has elegido ningun informe!");
        return true;
}

function vaciar_informe_doc(){
	window.opener.inf_doc.codigo="";
	window.opener.inf_doc.noucodigo="";
        window.opener.inf_doc.titulo="";
        window.opener.inf_doc.autor="";
        window.opener.inf_doc.anyo="";
        window.opener.inf_doc.fichero="";
        var num=window.opener.inf_doc.pclaves.length;
        for(i=0;i<num;i++){
                window.opener.inf_doc.pclaves.pop();
        }
}

function cancelar_accion(tipo){
	switch(tipo){
		case 0: vaciar_informe_doc();
			break;
		case 1: vaciar_informe_inv();
			break;
		case 2: vaciar_tesis();
			break;
	}
	var atras=history.length;
        atras=-atras;
        if(is_nav) atras++;
        history.go(atras);

}

function new_pk_inf_doc(accion){
	if(document.informes.palabra.value!=""){
		var new_pc=window.opener.inf_doc.pclaves.length;
		window.opener.inf_doc.pclaves[new_pc]=document.informes.palabra.value;
		window.opener.inf_doc.codigo=document.informes.codigo.value;
		//window.opener.inf_doc.noucodigo=document.informes.noucodigo.value;
	        window.opener.inf_doc.titulo=document.informes.titulo.value;
        	window.opener.inf_doc.autor=document.informes.autor.value;
        	window.opener.inf_doc.anyo=document.informes.anyo.value;

		var url=String(window.location);
		if(url.indexOf("?accion=")==-1){
 			window.location=url+"?accion="+accion;
		}
		else{
			window.location.reload()
		}		
	}
	else{
		alert("No has introducido ninguna palabra!");
	}
}

function el_pk_inf_doc(accion){
 	var i=document.informes.pclaves.selectedIndex;
        if(i<0)
                alert("No has seleccionado ninguna palabra!");
        else{
        	window.opener.inf_doc.pclaves[i]=window.opener.inf_doc.pclaves[window.opener.inf_doc.pclaves.length-1];
                window.opener.inf_doc.pclaves.pop();
                window.opener.inf_doc.codigo=document.informes.codigo.value;
		//window.opener.inf_doc.noucodigo=document.informes.noucodigo.value;
	        window.opener.inf_doc.titulo=document.informes.titulo.value;
        	window.opener.inf_doc.autor=document.informes.autor.value;
        	window.opener.inf_doc.anyo=document.informes.anyo.value;

       		var url=String(window.location);
                if(url.indexOf("?accion=")==-1){
                        window.location=url+"?accion="+accion;
                }
                else{
                        window.location.reload()
                }

        }
}

//******************************** GESTIÓN INFORMES DE INVESTIGACION ******************************


function Inf_Inv(){
	this.pclaves=new Array();
	this.codigo="";
	this.noucodigo="";
	this.titulo="";
	this.autor="";
	this.anyo="";
	this.fichero="";
}


function gestion_inf_inv(){
	open("gestioninfinv.pl","gestioninfinv","toolbar=no,menubar=no,width=640,height=480");	
}

function anyadir_informe_inv(f,caja,valor){
        if(eval(f+".codigo.value")==""){
                alert("Falta introducir el codigo del informe!");
		eval(f+".codigo.focus()");
	}
        else if(eval(f+".titulo.value")==""){
                alert("Falta introducir el titulo del informe!");
		eval(f+".titulo.focus()");
	}
        else if(eval(f+".autor.value")==""){
                alert("Falta introducir el autor del informe!");
		eval(f+".autor.focus()");
	}
	else if((valor==3 && !codigo_valido(eval(f+".codigo.value"),1)) || (valor==5 && !codigo_valido(eval(f+".noucodigo.value"),1)) ){
                alert("El codigo no es correcto");
                if(valor==3) eval(f+".codigo.focus()");
                else eval(f+".noucodigo.focus()");
        }
	else if(eval(f+".anyo.value").length!=4){
                alert("El anyo no es correcto");
                eval(f+".anyo.focus()");
        }
	else{
		var num=window.opener.inf_inv.pclaves.length;
		for(i=0;i<num;i++){
                        eval(f+".pclaves.options[i].selected=true");
                }
		vaciar_informe_inv();
                submit_form(f,caja,valor);
        }
        return true;
}

function eliminar_inf_inv(f,caja,valor){

        if(eval(f+".informe.selectedIndex")>=0){
                respuesta=confirm("Esta a punto de eliminar un informe de investigación. Esta seguro?");
                if(respuesta==true)
                        submit_form(f,caja,valor);
        }
        else
                alert("No has elegido ningun informe!");
        return true;
}

function modificar_inf_inv(f,caja,valor){
         if(eval(f+".informe.selectedIndex")>=0)
                submit_form(f,caja,valor);
        else
                alert("No has elegido ningun informe!");
        return true;
}

function vaciar_informe_inv(){
	window.opener.inf_inv.codigo="";
	window.opener.inf_inv.noucodigo="";
        window.opener.inf_inv.titulo="";
        window.opener.inf_inv.autor="";
        window.opener.inf_inv.anyo="";
        window.opener.inf_inv.fichero="";
        var num=window.opener.inf_inv.pclaves.length;
        for(i=0;i<num;i++){
                window.opener.inf_inv.pclaves.pop();
        }
}


function new_pk_inf_inv(accion){
	if(document.informes.palabra.value!=""){
		var new_pc=window.opener.inf_inv.pclaves.length;
		window.opener.inf_inv.pclaves[new_pc]=document.informes.palabra.value;
		window.opener.inf_inv.codigo=document.informes.codigo.value;
		//window.opener.inf_inv.noucodigo=document.informes.noucodigo.value;
	        window.opener.inf_inv.titulo=document.informes.titulo.value;
        	window.opener.inf_inv.autor=document.informes.autor.value;
        	window.opener.inf_inv.anyo=document.informes.anyo.value;

		var url=String(window.location);
		if(url.indexOf("?accion=")==-1){
 			window.location=url+"?accion="+accion;
		}
		else{
			window.location.reload()
		}		
	}
	else{
		alert("No has introducido ninguna palabra!");
	}
}

function el_pk_inf_inv(accion){
 	var i=document.informes.pclaves.selectedIndex;
        if(i<0)
                alert("No has seleccionado ninguna palabra!");
        else{
                window.opener.inf_inv.pclaves[i]=window.opener.inf_inv.pclaves[window.opener.inf_inv.pclaves.length-1];
                window.opener.inf_inv.pclaves.pop();
                window.opener.inf_inv.codigo=document.informes.codigo.value;
		//window.opener.inf_inv.noucodigo=document.informes.noucodigo.value;
	        window.opener.inf_inv.titulo=document.informes.titulo.value;
        	window.opener.inf_inv.autor=document.informes.autor.value;
        	window.opener.inf_inv.anyo=document.informes.anyo.value;

       		var url=String(window.location);
                if(url.indexOf("?accion=")==-1){
                        window.location=url+"?accion="+accion;
                }
                else{
                        window.location.reload()
                }

        }
}
//******************************** GESTIÓN TESIS ******************************

function Tesis(){
	this.pclaves=new Array();
	this.codigo="";
	this.noucodigo="";
	this.titulo="";
	this.autor="";
	this.director="";
	this.resumen="";
	this.programa="";
	this.num_registro="";
	this.presentacion="";
	this.lectura="";
	this.fichero="";
}


function gestion_tesis(){
	open("gestiontesis.pl","gestiontesis","toolbar=no,menubar=no,width=640,height=700");	
}

function anyadir_tesis(f,caja,valor){
	codigo=String(eval(f+".codigo.value"));
	titulo=String(eval(f+".titulo.value"));
	autor=String(eval(f+".autor.value"));
	director=String(eval(f+".director.value"));
	presentacion=String(eval(f+".presentacion.value"));
	lectura=String(eval(f+".lectura.value"));
	num_registro=String(eval(f+".num_registro.value"));
	resumen=String(eval(f+".resumen.value"));
	
        if(codigo==""){
                alert("Falta introducir el codigo de la tesis!");
		eval(f+".codigo.focus()");
	}
        else if(titulo==""){
                alert("Falta introducir el titulo de la tesis!");
		eval(f+".titulo.focus()");
	}
        else if(autor==""){
                alert("Falta introducir el autor de la tesis!");
		eval(f+".autor.focus()");
	}
	else if(director==""){
                alert("Falta introducir el director de la tesis!");
		eval(f+".director.focus()");
	}
	else if(aparece_apost(codigo)){
		alert("El caracter ' no puede aparecer en el código!");
		eval(f+".codigo.focus()");
	}
	else{
		var num=window.opener.tesis.pclaves.length;
		for(i=0;i<num;i++){
                        eval(f+".pclaves.options[i].selected=true");
                }
		vaciar_tesis();
                submit_form(f,caja,valor);
        }
        return true;
}

function vaciar_tesis(){
	window.opener.tesis.codigo="";
	window.opener.tesis.noucodigo="";
        window.opener.tesis.titulo="";
        window.opener.tesis.autor="";
        window.opener.tesis.director="";
        window.opener.tesis.presentacion="";
        window.opener.tesis.lectura="";
        window.opener.tesis.num_registro="";
        window.opener.tesis.resumen="";
        window.opener.tesis.fichero="";
        window.opener.tesis.programa="";
        var num=window.opener.tesis.pclaves.length;
        for(i=0;i<num;i++){
                window.opener.tesis.pclaves.pop();
        }
}

function new_pk_tesis(accion){
	if(document.tesis.palabra.value!=""){
		var new_pc=window.opener.tesis.pclaves.length;
		window.opener.tesis.pclaves[new_pc]=document.tesis.palabra.value;
		window.opener.tesis.codigo=document.tesis.codigo.value;
		//window.opener.tesis.noucodigo=document.tesis.noucodigo.value;
	        window.opener.tesis.titulo=document.tesis.titulo.value;
        	window.opener.tesis.autor=document.tesis.autor.value;
        	window.opener.tesis.director=document.tesis.director.value;
        	window.opener.tesis.resumen=document.tesis.resumen.value;
        	window.opener.tesis.programa=document.tesis.programa.value;
        	window.opener.tesis.num_registro=document.tesis.num_registro.value;
        	window.opener.tesis.presentacion=document.tesis.presentacion.value;
        	window.opener.tesis.lectura=document.tesis.lectura.value;
        	        	
        	var url=String(window.location);
		if(url.indexOf("?accion=")==-1){
 			window.location=url+"?accion="+accion;
		}
		else{
			window.location.reload()
		}		
	}
	else{
		alert("No has introducido ninguna palabra!");
	}
}

function el_pk_tesis(accion){
 	var i=document.tesis.pclaves.selectedIndex;
        if(i<0)
                alert("No has seleccionado ninguna palabra!");
        else{
                window.opener.tesis.pclaves[i]=window.opener.tesis.pclaves[window.opener.tesis.pclaves.length-1];
                window.opener.tesis.pclaves.pop();
                window.opener.tesis.codigo=document.tesis.codigo.value;
		//window.opener.tesis.noucodigo=document.tesis.noucodigo.value;
		window.opener.tesis.titulo=document.tesis.titulo.value;
	        window.opener.tesis.autor=document.tesis.autor.value;
        	window.opener.tesis.director=document.tesis.director.value;
        	window.opener.tesis.resumen=document.tesis.resumen.value;
        	window.opener.tesis.programa=document.tesis.programa.value;
        	window.opener.tesis.num_registro=document.tesis.num_registro.value;
        	window.opener.tesis.presentacion=document.tesis.presentacion.value;
        	window.opener.tesis.lectura=document.tesis.lectura.value;

       		var url=String(window.location);
                if(url.indexOf("?accion=")==-1){
                        window.location=url+"?accion="+accion;
                }
                else{
                        window.location.reload()
                }
        }
}

function modificar_tesis(f,caja,valor){
         if(eval(f+".tesis.selectedIndex")>=0)
                submit_form(f,caja,valor);
        else
                alert("No has elegido ninguna tesis!");
        return true;
}


function eliminar_tesis(f,caja,valor){
        if(eval(f+".tesis.selectedIndex")>=0){
                respuesta=confirm("Esta a punto de eliminar una tesis. Esta seguro?");
                if(respuesta==true)
                        submit_form(f,caja,valor);
        }
        else
                alert("No has elegido ninguna tesis!");
        return true;
}





//********************************* GESTIÓN GRUPOS *********************************


function gestion_linea(accion){
	switch(accion){
		case 0: // Nueva linea
			grupo=document.fdatos.grupo.value;
			open("gestionlinea.pl?grup="+grupo,"gestionlinea","toolbar=no,menubar=no,width=500,height=350");	
			break;
		case 1: //Modificar
			if(document.flineas.lineas.selectedIndex>=0){
				grupo=document.fdatos.grupo.value;
				linea=document.flineas.lineas.options[document.flineas.lineas.selectedIndex].value;
				open("gestionlinea.pl?grup="+grupo+"&linia="+linea,"gestionlinea","toolbar=no,menubar=no,width=500,height=350");	
			}
			else alert("Tienes que elegir una línea!");
			break;
		case 2: //Eliminar
			if(document.flineas.lineas.selectedIndex>=0){
				if(confirm("Esta a punto de eliminar una línea de investigación. Esta seguro?")){
					grupo=document.fdatos.grupo.value;
					linea=document.flineas.lineas.options[document.flineas.lineas.selectedIndex].value;
					open("gestionlinea.pl?grup="+grupo+"&linia="+linea+"&accio=2","gestionlinea","toolbar=no,menubar=no,width=500,height=350");	
				}
			}
			else alert("Tienes que elegir una línea!");
			break;
	}
}

function gestion_proys(accion){
	switch(accion){
		case 0: // Nueva linea
			grupo=document.fdatos.grupo.value;
			open("gestionproys.pl?grup="+grupo,"gestionproys","toolbar=no,menubar=no,width=500,height=500");	
			break;
		case 1: //Modificar
			if(document.fproys.proys.selectedIndex>=0){
				grupo=document.fdatos.grupo.value;
				proy=document.fproys.proys.options[document.fproys.proys.selectedIndex].value;
				open("gestionproys.pl?grup="+grupo+"&proy="+proy,"gestionproy","toolbar=no,menubar=no,width=500,height=500");	
			}
			else alert("Tienes que elegir un proyecto!");
			break;
		case 2: //Eliminar
			if(document.fproys.proys.selectedIndex>=0){
				if(confirm("Esta a punto de eliminar un proyecto de investigación. Esta seguro?")){
					grupo=document.fdatos.grupo.value;
					proy=document.fproys.proys.options[document.fproys.proys.selectedIndex].value;
					open("gestionproys.pl?grup="+grupo+"&proy="+proy+"&accio=2","gestionproy","toolbar=no,menubar=no,width=500,height=500");	
				}
			}
			else alert("Tienes que elegir un proyecto!");
			break;
	}
}

function caja_nombre(){
	if(document.f.tipo[1].checked){
		document.f.nom.disabled=false;
		document.f.nomexist.disabled=true;
		document.f.desc.disabled=false;
		document.f.subv.disabled=false;
		document.f.dur.disabled=false;
	}
	else{
		document.f.nom.disabled=true;
		document.f.nomexist.disabled=false;
		document.f.desc.disabled=true;
		document.f.subv.disabled=true;
		document.f.dur.disabled=true;
	}
}

function gestion_miembros(accion){
	document.fmem.accion.value=accion;
	document.fmem.submit();
}

function guarda_proy(){
	err=0;
	switch(document.f.accio.value){
		case "1": //Modificar
			nom=String(document.f.nom.value);
			if(nom=="") err=1;
			if(!err && nom.length>4000) err=6;
			if(!err && aparece_apost(nom)) err=2;
			break;
		case "0": //Nou
			if(document.f.nom.value=="" && document.f.nomexist.disabled==true) err=1;
			if(!err && document.f.nom.disabled==false && aparece_apost(document.f.nom.value)) err=2;
			break;
	}
	
	desc=String(document.f.desc.value);
	if(!err && desc.length>4000) err=7;
	if(!err && aparece_apost(desc)) err=3;
	if(!err && aparece_apost(document.f.subv.value)) err=4;
	if(!err && aparece_apost(document.f.dur.value)) err=5;
	
	if(!err){
		document.f.submit();
	}
	else{
		switch(err){
			case 1: alert("Tienes que introducir el nombre del proyecto!");
				break;
			case 2: alert("El caracter ' no puede aparecer en el nombre!");
				document.f.nom.focus();
				break;
			case 3: alert("El caracter ' no puede aparecer en la descripción!");
				document.f.desc.focus();
				break;
			case 4: alert("El caracter ' no puede aparecer en el organismo!");
				document.f.subv.focus();
				break;
			case 5: alert("El caracter ' no puede aparecer en la duración!");
				document.f.dur.focus();
				break;
			case 6: alert("El nombre del proyecto es demasiado largo!");
				document.f.nom.focus();
				break;
			case 7: alert("La descripción del proyecto es demasiado larga!");
				document.f.desc.focus();
				break;
		}
			
	}
}

function guarda_linea(){
	err=0;
	nom=String(document.f.nom.value);
	desc=String(document.f.desc.value);
	if(nom=="") err=1;
	if(!err && nom.length>200) err=4;
	if(!err && aparece_apost(nom)) err=2;
	if(!err && desc.length>4000) err=5;
	if(!err && aparece_apost(desc)) err=3;
	
	if(!err){
		document.f.submit();
	}
	else{
		switch(err){
			case 1: alert("Tienes que introducir el nombre de la línea!");
				document.f.nom.focus();
				break;
			case 2: alert("El caracter ' no puede aparecer en el nombre!");
				document.f.nom.focus();
				break;
			case 3: alert("El caracter ' no puede aparecer en la descripción!");
				document.f.nom.focus();
				break;
			case 4: alert("El nombre de la línea es demasiado largo!");
				document.f.nom.focus();
				break;
			case 5: alert("La descripción de la línea es demasiado larga!");
				document.f.nom.focus();
				break;
		}
	}
}



//*************************************** GESTIÓN PROGRAMAS PROY EUROPA ******************************************

function gestion_programas_europa(){
	 open("gestionprogseuropa.pl","gestionprogseuropa","toolbar=no,menubar=no,width=640,height=480");	
}

function anyadir_prog_europa(f,caja,valor){
	if(eval(f+".codigo.value")==""){
		alert("El codigo no es correcto!");
		eval(f+".codigo.focus()");
	}
	else if(aparece_apost(eval(f+".codigo.value"))){
		alert("No puede aparecer el carcater ' en el codigo!");
		eval(f+".codigo.focus()");
	}
	else if(aparece_apost(eval(f+".nombre.value"))){
		alert("No puede aparecer el carcater ' en el nombre!");
		eval(f+".nombre.focus()");
	}
	else if(aparece_apost(eval(f+".desc.value"))){
		alert("No puede aparecer el carcater ' en la descripcion!");
		eval(f+".desc.focus()");
	}
	else{
		submit_form(f,caja,valor);
	}
        return true;
}

function eliminar_prog_europa(f,caja,valor){
     
	if(eval(f+".prog.selectedIndex")>=0){
		respuesta=confirm("Esta a punto de eliminar un programa. Esta seguro?");
		if(respuesta==true)
       			submit_form(f,caja,valor);
	}
	else 
		alert("No has elegido ningun programa!");
	return true;
}

function modificar_prog_europa(f,caja,valor){
	if(eval(f+".prog.selectedIndex")>=0)
                submit_form(f,caja,valor);
        else
                alert("No has elegido ningun programa!");
        return true;
}

function nuevo_doc_prog_europa(){
	document.progs.accion.value=8;
	document.progs.submit();
}
function anyadir_doc_prog_europa(){
	document.progs.accion.value=6;
	if ((document.progs.titulo.value).length==0){
		alert("Debe introducir el título");
        }else if ((document.progs.documento.value).length==0){
		alert("Debe indicar la ruta del documento a subir");        	
        }else{
		document.progs.submit();
	}
}

function nuevo_info_prog_europa(){
	document.progs.accion.value=9;
	document.progs.submit();
}

function anyadir_info_prog_europa(){
	document.progs.accion.value=10;
	if ((document.progs.texto.value).length==0){
		alert("Debe introducir el texto");
        }else{
		document.progs.submit();
	}	
}
function eliminar_info_prog_europa(){
	var i=0;
	var j=0;
	var seleccionado=0;
	document.progs.accion.value=11;
	if (document.progs.totalInfo.value==1){
	     if (document.progs.infoTxt[0].selected){  	
	    	  document.progs.codInfoEliminar.value=document.progs.infoTxt.value;	
	    	  seleccionado=1;
	     }
	}else{
	   for (i=0;i<document.progs.totalInfo.value;i++){		
	     if (document.progs.infoTxt[i].selected){      		
	    	  document.progs.codInfoEliminar[j].value=document.progs.infoTxt[i].value;	    	  
		  j++;	
		  seleccionado=1;
	     }
	   }
	}
	if (seleccionado==0){
		alert("Debe seleccionar la información a eliminar");	
	}else{
		document.progs.submit();
	}
}
function eliminar_doc_prog_europa(){
	var i=0;
	var j=0;
	var seleccionado=0;
	document.progs.accion.value=7;
	if (document.progs.totalDocs.value==1){
	     if (document.progs.docsTxt[0].selected){  	
	    	  document.progs.codDocEliminar.value=document.progs.docsTxt.value;	
	    	  seleccionado=1;
	     }
	}else{
	   for (i=0;i<document.progs.totalDocs.value;i++){		
	     if (document.progs.docsTxt[i].selected){      		
	    	  document.progs.codDocEliminar[j].value=document.progs.docsTxt[i].value;	    	  
		  j++;	
		  seleccionado=1;
	     }
	   }
	}
	if (seleccionado==0){
		alert("Debe seleccionar algún documento");	
	}else{
		document.progs.submit();
	}
}

//*************************************** GESTIÓN FAQS PROY EUROPA ******************************************

function gestion_faqs_europa(){
	 open("gestionfaqseuropa.pl","gestionfaqseuropa","toolbar=no,menubar=no,width=640,height=480");	
}

function anyadir_faq_europa(f,caja,valor){
	if(eval(f+".pregunta.value")==""){
		alert("La pregunta no es correcta!");
		eval(f+".pregunta.focus()")
	}
	else if(eval(f+".respuesta.value")==""){
		alert("La respuesta no es correcta!");
		eval(f+".respuesta.focus()")
	}
	else if(aparece_apost(eval(f+".pregunta.value"))){
		alert("No puede aparecer el carcater ' en la pregunta!");
		eval(f+".pregunta.focus()")
	}
	else if(aparece_apost(eval(f+".respuesta.value"))){
		alert("No puede aparecer el carcater ' en la respuesta!");
		eval(f+".respuesta.focus()")
	}
	else{
		submit_form(f,caja,valor);
	}
        return true;
}

function eliminar_faq_europa(f,caja,valor){
     
	if(eval(f+".faq.selectedIndex")>=0){
		respuesta=confirm("Esta a punto de eliminar una pregunta frecuente. Esta seguro?");
		if(respuesta==true)
       			submit_form(f,caja,valor);
	}
	else 
		alert("No has elegido ninguna pregunta!");
	return true;
}

function modificar_faq_europa(f,caja,valor){
	if(eval(f+".faq.selectedIndex")>=0)
                submit_form(f,caja,valor);
        else
                alert("No has elegido ninguna pregunta!");
        return true;
}

//*************************************** GESTIÓN CONVOCATORIAS PROY EUROPA ******************************************

function gestion_convocatorias_europa(){
	 open("gestionconveuropa.pl","gestionvoneuropa","toolbar=no,menubar=no,width=640,height=480");	
}

function anyadir_conv_europa(f,caja,valor){
	if(eval(f+".convocatoria.value")==""){
		alert("La convocatoria no es correcta!");
		eval(f+".convocatoria.focus()")
	}
	else if(aparece_apost(eval(f+".convocatoria.value"))){
		alert("No puede aparecer el carcater ' en la descripción!");
		eval(f+".convocatoria.focus()")
	}
	else{
		submit_form(f,caja,valor);
	}
        return true;
}

function eliminar_conv_europa(f,caja,valor){
     
	if(eval(f+".conv.selectedIndex")>=0){
		respuesta=confirm("Esta a punto de eliminar una convocatoria. Esta seguro?");
		if(respuesta==true)
       			submit_form(f,caja,valor);
	}
	else 
		alert("No has elegido ninguna convocatoria!");
	return true;
}

function modificar_conv_europa(f,caja,valor){
	if(eval(f+".conv.selectedIndex")>=0)
                submit_form(f,caja,valor);
        else
                alert("No has elegido ninguna convocatoria!");
        return true;
}

//*************************************** GESTIÓN OBJETIVOS 3 CICLO ******************************************

function gestion_obj_3ciclo(programa){
	 open("gestionobj3ciclo.pl?programa="+programa,"gestionobj3ciclo","toolbar=no,menubar=no,width=640,height=480");	
}

function anyadir_obj_3ciclo(f,caja,valor){
	if(eval(f+".desc.value")==""){
		alert("La descripción del objetivo no es correcta!");
		eval(f+".desc.focus()")
	}
	else if(aparece_apost(eval(f+".desc.value"))){
		alert("No puede aparecer el carcater ' en la descripción!");
		eval(f+".desc.focus()")
	}
	else{
		submit_form(f,caja,valor);
	}
        return true;
}

function eliminar_obj_3ciclo(f,caja,valor){
     
	if(eval(f+".obj.selectedIndex")>=0){
		respuesta=confirm("Esta a punto de eliminar un objetivo. Esta seguro?");
		if(respuesta==true)
       			submit_form(f,caja,valor);
	}
	else 
		alert("No has elegido ningun objetivo!");
	return true;
}

function modificar_obj_3ciclo(f,caja,valor){
	if(eval(f+".obj.selectedIndex")>=0)
                submit_form(f,caja,valor);
        else
                alert("No has elegido ningun objetivo!");
        return true;
}

//*************************************** GESTIÓN ASG 3 CICLO ******************************************

function gestion_asg_3ciclo(programa){
	 open("gestionasg3ciclo.pl?programa="+programa,"gestionasg3ciclo","toolbar=no,menubar=no,width=640,height=500");	
}

function anyadir_asg_3ciclo(f,caja,valor){
	if(eval(f+".titulo.value")==""){
		alert("El titulo del objetivo no es correcto!");
		eval(f+".titulo.focus()")
	}
	else if(aparece_apost(eval(f+".titulo.value"))){
		alert("No puede aparecer el carcater ' en el titulo!");
		eval(f+".titulo.focus()")
	}
	else{
		submit_form(f,caja,valor);
	}
        return true;
}

function eliminar_asg_3ciclo(f,caja,valor){
     
	if(eval(f+".asg.selectedIndex")>=0){
		respuesta=confirm("Esta a punto de eliminar una asignatura. Esta seguro?");
		if(respuesta==true)
       			submit_form(f,caja,valor);
	}
	else 
		alert("No has elegido ninguna asignatura!");
	return true;
}

function modificar_asg_3ciclo(f,caja,valor){
	if(eval(f+".asg.selectedIndex")>=0)
                submit_form(f,caja,valor);
        else
                alert("No has elegido ninguna asignatura!");
        return true;
}

function estat_anyactual(){
	if(document.asg.bianual.checked==true){
		document.asg.anyactual.disabled=false;
		document.asg.labelanyactual.disabled=false;
	}
	else{
		document.asg.anyactual.disabled=true;
		document.asg.labelanyactual.disabled=true;
	}
}

//*************************************** GESTIÓN PROFES 3 CICLO ******************************************
function ilumina(boton){
	switch(boton){
		case 0:	document.listprof.el_prof.disabled=false;
			break;
		case 1:	document.listprof.anyadir_prof.disabled=false;
			break;
		case 2:	document.listprof.el_inv.disabled=false;
			break;
		case 3:	document.listprof.anyadir_inv.disabled=false;
			document.listprof.eliminar.disabled=false;
			break;
	}
	
	return true;
}

function realiza_accion(accion){
	document.listprof.accion.value=accion;
	document.listprof.submit();
}

//*************************************** GESTIÓN ACTAS ******************************************

function nuevo_dir_actas(){
	document.frmactas.accion.value=1;
	document.frmactas.submit();
}

function eliminar_dir_actas(){
	var i=0;
	var j=0;
	var seleccionado=0;
	document.frmactas.accion.value=8;
	if (document.frmactas.totalDir.value==1){
	     if (document.frmactas.dirTxt[0].selected){  	
	    	  document.frmactas.codDirEliminar.value=document.frmactas.dirTxt.value;	
	    	  seleccionado=1;	    	  
	     }
	}else{
	   for (i=0;i<document.frmactas.totalDir.value;i++){		
	     if (document.frmactas.dirTxt[i].selected){     		
	    	  document.frmactas.codDirEliminar[j].value=document.frmactas.dirTxt[i].value;	    	  
		  j++;	
	    	  seleccionado=1;			  
	     }
	   }
	}
	if (seleccionado==0){
		alert("Debe seleccionar primero una carpeta");
	}else{
		document.frmactas.submit();
	}
}

function crear_dir_actas(){
	document.frmactas.accion.value=7;
	document.frmactas.submit();
}

function abrir_dir_actas(){
	var i=0;
	var seleccionado=0;
	document.frmactas.accion.value=0;	
	if (document.frmactas.totalDir.value==1){
	     if (document.frmactas.dirTxt[0].selected){  
	    	  document.frmactas.directorio.value=document.frmactas.dirTxt.value;	
	    	  seleccionado=1;
	     }
	}else{
	   for (i=0;i<document.frmactas.totalDir.value;i++){		
	     if (document.frmactas.dirTxt[i].selected){      			     	
	    	  document.frmactas.directorio.value=document.frmactas.dirTxt[i].value;	    	  
	    	  seleccionado=1;	    	  
	     }
	   }
	}
	if (seleccionado==0){
		alert("Debe seleccionar una carpeta");
	}else{
		var j=eval(document.frmactas.nivel.value);	
	
		if (j==0){
			if (document.frmactas.totalDir.value==1){				
			     if (document.frmactas.dirTxt[0].selected){  
			    	  document.frmactas.arbolDir.value=document.frmactas.dirTxt.value;	
			     }
			}else{
			   for (i=0;i<document.frmactas.totalDir.value;i++){		
			     if (document.frmactas.dirTxt[i].selected){    			     	
			    	  document.frmactas.arbolDir.value=document.frmactas.dirTxt[i].value;	    	  
	    	  
			     }
			   }
			}
		}else{
			j=j-1;
		   for (i=0;i<j;i++){	
			if (document.frmactas.totalDir.value==1){
			     if (document.frmactas.dirTxt[0].selected){  
			    	  document.frmactas.arbolDir[j].value=document.frmactas.dirTxt.value;	;
			     }
			}else{
			   for (i=0;i<document.frmactas.totalDir.value;i++){		
			     if (document.frmactas.dirTxt[i].selected){      			     	
			    	  document.frmactas.arbolDir[j].value=document.frmactas.dirTxt[i].value;	    	  	    	  
			     }
			   }
			}
		   }
		}
		document.frmactas.nivel.value=j+1;	
		document.frmactas.submit();	
	}	

}

function cerrar_dir_actas(){
	var i=0;
	var nivel=eval(document.frmactas.nivel.value);
	document.frmactas.accion.value=0;
	if (nivel>0){	
	  //for (i=0;i<(nivel);i++){
		document.frmactas.arbolDir[nivel-1].value="";
	  //}
	}		
	document.frmactas.nivel.value=nivel-1;	
	document.frmactas.submit();		
}



function nuevo_doc_actas(){
	document.frmactas.accion.value=5;
	document.frmactas.submit();
}

function crear_doc_actas(){
	document.frmactas.accion.value=9;
	document.frmactas.submit();
}

function eliminar_doc_actas(){
	var i=0;
	var j=0;
	var seleccionado=0;
	document.frmactas.accion.value=10;
	if (document.frmactas.totalDocs.value==1){
	     if (document.frmactas.docsTxt[0].selected){  	
	    	  document.frmactas.codDocEliminar.value=document.frmactas.docsTxt.value;	
	    	  seleccionado=1;
	     }
	}else{
	   for (i=0;i<document.frmactas.totalDocs.value;i++){		
	     if (document.frmactas.docsTxt[i].selected){      		
	    	  document.frmactas.codDocEliminar[j].value=document.frmactas.docsTxt[i].value;	    	  
		  j++;	
	    	  seleccionado=1;		  
	     }
	   }
	}
	
	if (seleccionado==0){
		alert("Debe seleccionar primero una carpeta");
	}else{
		document.frmactas.totalDocSel.value=j;	
		document.frmactas.submit();
	}	
}
function mover_doc_actas(){
	var i=0;
	var j=0;
	var k=0;
	var seleccionado=0;
	document.frmactas.accion.value=11;
	if (document.frmactas.totalDir.value==1){
	     if (document.frmactas.dirTxt[0].selected){  
	    	  document.frmactas.directorio.value=document.frmactas.dirTxt.value;	
	    	  seleccionado=1;
	     }
	}else{
	   for (i=0;i<document.frmactas.totalDir.value;i++){		
	     if (document.frmactas.dirTxt[i].selected){      			     	
	    	  document.frmactas.directorio.value=document.frmactas.dirTxt[i].value;	    	  
	    	  seleccionado=1;	    	  
	     }
	   }
	}
	if (seleccionado==0){
		alert("Debe seleccionar la carpeta destino");
	}else{	
		var j=eval(document.frmactas.nivel.value);		
		if (j==0){
			if (document.frmactas.totalDir.value==1){				
			     if (document.frmactas.dirTxt[0].selected){  
			    	  document.frmactas.arbolDir.value=document.frmactas.dirTxt.value;	
			     }
			}else{
			   for (i=0;i<document.frmactas.totalDir.value;i++){		
			     if (document.frmactas.dirTxt[i].selected){    			     	
			    	  document.frmactas.arbolDir.value=document.frmactas.dirTxt[i].value;	    	  
	    	  
			     }
			   }
			}
		}else{
		   for (i=0;i<j;i++){	
			if (document.frmactas.totalDir.value==1){
			     if (document.frmactas.dirTxt[0].selected){  
			    	  document.frmactas.arbolDir[j].value=document.frmactas.dirTxt.value;	;
			     }
			}else{
			   for (i=0;i<document.frmactas.totalDir.value;i++){		
			     if (document.frmactas.dirTxt[i].selected){      			     	
			    	  document.frmactas.arbolDir[j].value=document.frmactas.dirTxt[i].value;	    	  	    	  
			     }
			   }
			}
		   }
		}	
	
		if (document.frmactas.totalDocs.value==1){
		     if (document.frmactas.docsTxt[0].selected){  	
		    	  document.frmactas.codDocMover.value=document.frmactas.docsTxt.value;	
		    	  k=1;
		    	  seleccionado=1;
		     }
		}else{
		   for (i=0;i<document.frmactas.totalDocs.value;i++){		
		     if (document.frmactas.docsTxt[i].selected){      		
		    	  document.frmactas.codDocMover[k].value=document.frmactas.docsTxt[i].value;	    	  
			  k++;	
		    	  seleccionado=1;		  
		     }
		   }
		}
		
		document.frmactas.nivel.value=j+1;		
		document.frmactas.totalDocSel.value=k;
		document.frmactas.submit();
	}	
}

//-----------------OFICINA GESTORA------------------------------------------------

function abrir_oficina_gestora(){
	 open("oficinagestora.pl","GestionViajes","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");	
}


function login_oficina_gestora(accion){
  var err=0;  

  if (((document.datos.nip[document.datos.nip.selectedIndex]).value==0) && (accion=="buscar") && ((document.datos.codigo.value).length==0)){
  	alert("Introduzca el código de una Oficina Gestora o el login de un profesor");
  	err=1;
  }	
  if (err==0){
	document.datos.accion.value=accion;
	document.datos.submit();
  }
	
}

function verificaFormOficinaGestora(accion){
  var err=0;
  if ((document.datos.codigo.value).length==0){
  	alert("Debe introducir el código de la Oficina Gestora");
  	err=1;
  }else{
  	if ((document.datos.nip[document.datos.nip.selectedIndex]).value==0){  
  		alert("Debe seleccionar un profesor");
  		err=1;
  	}else{
	  if ((document.datos.codigo.value).length>10){
	  	alert("El código de la Oficina Gestora no puede contener más de 10 caracteres");
	  	err=1;
	  }  	
  	}
  }
  if ((document.datos.codigo.value).length==0){
  	alert("Debe introducir el código de la Oficina Gestora");
  	err=1;
  }  
  
  
  if (err==0){
  	document.datos.accion.value=accion; 
  	document.datos.submit();
  }
  
 }
  

 //-----------------DIETAS------------------------------------------------

function abrir_dietas(){
	 open("dietas.pl","GestionViajes","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");	
}
function seleccionar_pais(accion){
  var err=0;  
  
  if ((((document.datos.cod_pais[document.datos.cod_pais.selectedIndex]).value)==0) && (accion=="buscar")){
  	alert("Seleccione un pais");
  	err=1;
  }
  if (err==0){
	document.datos.accion.value=accion;
	document.datos.submit();
  }
	
} 

//-----------------CENTRO DE COSTE------------------------------------------------

function abrir_centro_costes(){
	 open("centrocostes.pl","GestionViajes","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");	
}


function login_centro_coste(accion){
  var err=0;  
  
  if (((document.datos.nip[document.datos.nip.selectedIndex]).value==0) && (accion=="buscar") && ((document.datos.codigo.value).length==0)){
  	alert("Introduzca el código de un Centro de Coste o de una Oficina Gestora");
  	err=1;
  }
  if (err==0){
	document.datos.accion.value=accion;
	document.datos.submit();
  }
	
}

function verificaFormCentroCostes(accion){
  var err=0;

  if ((document.datos.ccc.value).length==0){
  	alert("Debe introducir el código del centro de costes");
  	err=1;
  }else{
	  if ((document.datos.ccc.value).length>15){
	  	alert("El código del Centro de Coste no puede contener más de 15 caracteres");
	  	err=1;
	  }  	
  }
   
  if (document.datos.categoria.value==0){
  	alert("Debe seleccionar la categoría del centro de costes");
  	err=1;
  }
  if ((document.datos.descripcion.value).length>100){
  	alert("Introduzca una descripción que no supere los 100 caracteres");
  	err=1;
  }  
  
  if (accion=="grabar"){
	  if ((document.datos.nip[document.datos.nip.selectedIndex]).value==0){
	  	alert("Debe seleccionar el profesor al que se le va a asociar el centro de coste");
	  	err=1;
	  }    	
  }
 
  if (err==0){
  	document.datos.accion.value=accion; 
  	document.datos.submit();
  }
  
 }

//---------Mantenimiento Sede DSIC---------------------------------------
function VerificaFormIncidencias(){
  var err=0;
	if ((document.datos.descripcion.value).length==0){
		alert("Debe introducir la descripción");
		err=1;
	}else{
		if ((document.datos.descripcion.value).length>500){
			alert("La despcripción no debe superar los 500 caractares");
			err=1;
		}
	}
	if (err==0){
  		document.datos.submit();
  	}
}
//-----------------------------------------------------------------------
//---------FUNCIONES PARA GENERAR EL MENU DE LA IZQUIERDA----------------
function outTD(celda,color){
	celda.style.cursor='default';
	celda.bgColor=color;
	MM_swapImgRestore();
}

function overTD(celda,color,imagen,pre){
	celda.style.cursor='hand';
	celda.bgColor=color;
	if(imagen!="")	MM_swapImage(imagen,'',pre+'cuad2.gif');
}	

function clickTD(celda){
	celda.children.tags('A')[0].click();
}
//------------------------BIBLIOTECA DIGITAL - TESIS---------------------------------

function verificaFormEntrarTesis(){
  var err=0;

  if (document.entrarTesis.programa_doctorado.selectedIndex==0){
	alert("Debe seleccionar un programa de Doctorado");  
	err=1;
  }
  if ((document.entrarTesis.titulo.value).length==0 || (document.entrarTesis.titulo.value).length>600){
	alert("Debe introducir el título de la tesis como máximo con 600 caracteres");  
	err=1;
  }  
  if ((document.entrarTesis.autor_plantilla[document.entrarTesis.autor_plantilla.selectedIndex]).value=='NO PERTENECE' && (document.entrarTesis.autor.value).length==0){
	alert("Debe introducir el autor de la tesis");  
	err=1;  	
  }
	if ((document.entrarTesis.autor_plantilla[document.entrarTesis.autor_plantilla.selectedIndex]).value=='NO PERTENECE' && (document.entrarTesis.email_autor.value).length==0){
	alert("Debe introducir el email del autor de la tesis");  
	err=1;  	
  }
  if ((document.entrarTesis.autor.value).length>250){
	alert("Debe introducir el autor de la tesis como máximo con 250 caracteres");  
	err=1;
  }
  if ((document.entrarTesis.director.value).length==0 || (document.entrarTesis.director.value).length>250){
	alert("Debe introducir el(los) director(es) de la tesis como máximo con 250 caracteres");   
	err=1;
  }
	
	if ((document.entrarTesis.director.value).length==0 ){
	alert("Debe introducir el email del director de la tesis");   
	err=1;
  }
 // if ((document.entrarTesis.resumenC.value).length==0){
	//alert("Como mínimo debe introducir el resumen de la tesis en versión castellana");  
//	err=1;
 // }
  if ((document.entrarTesis.archivo.value).length==0){
	alert("Debe introducir el archivo de la tesis");  
	err=1;
  }
	if ((document.entrarTesis.curriculo.value).length==0){
	alert("Debe introducir el currículum del autor de la tesis");  
	err=1;
  }
  res=CheckearNombreFichero('entrarTesis','archivo');
  if (res!=-1){
	err=1;
  }  
	
	res=CheckearNombreFichero('entrarTesis','curriculo');
  if (res!=-1){
	err=1;
  }  
  if (err==0){
  	document.entrarTesis.submit();
  }
}

function verificaFormModificarTesis(){
  var err=0;
  
  if ((document.modificarTesis.titulo.value).length==0 || (document.modificarTesis.titulo.value).length>600){
	alert("Debe introducir el título de la tesis como máximo con 600 caracteres");  
	err=1;
  }  
  if ((document.modificarTesis.autor_plantilla[document.modificarTesis.autor_plantilla.selectedIndex]).value=='NO PERTENECE' && (document.modificarTesis.autor.value).length==0){
	alert("Debe introducir el autor de la tesis");  
	err=1;  	
  }
	if ((document.modificarTesis.autor_plantilla[document.modificarTesis.autor_plantilla.selectedIndex]).value=='NO PERTENECE' && (document.modificarTesis.email_autor.value).length==0){
	alert("Debe introducir el email del autor de la tesis");  
	err=1;  	
  }
  if ((document.modificarTesis.autor.value).length>250){
	alert("Debe introducir el autor de la tesis como máximo con 250 caracteres");  
	err=1;
  }  
  if ((document.modificarTesis.director.value).length==0 || (document.modificarTesis.director.value).length>250){
	alert("Debe introducir el(los) director(es) de la tesis como máximo con 250 caracteres");   
	err=1;
  }
	if ((document.modificarTesis.email_director.value).length==0){
	alert("Debe introducir el email del director de la tesis");   
	err=1;
  }
  if ((document.modificarTesis.resumenC.value).length==0){
	alert("Como mínimo debe introducir el resumen de la tesis en versión castellana");  
	err=1;
  }
  res=CheckearNombreFichero('modificarTesis','archivo');
  if (res!=-1){
	err=1;
  }  
  if (err==0){
  	document.modificarTesis.submit();
  }
}



function verificaFormValidarTesis(){
  var err=0;
  
  if ((document.validaTesis.registro.value).length==0 || (document.validaTesis.registro.value).length>20){  
	alert("Debe introducirse el número de registro como máximo con 20 caracteres");  
	err=1;
  }
  if ((document.validaTesis.calificacion.value).length==0 || (document.validaTesis.calificacion.value).length>10){  
	alert("Debe introducirse la nota como máximo con 10 caracteres");    
	err=1;
  }  

  if ((document.validaTesis.fecha_lectura.value).length>0){
	res=esFechaOk(document.validaTesis.fecha_lectura.value);
	if (res>0){
		alert("La fecha es incorrecta");
		document.validaTesis.fecha_lectura.focus();		
		err=1;
	}
  }else{
	alert("Debe introducirse la fecha");  
	err=1;
  }
  
  if (err==0){
  	document.validaTesis.submit();
  }
}

function verificaFormCalendarioTesis(){
  var err=0;
  
 if ((document.calendarioTesis.fecha_presentacion.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_presentacion.value);
	if (res>0){
		alert("La fecha de presentación es incorrecta");
		document.calendarioTesis.fecha_presentacion.focus();		
		err=1;
	}
  }

  
 if ((document.calendarioTesis.fecha_present_rectorado.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_present_rectorado.value);
	if (res>0){
		alert("La fecha de presentación en rectorado es incorrecta");
		document.calendarioTesis.fecha_present_rectorado.focus();		
		err=1;
	}
  }

 if ((document.calendarioTesis.fecha_presen_trib.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_presen_trib.value);
	if (res>0){
		alert("La fecha de presentación tribunal en secretaría es incorrecta");
		document.calendarioTesis.fecha_presen_trib.focus();		
		err=1;
	}
  }
  
 if ((document.calendarioTesis.fecha_envio_trib_cct.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_envio_trib_cct.value);
	if (res>0){
		alert("La fecha de envío del tribunal a la CCT es incorrecta");
		document.calendarioTesis.fecha_envio_trib_cct.focus();		
		err=1;
	}
  }
  
 if ((document.calendarioTesis.fecha_aprob_trib_cct.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_aprob_trib_cct.value);
	if (res>0){
		alert("La fecha de aprobación del tribunal por la CCT es incorrecta");
		document.calendarioTesis.fecha_aprob_trib_cct.focus();		
		err=1;
	}
  }
  
 if ((document.calendarioTesis.fecha_presen_trib_rect.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_presen_trib_rect.value);
	if (res>0){
		alert("La fecha de presentación tribunal en rectorado es incorrecta");
		document.calendarioTesis.fecha_presen_trib_rect.focus();		
		err=1;
	}
  }
  
 if ((document.calendarioTesis.fecha_adm_tram.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_adm_tram.value);
	if (res>0){
		alert("La fecha de admisión a trámite es incorrecta");
		document.calendarioTesis.fecha_adm_tram.focus();		
		err=1;
	}
  }  
  
 if ((document.calendarioTesis.fecha_desig_trib.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_desig_trib.value);
	if (res>0){
		alert("La fecha de designación del tribunal es incorrecta");
		document.calendarioTesis.fecha_desig_trib.focus();		
		err=1;
	}
  }  
  
 if ((document.calendarioTesis.fecha_const_trib.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_const_trib.value);
	if (res>0){
		alert("La fecha de constitución del tribunal es incorrecta");
		document.calendarioTesis.fecha_const_trib.focus();		
		err=1;
	}
  }  
  
 if ((document.calendarioTesis.fecha_aprob_lectura.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_aprob_lectura.value);
	if (res>0){
		alert("La fecha de aprobación de lectura es incorrecta");
		document.calendarioTesis.fecha_aprob_lectura.focus();		
		err=1;
	}
  }  
  
if ((document.calendarioTesis.fecha_lectura.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_lectura.value);
	if (res>0){
		alert("La fecha de lectura es incorrecta");
		document.calendarioTesis.fecha_lectura.focus();		
		err=1;
	}
  } 
  
  if (err==0){
  	document.calendarioTesis.submit();
  }
}


function verificaFormCalendarioBorradorTesis(){
  var err=0;
  
 if ((document.calendarioTesis.fecha_bor_presentacion.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_bor_presentacion.value);
	if (res>0){
		alert("La fecha de presentación del borrador es incorrecta");
		document.calendarioTesis.fecha_bor_presentacion.focus();		
		err=1;
	}
  }

 if ((document.calendarioTesis.fecha_bor_6_eval.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_bor_6_eval.value);
	if (res>0){
		alert("la fecha de presentación de la propuesta de los 6 evaluadores es incorrecta");
		document.calendarioTesis.fecha_bor_6_eval.focus();		
		err=1;
	}
  }
  
 if ((document.calendarioTesis.fecha_bor_aprob_eval.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_bor_aprob_eval.value);
	if (res>0){
		alert("La fecha de aprobación de los evaluadores por la CTT es incorrecta");
		document.calendarioTesis.fecha_bor_aprob_eval.focus();		
		err=1;
	}
  }

 if ((document.calendarioTesis.fecha_bor_rectorado.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_bor_rectorado.value);
	if (res>0){
		alert("La fecha de envio de la propuesta a rectorado es incorrecta");
		document.calendarioTesis.fecha_bor_rectorado.focus();		
		err=1;
	}
  }
  
 if ((document.calendarioTesis.fecha_bor_3_eval.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_bor_3_eval.value);
	if (res>0){
		alert("La fecha de designación de los 3 evaluadores es incorrecta");
		document.calendarioTesis.fecha_bor_3_eval.focus();		
		err=1;
	}
  }
  
 if ((document.calendarioTesis.fecha_bor_documentacion.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_bor_documentacion.value);
	if (res>0){
		alert("La fecha de envio de la documentación a los 3 informadores es incorrecta");
		document.calendarioTesis.fecha_bor_documentacion.focus();		
		err=1;
	}
  }
  
  
 if ((document.calendarioTesis.fecha_bor_informes.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_bor_informes.value);
	if (res>0){
		alert("La fecha en que finaliza el plazo de repeción de informes es incorrecta");
		document.calendarioTesis.fecha_bor_informes.focus();		
		err=1;
	}
  }  
  
 if ((document.calendarioTesis.fecha_bor_autorizacion.value).length>0){
	res=esFechaOk(document.calendarioTesis.fecha_bor_autorizacion.value);
	if (res>0){
		alert("La fecha de autorización para la presentación formal de la tesis es incorrecta");
		document.calendarioTesis.fecha_bor_autorizacion.focus();		
		err=1;
	}
  }  
 
  if (err==0){
  	document.calendarioTesis.submit();
  }
}

//------------------------BIBLIOTECA DIGITAL - TESIS DE MASTER---------------------------------

function verificaFormEntrarTesisMaster(){
  var err=0;

  if (document.entrarTesisMaster.programa_doctorado.selectedIndex==0){
	alert("Debe seleccionar un programa de Master");  
	err=1;
  }
  if ((document.entrarTesisMaster.titulo.value).length==0 || (document.entrarTesisMaster.titulo.value).length>600){
	alert("Debe introducir el título de la tesis como máximo con 600 caracteres");  
	err=1;
  }  
  if ((document.entrarTesisMaster.autor.value).length==0){
	alert("Debe introducir el autor de la tesis");  
	err=1;  	
  }
	if ((document.entrarTesisMaster.email_autor.value).length==0){
	alert("Debe introducir el email del autor de la tesis");  
	err=1;  	
  }
  if ((document.entrarTesisMaster.autor.value).length>250){
	alert("Debe introducir el autor de la tesis como máximo con 250 caracteres");  
	err=1;
  }
  if ((document.entrarTesisMaster.director.value).length==0 || (document.entrarTesisMaster.director.value).length>250){
	alert("Debe introducir el(los) director(es) de la tesis como máximo con 250 caracteres");   
	err=1;
  }
	if ((document.entrarTesisMaster.email_director.value).length==0){
	alert("Debe introducir el email del director de la tesis");  
	err=1;  	
  }

  if ((document.entrarTesisMaster.resumenC.value).length==0){
	alert("Como mínimo debe introducir el resumen de la tesis en versión castellana");  
	err=1;
  }
  if ((document.entrarTesisMaster.archivo.value).length==0){
	alert("Debe introducir el archivo de la tesis");  
	err=1;
  }

  res=CheckearNombreFichero('entrarTesisMaster','archivo');
  if (res!=-1){
	err=1;
  }  

  if (err==0){
  	document.entrarTesisMaster.submit();
  }
}


//------------------------BIBLIOTECA DIGITAL - DOCUMENTACION DOCENTE---------------------
function cargaAsignaturasUnidadDocente(form,valor){
  eval("document."+form+".action='"+valor+"'");	
  eval("document."+form+".submit()");		
}

function verificaFormEntrarDocumentacion(){
  var err=0;

  if ((document.entrarDocumentacion.unidad_docente[document.entrarDocumentacion.unidad_docente.selectedIndex]).value=="not selected"){
	alert("Debe seleccionar una unidad docente");  
	err=1;
  }else{
	  if ((document.entrarDocumentacion.asignatura.value).length==0){
		alert("Debe seleccionar como mínimo una asignatura");  
		err=1;
	  }  
  }

  if ((document.entrarDocumentacion.autor.value).length==0 ){
	alert("Debe seleccionar el(los) autor(es)");  
	err=1;
  }
  if ((document.entrarDocumentacion.titulo.value).length==0 || (document.entrarDocumentacion.titulo.value).length>100){
	alert("Debe introducir el título como máximo con 100 caracteres"); 
	err=1;
  }    
  if ((document.entrarDocumentacion.resumen.value).length==0){
	alert("Debe introducir el resumen");  
	err=1;
  }
  if ((document.entrarDocumentacion.palabras_clave.value).length==0 || (document.entrarDocumentacion.palabras_clave.value).length>100){
	alert("Debe introducir las palabras clave como máximo con 100 caracteres");  
	err=1;
  }  
  if ((document.entrarDocumentacion.archivo.value).length==0){
	alert("Debe introducir el archivo");  
	err=1;
  }
  res=CheckearNombreFichero('entrarDocumentacion','archivo');
  if (res!=-1){
	err=1;
  }  
  if (err==0){
  	document.entrarDocumentacion.action="anyadir_documentacion.pl";		  	
  	document.entrarDocumentacion.submit();
  }
}

function verificaFormModificarDocumentacion(){
  var err=0;
  if ((document.modificarDocumentacion.unidad_docente[document.modificarDocumentacion.unidad_docente.selectedIndex]).value=="not selected"){
	alert("Debe seleccionar una unidad docente");  
	err=1;
  }
  if ((document.modificarDocumentacion.asignatura.value).length==0){
	alert("Debe seleccionar como mínimo una asignatura");  
	err=1;
  }
  if ((document.modificarDocumentacion.autor.value).length==0){
	alert("Debe seleccionar el(los) autor(es)");  
	err=1;
  }
  if ((document.modificarDocumentacion.titulo.value).length==0 || (document.modificarDocumentacion.titulo.value).length>600){
	alert("Debe introducir el título como máximo con 600 caracteres");  
	err=1;
  }    
  if ((document.modificarDocumentacion.resumen.value).length==0){
	alert("Debe introducir el resumen de la documentación");  
	err=1;
  }
  if ((document.modificarDocumentacion.palabras_clave.value).length==0 || (document.modificarDocumentacion.palabras_clave.value).length>100){
	alert("Debe introducir las palabras clave como máximo con 100 caracteres");   
	err=1;
  }  
  res=CheckearNombreFichero('modificarDocumentacion','archivo');
  if (res!=-1){
	err=1;
  }    
  if (err==0){
  	document.modificarDocumentacion.action="actualizar_documentacion.pl";		  	  	
  	document.modificarDocumentacion.submit();
  }
}
//------------------------BIBLIOTECA DIGITAL - INFORMES---------------------------------

function verificaFormEntrarInformes(){
  var err=0;

  if (document.entrarInformes.grupo_inv.value=='valor0'){
	alert("Debe seleccionar un grupo de investigación");  
	err=1;
  }
  if ((document.entrarInformes.autor.value).length==0){
	alert("Debe introducir el autor/es del informe");  
	err=1;
  }
  if ((document.entrarInformes.titulo.value).length==0 || (document.entrarInformes.titulo.value).length>600){
	alert("Debe introducir el título del informe como máximo con 600 caracteres");   
	err=1;
  }
  if ((document.entrarInformes.resumen.value).length==0){
	alert("Debe introducir el resumen del informe");  
	err=1;
  }
  if ((document.entrarInformes.palabras_clave.value).length==0 || (document.entrarInformes.palabras_clave.value).length>100){
	alert("Debe introducir las palabras clave del informe como máximo con 100 caracteres");   
	err=1;
  }
  if ((document.entrarInformes.archivo.value).length==0){
	alert("Debe introducir el archivo del informe");  
	err=1;
  }
  res=CheckearNombreFichero('entrarInformes','archivo');
  if (res!=-1){
	err=1;
  }  
  if (err==0){
  	document.entrarInformes.submit();
  }
}

function verificaFormModificarInformes(){
  var err=0;

  if ((document.modificarInformes.autor.value).length==0){
	alert("Debe introducir el autor del informe");  
	err=1;
  }
  if ((document.modificarInformes.titulo.value).length==0 || (document.modificarInformes.titulo.value).length>600){
	alert("Debe introducir el título del informe como máximo con 600 caracteres");   
	err=1;
  }
  if ((document.modificarInformes.resumen.value).length==0){
	alert("Debe introducir el resumen del informe");  
	err=1;
  }
  if ((document.modificarInformes.palabras_clave.value).length==0 || (document.modificarInformes.palabras_clave.value).length>100){
	alert("Debe introducir las palabras clave del informe como máximo con 100 caracteres");   
	err=1;
  }  
  res=CheckearNombreFichero('modificarInformes','archivo');
  if (res!=-1){
	err=1;
  }    
  if (err==0){
  	document.modificarInformes.submit();
  }
}

//------------------------ BIBLIOTECA DSIC - INVENTARIO ---------------------------------

function inventario_biblioteca(){
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/inventario/libros_prestados.pl","inventario","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");	
}

function iluminar_botones_inventario_bib(f){
	f.eliminar.disabled=false;
	return true;
}

function operacion_libros_prestados(accion){
	if (accion=="eliminar"){
		document.listado_prestamos.action="eliminar_prestamo.pl";	
	}
	if (accion=="anyadir"){
		document.listado_prestamos.action="libros_no_prestados.pl";
	}
	if (accion=="inventarioCorrecto"){
		document.listado_prestamos.action="inventario_realizado.pl";
	}	
	document.listado_prestamos.submit();

}

function iluminar_botones_inventario_bib(f,boton){
	if (boton==1){
		f.eliminar.disabled=false;
	}
	if (boton==2){
		f.anyadir.disabled=false;		
	}
	return true;
}

function filtrar_busqueda(f){	
	eval(f+".submit()");
	return true;
}



//------------------------ BIBLIOTECA DSIC - INVENTARIO - ACTUALIZACION ESTADO EJEMPLARES (CONSERJERIA) ----------------

function todos_libros(){
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/inventario/todos_los_libros.pl","inventario","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");	
}

function iluminar_botones_todos_libros(f){
	f.perdido.disabled=false;
	f.libre.disabled=false;	
	return true;
}

function actualizar_estado_libros(accion){
	document.todos_libros.accion.value=accion;
	document.todos_libros.submit();

}

//------------------------ BIBLIOTECA DSIC - INVENTARIO - IMPORTAR NUEVAS ADQUISICIONES ----------------

function importar_nuevas_adquisiciones(){
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/inventario/importar_nuevas_adquisiciones.pl","BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=640,height=250");	
}


function verificaImportarNuevasAdquisiciones(){
  var err=0;
  
  if ((document.importarNuevasAdquisiciones.archivo.value).length==0){
	alert("Debe introducir el archivo que contiene las nuevas adquisiciones");  
	err=1;
  }
  res=CheckearNombreFichero('importarNuevasAdquisiciones','archivo');
  if (res!=-1){
	err=1;
  }  
  if (err==0){
  	document.importarNuevasAdquisiciones.accion.value="importar";  	
  	document.importarNuevasAdquisiciones.submit();
  }
	 
}

//------------------------ BIBLIOTECA DSIC - PASAR PRESTAMO ---------------------------------

function mostrar_mis_prestamos(){
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/prestamo/mostrar_mis_prestamos.pl","BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");	
}

function iluminar_botones_pasar_prestamo_bib(){
 if ((document.listado_mis_prestamos.prestamos.selectedIndex>=0) && (document.listado_mis_prestamos.nip.selectedIndex>0)){
	document.listado_mis_prestamos.pasar.disabled=false;
  }
  return true;
}


//------------------------ BIBLIOTECA DSIC - DEVOLUCION DE UN PRESTAMO ----------------

function buscar_prestamos_persona(){
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/prestamo/buscar_prestamos_persona.pl","BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");	
}

function inventario_ejemplares_perdidos(){
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/prestamo/inventario_ejemplares_perdidos.pl","BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");	
}

function verificaBusqueda(){
  var err=0;
  
  if ((document.buscarPrestamosPersona.nip.value).length=='Seleccionar'){
	alert("Debe seleccionar una persona");  
	err=1;
  }
  if (err==0){
  	document.buscarPrestamosPersona.submit();
  }
	 
}

function iluminar_botones_devolver_prestamo_bib(){
 if (document.listado_prestamos.devoluciones.selectedIndex>=0){
	document.listado_prestamos.devolver.disabled=false;
  }
  return true;
}

//------------------------ BIBLIOTECA DSIC - ACEPTAR/RECHAZAR PASO DE PRESTAMOS ----------------

function mostrar_mis_prestamos_pendientes(){
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/prestamo/mostrar_mis_prestamos_pend.pl","BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");	
}

function iluminar_botones_mis_prestamos_pendientes(){
   if (document.listado_mis_prestamos_pend.prestamos.selectedIndex>=0){
 	document.listado_mis_prestamos_pend.aceptar.disabled=false;
 	document.listado_mis_prestamos_pend.rechazar.disabled=false; 	
   }
   return true;
} 

function aceptar_prestamos_pendientes(){
  document.listado_mis_prestamos_pend.action="aceptar_prestamo.pl";  	
  document.listado_mis_prestamos_pend.submit();
}

function rechazar_prestamos_pendientes(){
  document.listado_mis_prestamos_pend.action="rechazar_prestamo.pl";  	
  document.listado_mis_prestamos_pend.submit();
}

//------------------------ BIBLIOTECA DSIC - EFECTUAR UN PRESTAMO ----------------

function efectuar_solicitud(){
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/prestamo/realizar_solicitud.pl","BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");	
}

function buscar_solicitudes_persona(){
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/prestamo/buscar_solicitudes_persona.pl","BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");	
}


function verificaBusquedaSolicitudes(){
  var err=0;
  
  if ((document.buscarSolicitudesPersona.nip.value).length=='Seleccionar'){
	alert("Debe seleccionar una persona");  
	err=1;
  }
  if (err==0){
  	document.buscarSolicitudesPersona.submit();
  }
	 
}

function iluminar_botones_solicitud_prestamo_bib(){
 if (document.listado_solicitudes.solicitudes.selectedIndex>=0){
	document.listado_solicitudes.prestar.disabled=false;
  }
  return true;
}


//------------------------ BIBLIOTECA DSIC - SOLICITAR PRESTAMO ----------------
function buscar_libro()
{
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/prestamo/buscar_libro.pl","BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");	
}

function cataloga_libro()
{
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/prestamo/solicitar_catalogacion_nuevo_libro.pl","BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");	
}

function solicitar_prestamo()
{
  	document.detalle_libro.action="solicitar_prestamo.pl";  	
  	document.detalle_libro.submit();
}

function solicitar_compra()
{
  	document.detalle_libro.action="solicitar_compra.pl";  	
  	document.detalle_libro.submit();
}

function apuntarse_lista_espera()
{
	document.detalle_libro.action="apuntarse_lista_espera.pl";  	
  	document.detalle_libro.submit();
}
 
function iluminar_botones_prestamos_con_espera()
{
	if (document.listado_mis_prestamos_con_espera.prestamos.selectedIndex >= 0) 
 	{
		document.listado_mis_prestamos_con_espera.mostrar_lista.disabled=false;
  	}
  
  	return true;
}

function iluminar_botones_lista_espera()
{
	if (document.lista_espera.personas_en_espera.selectedIndex >= 0) 
 	{
		document.lista_espera.pasar.disabled=false;
  	}
  
  	return true;
}
        
function iluminar_botones_libros_encontrados()
{
 if (document.libros_encontrados.libro_seleccionado.selectedIndex >= 0){
	document.libros_encontrados.continuar.disabled=false;
 }else{
	document.libros_encontrados.continuar.disabled=true; 
 }
 return true;
}

function buscar_libros(){
 var err=0;
 if ((document.buscar_libro.titulo.value == '') && (document.buscar_libro.autor.value == '') && (document.buscar_libro.signatura.value == '') && (document.buscar_libro.seleccion_materia.value==-1)){
	alert ("Debe introducir algún criterio de búsqueda");
	err = 1;
 }
 if (err==0){
  	document.buscar_libro.submit();
  }		
}

function ilumina_botones_mis_prestamos_con_espera(){
 alert("hola");
 if (document.listado_mis_prestamos_con_espera.prestamos_con_espera.selectedIndex >= 0){
	document.listado_mis_prestamos_con_espera.mostrar_lista.disabled=false;
 }else{
	document.listado_mis_prestamos_con_espera.mostrar_lista.disabled=true; 
 }
 return true;	
}

function anyadir_solicitud(){
 var err=0;
 if ((document.solicitud_ejemplar.nip.value == '-1') || (document.solicitud_ejemplar.signatura.value == '-1')){
	alert ("Debe seleccionar el usuario y la signatura");
	err = 1;
 }
 if (err==0){
  	document.solicitud_ejemplar.submit();
	opener.document.location.reload();
  }		
}

function prestar_ejemplar_perdido(){
 var err=0;
 if ((document.solicitud_ejemplar.nip.value == '-1') || (document.solicitud_ejemplar.signatura.value == '-1')){
	alert ("Debe seleccionar el usuario y la signatura");
	err = 1;
 }
 if (err==0){
  	document.solicitud_ejemplar.submit();
  }		
}


// ------------------------ BIBLIOTECA DSIC - APUNTARSE LISTA DE ESPERA ----------------
function mostrar_detalle_lista_espera(codigo)
{
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/prestamo/detalle_lista_espera.pl?signatura="+codigo,"BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=600,height=280");	
}

function mis_prestamos_con_lista_espera(){
	open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/prestamo/mostrar_mis_prestamos_con_espera.pl","BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=600,height=480");	
}


//------------------------ BIBLIOTECA DSIC - SOLICITAR COMPRA NUEVO LIBRO ----------------

function solicitar_compra_nuevo_libro(){
	 document.libros_encontrados.action = "solicitar_compra_nuevo_libro.pl";
	 document.libros_encontrados.submit();
	 //open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/prestamo/solicitar_compra_nuevo_libro.pl","BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=640,height=480");		
}

function solicitar_catalogacion_nuevo_libro(){
	document.detalle_libro.action="solicitar_catalogacion_nuevo_libro.pl";  	
	document.detalle_libro.submit();
}

function confirma_compra(){
	if (!confirm ("Ya existen ejemplares del libro que solicitas.\n¿Necesitas un ejemplar adicional?")){ 
		self.close();
	}
	else {
	  document.detalle_libro.action="solicitar_compra_nuevo_libro.pl";  	
  	  document.detalle_libro.submit();
	}
}

function verifica_datos_solicitar_compra_nuevo_libro(){
 var err=0;
 if (document.datos_libro.titulo.value == ''){
	alert ("Introduzca el título del libro");
	err = 1;
 }
 if (document.datos_libro.autor.value == ''){
	alert ("Introduzca el autor del libro");
	err = 1;
 } 
 if ((document.datos_libro.isbn.value == '') && (document.datos_libro.editorial.value == '')){
	alert ("Introduzca el isbn o la editorial");
	err = 1;
 } 
 if (err==0){
  	document.datos_libro.submit();
  }	
	
}

//------------------------ BIBLIOTECA DSIC - VER MIS PRESTAMOS (DETALLE EJEMPLAR) ----------------
function mostrar_detalle_ejemplar(codigo)
{
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/prestamo/detalle_ejemplar.pl?signatura="+codigo,"BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=600,height=280");	
}

//------------------------ BIBLIOTECA DSIC - COMPRAS  ----------------
function mostrar_detalle_compra(codigo)
{
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/compras/detalle_compra.pl?codigo="+codigo,"BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=600,height=280");	
}

function valida_paso_compra(codigo,compra,nip)
{
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/compras/validar_paso.pl?paso="+codigo+"&compra="+compra+"&nip="+nip,"BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=600,height=280");	
}

function borra_compra(compra)
{
	if (!confirm ("¿Seguro que quieres borrar la compra?")){ 
		self.close();
	}
	else {
	  open("https://www.dsic.upv.es/mapa/espanyol/intranet/biblioteca/compras/borrar_compra.pl?compra="+compra,"BibliotecaDSIC","scrollbars=yes,toolbar=no,menubar=no,width=600,height=280");
	}	 	
}

function paso_incorrecto()
{
	alert("Hay pasos anteriores sin validar.");
}

function cierra_actualiza()
{
	self.close();
	opener.document.location.reload();
}

function imprSelec(nombre)
{
  var ficha = document.getElementById(nombre);
  var ventimp = window.open(' ','popimpr');
  ventimp.document.write( nombre.innerHTML );
  ventimp.document.close();
  ventimp.print( );
  ventimp.close();
} 

//-------------------CONSUMOS TELEFONICOS - IMPORTAR ULTIMOS CONSUMOS
function importar_ultimos_consumos(){
	 open("https://www.dsic.upv.es/mapa/espanyol/intranet/consumoTelefonico/importar_consumos.pl","ConsumosTelefonicos","scrollbars=yes,toolbar=no,menubar=no,width=640,height=250");	
}

function verificaImportarUltimosConsumos(){
  var err=0;
  
  if ((document.importarUltimosConsumos.archivo.value).length==0){
	alert("Debe introducir el archivo que contiene los últimos consumos");  
	err=1;
  }
  res=CheckearNombreFichero('importarUltimosConsumos','archivo');
  if (res!=-1){
	err=1;
  }  
  if (err==0){
  	document.importarUltimosConsumos.accion.value="importar";  	
  	document.importarUltimosConsumos.submit();
  }
	 
}
//-------------------CONSUMOS TELEFONICOS - RESPONSABLE ESPACIOS
function responsable_espacio(espacio){
	 open("responsables_espacio.pl?cod_desp="+espacio,"ConsumosTelefonicos","scrollbars=yes,toolbar=no,menubar=no,width=600,height=250");	
}

//****************************************************
function CheckearNombreFichero(f,c){
	var texto,len_texto,ult_index,len_sub_texto,sub_texto,pos;
	
	texto=eval('document.'+f+'.'+c+'.value');
	len_texto=texto.length;
	ult_index=texto.lastIndexOf("\\");
	len_sub_texto=len_texto-ult_index;
	sub_texto=texto.substr(ult_index,len_sub_texto);

	pos=sub_texto.indexOf(" ");
	if (pos!=-1){
		alert("El nombre del archivo no debe contener espacios!");
	}
	return pos;
}

//-----------------GESTION CONSEJO DEPARTAMENTO -------------------- 

function gestion_comisiones(accion,grupo){
	document.miembrosComision.accion.value=accion;
	document.miembrosComision.grupo.value=grupo;
	document.miembrosComision.submit();
}

//-----------------VALIDACION DESPACHOS -------------------- 

function verificaDespacho(){
        var err=0;
	//if ((document.datos_despacho.desp_new[document.datosComisionSer.cod_pais.selectedIndex]).value==0){
	if (document.datos_despacho.desp_new.value=="valor0" || document.vuelve.ext_new.value=="valor0"){
		alert("Debe seleccionar un despacho y una extensión");
		err=1;
	}
        if ( err == 0 ) {
		document.vuelve.submit();
        }
}
//-----------------ORDENES DE VIAJE -------------------- 

function verificarFormOrdenesViaje(accion,modo){
	var err=0;
	if (document.datosComisionSer.objeto.value.length==0  || document.datosComisionSer.objeto.value.length>100){
		alert("Debe indicar el objeto del viaje. Utilice como máximo 100 caracteres");
		err=1;
	}
	if (document.datosComisionSer.lugar.value.length==0 || document.datosComisionSer.lugar.value.length>100){
		alert("Debe indicar el lugar de destino. Utilice como máximo 100 caracteres");
		err=1;
	}
	if ((document.datosComisionSer.cod_pais[document.datosComisionSer.cod_pais.selectedIndex]).value==0){
		alert("Debe seleccionar un país");
		err=1;
	}
        if ( modo == 1 ) {	
	   if ((document.datosComisionSer.cod_trans[document.datosComisionSer.cod_trans.selectedIndex]).value==0){
		alert("Debe seleccionar un tipo de transporte");
		err=1;
	   }
	   if ((document.datosComisionSer.cod_trans[document.datosComisionSer.cod_trans.selectedIndex]).value==1){
		if ((document.datosComisionSer.provincia[document.datosComisionSer.provincia.selectedIndex]).value==0){
			alert("Debe seleccionar una provincia");
			err=1;
		}		
	   }			
	   res=isNumber(document.datosComisionSer.precio_transporte.value);
	   if (res>0){
		alert("El importe debe ser un dato numérico. Utilice el punto para indicar la coma decimal");
		document.datosComisionSer.precio_transporte.focus();		
		err=1;
	   }	

	   if ((document.datosComisionSer.oficina[document.datosComisionSer.oficina.selectedIndex]).value==0){
		alert("Debe seleccionar una oficina");
		err=1;
	   }else{
		if ((document.datosComisionSer.ccc[document.datosComisionSer.ccc.selectedIndex]).value==0){
			alert("Debe seleccionar un centro de coste");
			err=1;
		}	
	   }	
        }
	if (!comprobar_fechasbien(document.datosComisionSer.f_salida,document.datosComisionSer.h_salida,document.datosComisionSer.f_entrada,document.datosComisionSer.h_entrada)){
		err=1;
	}else{
		if (!ofreceNoches()){
			document.datosComisionSer.num_noches.focus();
			err=1;
		}	
	}
	if ((document.datosComisionSer.cprf_susti[document.datosComisionSer.cprf_susti.selectedIndex]).value==0){
		alert("Debe seleccionar un profesor sustituto");
		err=1;
	}	
	if (err==0){
                if ( modo == 0 ) {
                   with (document.forms[0]) {
                       sincoste.value=1;
                   }
                }
		if (accion == 0){
			document.datosComisionSer.action="anyadir_orden.pl";
		}else{
			document.datosComisionSer.action="actualizar_orden.pl";		
		}
		document.datosComisionSer.submit();
	}				
}

function isNumber(num1) { 
    if ((num1 == "")||(num1 == " ")||(num1 == "  ")||(num1.length==0)) 
     return 1 
    else if ((num1 / 2 >= 0)||(num1 / 2 < 0)) 
     return 0 
    else 
     return 1 
} 

function comprobar_fechasbien (campofecha1,campohora1,campofecha2,campohora2){
	if ( !comprobar_fecha(campofecha1,'Fecha de SALIDA incorrecta')) {
		campofecha1.focus();
		return false;
	}
	if ( !comprobar_hora(campohora1,'Hora de SALIDA incorrecta')){
		campohora1.focus();
		return false;
	}
	if ( !comprobar_fecha(campofecha2,'Fecha de REGRESO incorrecta')){
		campofecha2.focus();
		return false;
	}
	if ( !comprobar_hora(campohora2,'Hora de REGRESO incorrecta')){
		campohora2.focus();
		return false;
	}

	var mifecha1 = new String(campofecha1.value)
	var mifecha2 = new String(campofecha2.value)
	var mihora1 = new String(campohora1.value)
	var mihora2 = new String(campohora2.value)

	var mifecha1s = mifecha1.split('/',3)
	var mifecha2s = mifecha2.split('/',3)
	var mihora1s = mihora1.split(':',2)
	var mihora2s = mihora2.split(':',2)

	var mifecha1d = new Date(Number(mifecha1s[2]),Number(mifecha1s[1]-1),Number(mifecha1s[0]))
	var mifecha2d = new Date(Number(mifecha2s[2]),Number(mifecha2s[1]-1),Number(mifecha2s[0]))

	mifecha1d.setHours(Number(mihora1s[0]))
	mifecha1d.setMinutes(Number(mihora1s[1]))
	mifecha2d.setHours(Number(mihora2s[0]))
	mifecha2d.setMinutes(Number(mihora2s[1]))

	if ((mifecha2d - mifecha1d) <= 0) {
		campofecha2.focus()
		alert('Fecha y hora de REGRESO es anterior a la de SALIDA')
		return false
	}
	return true
}

function comprobar_fecha (mi_item,msg) {
    var  mifecha = new String(mi_item.value);
    var  mifechasplited = mifecha.split("/",3);
    var  mimsg = msg+" (Utilice formato dd/mm/aaaa).";
     i=0;
     while(i<3) {
        if (isNaN(Number(mifechasplited[i]))){
            mi_item.focus();
            alert(mimsg);
            return false;
         }
         i++;
      } 

      any = Number(mifechasplited[2]);

      fechasal = new  Date(any,(Number(mifechasplited[1])-1),Number(mifechasplited[0]));

      if (any<2000) any = any - 1900;
      fechabug =  new Date(2000,1,1);
      if ((fechabug.getYear() == 100) && (any >1999)) {
          any = any - 1900;
      }
      if ((Number(mifechasplited[0]) != fechasal.getDate()) || ((Number(mifechasplited[1])-1) != fechasal.getMonth()) || (any != fechasal.getYear()) ) {                              
          mi_item.focus();
          alert(mimsg);
          return false;
       }
       return true
}

function comprobar_hora (campohora,errmsg){
	errmsg+=".Utilice le formato hh[:mm]"
	if (campohora.value==""){
		campohora.focus()
		alert(errmsg)
		return false
	}else{
		var mihora=new String(campohora.value)
		var mihorasplit = mihora.split(":",2)
		if ((mihorasplit.length > 2) || (mihorasplit.length == 0)) {
			campohora.focus()
			alert(errmsg)
			return false
		}
		if (mihorasplit.length == 2){
		   if (isNaN(Number(mihorasplit[0])) || (Number(mihorasplit[0])>23)){
				campohora.focus()
				alert(errmsg)
				return false
		   }
		   if (mihorasplit[1].length == 0){
			campohora.focus()
			alert(errmsg)
			return false
		   }
		   if (isNaN(Number(mihorasplit[1])) || (Number(mihorasplit[1])>59)){
			campohora.focus()
			alert(errmsg)
			return false
		   }
		} else {
		   if (isNaN(Number(mihora)) || (Number(mihora)>23)){
				campohora.focus()
				alert(errmsg)
				return false
		   }
		   campohora.value=mihora+":00"
		}
	}
	return true
}

// Esta funcion ofrece al usuario un valor de noches de hospedaje segun lo que ha introducido
// como efecto lateral, cada vez que se invoca un alert o confirm se reproduce el evento OnFocus, del cual depende, por
// tanto es necesario un contador para evitar disparos espureos. Por cada confirm o alert -> nuevo onfocus, por lo que
// sumando y restando lo controlamos.
function  ofreceNoches() {
 var numDias;
 var dias;
 with (document.forms[0]) {
    if (comprobar_fechasbien(f_salida,h_salida,f_entrada,h_entrada))  {
   	numDias = calcula_dias(f_salida,f_entrada);
      	if (num_noches.value == "") {
   	     if (confirm("Número de noches de hospedaje: "+numDias+"\n\n¿Es correcto el número de noches de hospedaje propuesto?")){
		num_noches.value = numDias;
		return true;
	     }else{ return false}
	}else { 
		dias = Number(num_noches.value);
		if (isNaN(dias)) {
			alert("Introduzca correctamente el número de noches de hospedaje");
			return false;			
		}else if( dias > numDias) {
			alert("Número de noches de hospedaje mayor que dias de comisión solicitados. Debería solicitar como máximo " +numDias+ " días.");
			return false;
		}else{return true}
	}
    }else{ return false}
 }
}

function  ofreceNochesOLD() {

var numDias
var dias
//Vble. necesaria para evitar un efecto lateral cuando se invoca un alert o un confirm desde un evento onFocus
var controlOnFocus = 0

if (controlOnFocus==0) {
      with (document.forms[0]) {
        if (comprobar_fechasbien(f_salida,f_entrada,h_salida,h_entrada))  {
        	if (num_noches.value == "") {
		  numDias = calcula_dias(f_salida,f_entrada)
	          controlOnFocus++;
			if (confirm("Número de noches de hospedaje: "+numDias+"\n\n¿Es correcto el número de noches de hospedaje propuesto?"))
			 {
				num_noches.value = numDias;
				cod_trans.focus();
		       }
		 	else { controlOnFocus++;
				 alert("Introduzca el número de noches correcto "); 
				}	
	 	}
		else { dias = Number(num_noches.value);
			 if (isNaN(dias)) {
				 controlOnFocus++;
				 alert("Introduzca correctamente el número de noches de hospedaje");
			 }
			 else if( dias > numDias) {
					controlOnFocus++;
					alert("Número de noches de hospedaje mayor que dias de comisión solicitados");
				}
			}
	  }
 	}
}
else controlOnFocus--;
}

// Esta funcion calcula el numero de dias entre dos fechas
function calcula_dias (fechasal,fechareg) {
	
	var fecha1s  = fechasal.value
	var fecha1sp = fecha1s.split('/',3)
	var fecha2s  = fechareg.value
	var fecha2sp = fecha2s.split('/',3)

	
	sale = new Date( Number(fecha1sp[2]), (Number(fecha1sp[1])-1), Number(fecha1sp[0]) )
	entra = new Date( Number(fecha2sp[2]), (Number(fecha2sp[1])-1), Number(fecha2sp[0]) )

	sale.setHours(0);
	sale.setMinutes(0);
	entra.setHours(0);
	entra.setMinutes(0);
	

	return Math.floor(Number((entra-sale)/86400000));
}

//Reserva recursos 
function motivos(){
	open('https://www.dsic.upv.es/mapa/espanyol/intranet/gestionRecursos/motivos/gestionmotivos.pl','GestiónMotivos','toolbar=no,menubar=no,width=640,height=480,scrollbars=YES');	
}
function tipos(){
	open('https://www.dsic.upv.es/mapa/espanyol/intranet/gestionRecursos/tipos/gestiontipos.pl','GestiónTipos','toolbar=no,menubar=no,width=640,height=480,scrollbars=YES');	
}
	
function recursos(){
	open('https://www.dsic.upv.es/mapa/espanyol/intranet/gestionRecursos/recursos/gestionrecursos.pl','GestiónRecursos','toolbar=no,menubar=no,width=640,height=480,scrollbars=YES');	
}

function puntual(){
	open('https://www.dsic.upv.es/mapa/espanyol/intranet/gestionRecursos/puntual/p_seleccionar_tipo.pl','ReservaPuntual','toolbar=no,menubar=no,width=640,height=480,scrollbars=YES');	
}

function infoReservas(){
	open('https://www.dsic.upv.es/mapa/espanyol/intranet/gestionRecursos/adminres/a_seleccionar_tipo.pl','AdministrarReservas','toolbar=no,menubar=no,width=640,height=480,scrollbars=YES');	
}

function reservaPeriodica(){
	open('https://www.dsic.upv.es/mapa/espanyol/intranet/gestionRecursos/periodica/e_seleccionar_tipo.pl','ListarRecursos','toolbar=no,menubar=no,width=640,height=480,scrollbars=YES');	
}

function reservaPeriodicaAdmin(){
	open('https://www.dsic.upv.es/mapa/espanyol/intranet/gestionRecursos/reserva_periodica/e_seleccionar_tipo.pl','ListarRecursos','toolbar=no,menubar=no,width=640,height=480,scrollbars=YES');	
}	

function misReservas(){
	open('https://www.dsic.upv.es/mapa/espanyol/intranet/gestionRecursos/misreservas/m_mostrar_reservas.pl','MisReservas','toolbar=no,menubar=no,width=640,height=480,scrollbars=YES');	
}

function reservasFecha(){
	open('https://www.dsic.upv.es/mapa/espanyol/intranet/gestionRecursos/reserva_dia/seleccionar_tipo_fecha.pl','ReservasFecha','toolbar=no,menubar=no,width=640,height=480,scrollbars=YES');	
}

//Gestion Noticias

function mostrar_detalle_noticia(codigo)
{
	open("https://www.dsic.upv.es/mapa/espanyol/intranet/gestionNoticias/detalle_noticia.pl?codigo=" + codigo,"DetalleNoticia","scrollbars=yes,toolbar=no,menubar=no,width=600,height=300");
}


function verificaFormEntrarNoticias(){
  var err=0;
  
  if (document.entrarNoticia.tipo.value=='congreso'){
	  if (((document.entrarNoticia.profesor.value).length>100) || ((document.entrarNoticia.profesor.value).length == 0)){
		alert("Introduzca el nombre del profesor que va a dar la conferencia como máximo con 100 caracteres");  
		err=1;
	  }  	
	  if (((document.entrarNoticia.lugar.value).length>100) || ((document.entrarNoticia.lugar.value).length == 0)){
		alert("Introduzca el lugar donde se va a realizar la conferencia como máximo con 100 caracteres");  
		err=1;
	  }  	
	  if (!comprobar_fecha(document.entrarNoticia.fecha,'Fecha incorrecta')){
		err=1;
	  }  	  	
	  if (!comprobar_hora(document.entrarNoticia.hora,'Hora incorrecta')){
		err=1;
	  }  	
  }else {
  	if (document.entrarNoticia.tipo.value=='otros'){
	  if (((document.entrarNoticia.titulo.value).length==0) || ((document.entrarNoticia.titulo.value).length > 30)){
		alert("Debe introducir el título de la noticia como máximo con 100 caracteres");  
		err=1;
	  }      
	  if (((document.entrarNoticia.texto.value).length>250) || ((document.entrarNoticia.texto.value).length == 0)){
		alert("Introduzca el texto de la noticia como máximo con 250 caracteres");  
		err=1;
	  }  	
	}
  }
  if (((document.entrarNoticia.fecha_caducidad.value).length==0) || (!comprobar_fecha(document.entrarNoticia.fecha_caducidad,'Fecha de caducidad incorrecta'))){
	err=1;
  }      
  if (err==0){
  	document.entrarNoticia.submit();
  }
}

function verificaFormModificarNoticia(){
  var err=0;

  if (document.modNoticia.tipo.value=='congreso'){
	  if (((document.modNoticia.profesor.value).length>100) || ((document.modNoticia.profesor.value).length == 0)){
		alert("Introduzca el nombre del profesor que va a dar la conferencia como máximo con 100 caracteres");  
		err=1;
	  }  	
	  if (((document.modNoticia.lugar.value).length>100) || ((document.modNoticia.lugar.value).length == 0)){
		alert("Introduzca el lugar donde se va a realizar la conferencia como máximo con 100 caracteres");  
		err=1;
	  }  	
	  if (!comprobar_fecha(document.modNoticia.fecha,'Fecha incorrecta')){
		err=1;
	  }  	  	
	  if (!comprobar_hora(document.modNoticia.hora,'Hora incorrecta')){
		err=1;
	  }  	
  }else {
  	if (document.modNoticia.tipo.value=='otros'){
	  if ((((document.modNoticia.tituloC.value).length==0) || ((document.modNoticia.tituloC.value).length > 30)) &&
	      (((document.modNoticia.tituloV.value).length==0) || ((document.modNoticia.tituloV.value).length > 30)) && 
	      (((document.modNoticia.tituloI.value).length==0) || ((document.modNoticia.tituloI.value).length > 30)) ){
		alert("Debe introducir el título de la noticia como máximo con 100 caracteres en alguno de los idiomas");  
		err=1;
	  }      
	  if ((((document.modNoticia.textoC.value).length>250) || ((document.modNoticia.textoC.value).length == 0)) && 
	      (((document.modNoticia.textoV.value).length>250) || ((document.modNoticia.textoV.value).length == 0)) && 
	      (((document.modNoticia.textoI.value).length>250) || ((document.modNoticia.textoI.value).length == 0))){
		alert("Introduzca el texto de la noticia como máximo con 250 caracteres en alguno de los idioma");  
		err=1;
	  }  	
	}
  }
  if (((document.modNoticia.fecha_caducidad.value).length==0) || (!comprobar_fecha(document.modNoticia.fecha_caducidad,'Fecha de caducidad incorrecta'))){
	err=1;
  }      
  if (err==0){
  	document.modNoticia.submit();
  }
}

//Reparto Laboratorios
function modificar_espacios(){
	open('https://www.dsic.upv.es/mapa/espanyol/intranet/repartoLaboratorios/modificar_espacios.pl','RepartoLaboratorios','scrollbars=yes,toolbar=no,menubar=no,width=600,height=480');	
}

function modificar_pesos(){
	open('https://www.dsic.upv.es/mapa/espanyol/intranet/repartoLaboratorios/modificar_pesos.pl','RepartoLaboratorios','scrollbars=yes,toolbar=no,menubar=no,width=600,height=480');	
}

function resultados_reparto(){
	open('https://www.dsic.upv.es/mapa/espanyol/intranet/repartoLaboratorios/repartoLaboratoriosRes.pl','RepartoLaboratorios','scrollbars=yes,toolbar=no,menubar=no,width=400,height=350');	
}

