function email(nombre,dominio)
{
 var cadena="";

 cadena+=nombre+'@'+dominio;
 window.top.location.href="mailto:"+cadena;

}

function isValidEmail(strEmail){
//validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;

var validRegExp = /^(.+\@.+\..+)$/;
strEmail = document.forms[0].sem_email.value;

// search email text for regular exp matches
if (strEmail.search(validRegExp) == -1) 
{
 return false;
} 
return true; 
}


function comprobar_existe(caracter)
{
 var encontrado=false;
 var array_chars = new Array('a', 'b', 'c', 'd', 'e', 'f', 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0', '1', '2', '3', '4', '5', '6', '7', '8', '9','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T','U', 'V', 'W', 'X', 'Y', 'Z');

 for (k=0;k<array_chars.length;k++)
 {
  if (array_chars[k]==caracter)
	 {
	  encontrado=true;
	 }
 }
return encontrado;
}

function comprobar_existe_pag(caracter)
{

 var encontrado=false;
 var array_chars = new Array('a', 'b', 'c', 'd', 'e', 'f', 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0', '1', '2', '3', '4', '5', '6', '7', '8', '9','A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T','U', 'V', 'W', 'X', 'Y', 'Z','_');

 for (k=0;k<array_chars.length;k++)
 {

  if (array_chars[k]==caracter)
	 {
	  encontrado=true;
	 }
 }
return encontrado;
}


function comprobar_passwd(passwd){

var longitud=passwd.length;

  for (j=0;j<=longitud-1;j++){
   var car=passwd.charAt(j);
   if (!comprobar_existe(car))
	  {
		 return false;
		}
  }
  return true;
}






//comprobar-formatos-alumnos
function comprobarFormatosAlumnos()
{
	//Comprobamos los formatos y si todo va bien, llamamos al submit
	strfield2 = document.getElementById("alu_passwd").value;
	strfield3 = document.getElementById("alu_passwd2").value;
	if (strfield2.length<4)
	{
		alert("El campo \"Clave de acceso\" debe tener al menos 4 caracteres");
		return false;
	}
	if (!comprobar_passwd(strfield2))
	{
		alert("El campo \"Clave de acceso\" contiene caracteres incorrectos. Sólo están permitidos caracteres alfanuméricos.");
		return false;
	} 
	if (strfield2!=strfield3)
	{
	    alert("El campo \"Clave de acceso\" y \"Repetir Clave de acceso\" no coinciden");
		return false;
	} 
	document.getElementById("formAltaAluUCM").submit();
}
//comprobar-formatos-alumnos no ucm
function comprobarFormatosAlumnosNoUCM()
{
	//Comprobamos los formatos y si todo va bien, llamamos al submit
	strfield2 = document.getElementById("alu_passwd").value;
	strfield3 = document.getElementById("alu_passwd2").value;
	if (strfield2.length<4)
	{
		alert("El campo \"Clave de acceso\" debe tener al menos 4 caracteres");
		return false;
	}
	if (!comprobar_passwd(strfield2))
	{
		alert("El campo \"Clave de acceso\" contiene caracteres incorrectos. Sólo están permitidos caracteres alfanuméricos.");
		return false;
	} 
	if (strfield2!=strfield3)
	{
	    alert("El campo \"Clave de acceso\" y \"Repetir Clave de acceso\" no coinciden");
		return false;
	} 
	document.getElementById("formAltaAluNoUCM").submit();
}


//Una vez que estan rellenos los campos del formulario de inscripcion
//de profesores, ver 
function comprobarFormatosProfesores()
{

	//strfield3 = document.forms[0].sem_email.value;
	strfield4 = document.getElementById("sem_passwd").value;
	strfield5 = document.getElementById("sem_passwd2").value;
	//strfield8 = document.forms[0].sem_p_alumno.value;
	//strfield9 = document.forms[0].sem_p_alumno2.value;
	/*if (!isValidEmail(strfield3))
	 {
	  alert("El campo \"Correo Electrónico\" no es válido");
		return false;
	 }
	*/
	if (strfield4.length<4)
	{
	    alert("El campo \"Clave de acceso\" debe tener al menos 4 caracteres");
		return false;
	}
	if (!comprobar_passwd(strfield4))
	{
		alert("El campo \"Clave de acceso\" contiene caracteres incorrectos. Sólo están permitidos caracteres alfanuméricos.");
		return false;
	} 
	if (strfield4!=strfield5)
	{
		alert("El campo \"Clave de acceso\" y \"Repetir Clave de acceso\" no coinciden");
		return false;
	}
	document.getElementById("formAltaProfUCM").submit();
}
//Antiguo : comprobar_formatos_no_ucm
function comprobarFormatosProfesoresNoUCM()
{
	strfield4 = document.getElementById("sem_passwd_no_ucm").value;
	strfield5 = document.getElementById("sem_passwd2_no_ucm").value;
	if (strfield4.length<4)
	{
	    alert("El campo \"Clave de acceso\" debe tener al menos 4 caracteres");
		return false;
	}
	if (!comprobar_passwd(strfield4))
	{
		alert("El campo \"Clave de acceso\" contiene caracteres incorrectos. Sólo están permitidos caracteres alfanuméricos.");
		return false;
	}
	if (strfield4!=strfield5)
	{
	    alert("El campo \"Clave de acceso\" y \"Repetir Clave de acceso\" no coinciden");
		return false;
	}
	document.getElementById("formAltaProfNoUCM").submit();

}//funcion

function comprobar_vacio_dni(){
//change "field1, field2 and field3" to your field names
strfield1 = document.forms[0].olvido_dni.value;
if (strfield1 == "" || strfield1 == null || strfield1.charAt(0) == ' ')
{
alert("El campo \"DNI\" es obligatorio");
return false;
}

document.form_olvido.submit();
return true;

}

//Comprobar vacios de los profesores
function comprobarCamposProfesores()
{
	//change "field1, field2 and field3" to your field names
	strfield1 = document.getElementById("sem_dni").value; 
	strfield2 = document.getElementById("sem_nrp").value;
	//strfield3 = document.forms[0].sem_email.value;
	strfield4 = document.getElementById("sem_passwd").value;
	strfield5 = document.getElementById("sem_passwd2").value;
	strfield6 = document.getElementById("sem_pregunta").value;
	strfield7 = document.getElementById("sem_respuesta").value;
	//strfield8 = document.forms[0].sem_p_alumno.value;
	//strfield9 = document.forms[0].sem_p_alumno2.value;
	if (strfield1 == "" || strfield1 == null || strfield1.charAt(0) == ' ')
	{
		alert("El campo \"DNI\" es obligatorio");
		return false;
	}
	if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
	{
		alert("El campo \"Número de Registro Personal\" es obligatorio");
		return false;
	}
	/*if (strfield3 == "" || strfield3 == null || strfield3.charAt(0) == ' ')
	{
	alert("El campo \"Correo Electrónico\" es obligatorio");
	return false;
	}
	*/
	if (strfield4 == "" || strfield4 == null || strfield4.charAt(0) == ' ')
	{
		alert("El campo \"Clave de acceso\" es obligatorio");
		return false;
	}
	if (strfield5 == "" || strfield5 == null || strfield5.charAt(0) == ' ')
	{
		alert("El campo \"Repetir clave de acceso\" es obligatorio");
		return false;
	}
	if (strfield6 == "" || strfield6 == null || strfield6.charAt(0) == ' ')
	{
		alert("El campo \"Pregunta desafío\" es obligatorio");
		return false;
	}
	if (strfield7 == "" || strfield7 == null || strfield7.charAt(0) == ' ')
	{
		alert("El campo \"Respuesta desafío\" es obligatorio");
		return false;
	}
	/*
	if (strfield8 == "" || strfield8 == null || strfield8.charAt(0) == ' ')
	{
	alert("El campo \"Clave de Acceso del Alumno Invitado\" es obligatorio");
	return false;
	}

	if (strfield9 == "" || strfield9 == null || strfield9.charAt(0) == ' ')
	{
	alert("El campo \"Repetir Clave de Acceso del Alumno Invitado\" es obligatorio");
	return false;
	}
	*/
	comprobarFormatosProfesores();
	return true;
}
//antiguo comprobar_vacios_no_ucm
function comprobarCamposProfesoresNoUCM()
{

	//change "field1, field2 and field3" to your field names
	strfield1 = document.getElementById("sem_dni_no_ucm").value; 
	strfield4 = document.getElementById("sem_passwd_no_ucm").value;
	strfield5 = document.getElementById("sem_passwd2_no_ucm").value;
	strfield6 = document.getElementById("sem_pregunta_no_ucm").value;
	strfield7 = document.getElementById("sem_respuesta_no_ucm").value;
	if (strfield1 == "" || strfield1 == null || strfield1.charAt(0) == ' ')
	{
		alert("El campo \"DNI\" es obligatorio");
		return false;
	}
	if (strfield4 == "" || strfield4 == null || strfield4.charAt(0) == ' ')
	{
		alert("El campo \"Clave de acceso\" es obligatorio");
		return false;
	}
	if (strfield5 == "" || strfield5 == null || strfield5.charAt(0) == ' ')
	{
		alert("El campo \"Repetir clave de acceso\" es obligatorio");
		return false;
	}
	if (strfield6 == "" || strfield6 == null || strfield6.charAt(0) == ' ')
	{
		alert("El campo \"Pregunta desafío\" es obligatorio");
		return false;
	}
	if (strfield7 == "" || strfield7 == null || strfield7.charAt(0) == ' ')
	{
		alert("El campo \"Respuesta desafío\" es obligatorio");
		return false;
	}
	comprobarFormatosProfesoresNoUCM();
	return true;
}

//comprobar_vacios_alumnos
//Comprobar que los campos del formulario de alumno UCM estan rellenos 
function comprobarCamposAlumnos()
{
	//change "field1, field2 and field3" to your field names
	strfield1 = document.getElementById("alu_dni").value; 
	strfield2 = document.getElementById("alu_passwd").value;
	strfield3 = document.getElementById("alu_passwd2").value;
	strfield4 = document.getElementById("alu_pregunta").value;
	strfield5 = document.getElementById("alu_respuesta").value;
	if (strfield1 == "" || strfield1 == null || strfield1.charAt(0) == ' ')
	{
		alert("El campo \"DNI\" es obligatorio");
		return false;
	}
	if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
	{
		alert("El campo \"Clave de acceso\" es obligatorio");
		return false;
	}
	if (strfield3 == "" || strfield3 == null || strfield3.charAt(0) == ' ')
	{
		alert("El campo \"Repetir clave de acceso\" es obligatorio");
		return false;
	}
	if (strfield4 == "" || strfield4 == null || strfield4.charAt(0) == ' ')
	{
		alert("El campo \"Pregunta desafío\" es obligatorio");
		return false;
	}

	if (strfield5 == "" || strfield5 == null || strfield5.charAt(0) == ' ')
	{
		alert("El campo \"Respuesta desafío\" es obligatorio");
		return false;
	}
	comprobarFormatosAlumnos();
	return true;
}//funcion

//Comprobar que los campos del formulario de alumno NO UCM estan rellenos
function comprobarCamposAlumnosNoUCM()
{
	//change "field1, field2 and field3" to your field names
	strfield1 = document.getElementById("alu_dni").value; 
	strfield2 = document.getElementById("alu_passwd").value;
	strfield3 = document.getElementById("alu_passwd2").value;
	strfield5 = document.getElementById("alu_pregunta").value;
	strfield6 = document.getElementById("alu_respuesta").value;
	if (strfield1 == "" || strfield1 == null || strfield1.charAt(0) == ' ')
	{
		alert("El campo \"DNI\" es obligatorio");
		return false;
	}
	if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
	{
		alert("El campo \"Clave de acceso\" es obligatorio");
		return false;
	}
	if (strfield3 == "" || strfield3 == null || strfield3.charAt(0) == ' ')
	{
		alert("El campo \"Repetir clave de acceso\" es obligatorio");
		return false;
	}
	if (strfield5 == "" || strfield5 == null || strfield5.charAt(0) == ' ')
	{
		alert("El campo \"Pregunta desafio\" es obligatorio");
		return false;
	}
	if (strfield6 == "" || strfield6 == null || strfield6.charAt(0) == ' ')
	{
		alert("El campo \"Respuesta desafio\" es obligatorio");
		return false;
	}
	comprobarFormatosAlumnosNoUCM();
	return true;
}



function ir_pagina_ppal(){
	 location.href="../peticion_seminarios/peticion_seminarios.php";
}
function ir_pagina_ppal_pag(){
  location.href="../pag_personales/index_pag_personal.html";
}
function ir_pagina_ppal_sem(){
   location.href="../pag_personales/index_sem_investigacion.html";
}
function ir_pagina_ppal_cont(){
   location.href="../eleccion_asignatura/frame_continuar.html";
}
// --------------------------
//FORMULARIO ALTA ASIGNATURAS
// --------------------------

function comprobar_vacios_asig(){

  strfield1 = document.forms[0].asig_dni.value; 
  strfield2 = document.forms[0].asig_passwd.value;

  if (strfield1 == "" || strfield1 == null || strfield1.charAt(0) == ' ')
  {
   alert("El campo \"DNI\" es obligatorio");
   return false;
  }

  if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
  {
   alert("El campo \"Clave de Acceso\" es obligatorio");
   return false;
  }
  document.form_peticion_asig.submit();
	
}

/*
function comprobar_passwd_alumno()
{
strfield1 = document.forms[0].p_alu_gen.value; 
strfield2 = document.forms[0].p_alu_gen2.value;

if (strfield1 == "" || strfield1 == null || strfield1.charAt(0) == ' ')
{
alert("El campo \"Clave de Acceso Alumno Genérico\" es obligatorio");
return false;
}

if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
{
alert("El campo \"Repetir Clave de Acceso Alumno Genérico\" es obligatorio");
return false;
}

if (strfield1.length<4)
 {
  alert("El campo \"Clave de acceso Alumno Genérico\" debe tener al menos 4 caracteres");
	return false;
 }

if (!comprobar_passwd(strfield1))
 {
  alert("El campo \"Clave de acceso Alumno Genérico\" contiene caracteres incorrectos. Sólo están permitidos caracteres alfanuméricos.");
	return false;
 } 

if (strfield1!=strfield2)
 {
  alert("El campo \"Clave de acceso Alumno Genérico\" y \"Repetir Clave de acceso Alumno Genérico\" no coinciden");
	return false;
 }
 
document.form_insertar.submit();

}

*/
function ir_pagina_ppal_asig(){
	 location.href="../eleccion_asignatura/peticion_asignatura.html";
}

function ir_pagina_ppal_form(){
	 location.href="../eleccion_asignatura/frame.html";
}

function ir_pagina_inicio(){
	 location.href="../principal.html";
}

function abrir_ventana_peque(el_url) {

var titulo="";

window.open(el_url,titulo,"top=10,left=10,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes,location=yes,status=yes,width='85%',height='80%'");
}


function comprobar_vacios_pag_personal() {

strfield1 = document.forms[0].prof_dni.value; 
strfield2 = document.forms[0].pag.value;
strfield3 = document.forms[0].descCurso.value;
// strfield4 = document.forms[0].objetivo.value;

if (strfield1 == "" || strfield1 == null || strfield1.charAt(0) == ' ')
{
alert("El campo \"DNI\" es obligatorio");
return false;
}

if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
{
alert("El campo \"Nombre de la Página Personal\" es obligatorio");
return false;
}
if (strfield3 == "" || strfield3 == null || strfield3.charAt(0) == ' ') {
alert("El campo \"Nombre del curso\" es obligatorio ");
return false;
}


longitud=strfield1.length;
for (j=0;j<=longitud-1;j++){
   var car=strfield1.charAt(j);
   if (!comprobar_existe(car))
	  {
	    alert("El campo \"DNI/Pasaporte\" contiene carácteres inválidos");	
            return false;
       	   }
  }


longitud=strfield2.length;
for (j=0;j<=longitud-1;j++){
   var car=strfield2.charAt(j);
   if (!comprobar_existe_pag(car))
	  {
	    alert("El campo \"Nombre de la Página Personal\" contiene carácteres inválidos");	
            return false;
       	   }
  }
  
// comprobar_formatos_pag();
document.forms[0].submit();
return true;
}

function comprobar_vacios_sem_inves(){
//change "field1, field2 and field3" to your field names
strfield1 = document.forms[0].prof_dni.value; 
strfield2 = document.forms[0].descCurso.value;

if (strfield1 == "" || strfield1 == null || strfield1.charAt(0) == ' ')
{
alert("El campo \"DNI\" es obligatorio");
return false;
}

if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
{
alert("El campo \"Nombre del curso\" es obligatorio");
return false;
}
document.forms[0].submit();
return true;
}






