//--EXPLICACIÓN:
//*********************************************************************************************
//Nombre archivo: comprobar.js
//Accion:
//						-	Funciones a raiz de pasar los campos de formularios para compromarlos.
//						-  .js activado desde el archivo inc_abierto.php
//*********************************************************************************************

//--CONTENIDO:
function comprobar_mail()
{  //Recojo los valores del formulario.
	nombre =		document.forms[0].elements[0].value;
	apellidos = document.forms[0].elements[1].value;
	m =			     document.forms[0].elements[2].value; //email
	comentario =document.forms[0].elements[3].value;
	
	var ok = true;;
	if ((nombre=="")||(apellidos=="")||(m=="")||(comentario==""))
	{		alert("Por favor, todos los campos han de ser rellenados. Gracias");
			var ok= false;
	}
	else
	{     
			ok = true
 	}
	return ok;
 }
 function comprobar_incidencia()
{  //Recojo los valores del formulario.
	mail =		document.forms[0].elements[0].value;
	nombre = document.forms[0].elements[1].value;
	comentario =document.forms[0].elements[2].value;

	
	var ok = true;;
	if ((nombre=="")||(mail=="")||(comentario==""))
	{		alert("Por favor, todos los campos han de ser rellenados. Gracias");
			var ok= false;
	}
	else
	{     k = true
 	}
	return ok;
 }
 function comprobar_notificacion()
{  //Recojo los valores del formulario.
	emisor_id = document.getElementById("emisor_id").value;
	emisor_nombre = document.getElementById("emisor_nombre").value;
	asunto = document.forms[0].asunto.value;
	comentario =document.forms[0].elements[4].value;
	
	var ok = true;;
	if ((asunto=="")||(comentario==""))
	{		alert("Por favor, todos los campos han de ser rellenados. Gracias");
			var ok= false;
	}
	else
	{     k = true
 	}
	return ok;
 }
 function comprobar_login()
 {   	usuario =	document.loginacion.usuario.value;
		contrasena = document.loginacion.contrasena.value;
		
		var ok = false;
		if ((usuario=="")||(contrasena==""))
		{  alert("Ha de rellenar el campo usuario y contraseña")
		   var ok = false;
		}
		else
		{  if (contrasena.length < 6 )
		   {  alert("La contraseña ha de ser minimo de 6 caracteres");
		      var ok = false;
		   }
		   else
		   {  var ok = true;
		   }
		}
		return ok;
}
function comprobar_profesora()
{	forma = document.getElementById("profesora");
	act = forma.act.value;
	error = "";
 	ok = true;
 	
 	if (act== "1_obs")
	{	if (forma.option_alu.selectedIndex == "0")
	 	{  ok = false
		   error += "- Seleccione un alumno\n";
	 	}
	}
		if (ok == false)
	{  alert(error)
	}

 	return ok
}

function comprobar_objetivos()
{	forma = document.getElementById("objetivos");
	act = forma.act.value;
	error = "";
 	ok = true;

	 	if (forma.option_ano.selectedIndex == "0")
	 	{  ok = false
		   error += "- Seleccione un año escolar\n";
	 	}
	 	if (forma.option_tri.selectedIndex == "0")
	 	{  ok = false
		   error += "- Seleccione un Trimestre\n";
	 	}
		fechai = forma.iano.value+forma.imes.value+forma.idia.value;
		fechaf = forma.fano.value+forma.fmes.value+forma.fdia.value;
		
		if (fechai.length == 6)
		{ 	ano = fechai.substring(0,2)
			mes = fechai.substring(2,4)
			if ((mes>12) || (mes < 01))
			{  error +="- Escriba un mes correcto\n";
			   ok = false
			}
	 		dia = fechai.substring(4,6)
	 		if ((dia>31) || (dia<01))
	 		{  error +="- Escriba un dia correcto.\n";
			   ok = false
			}
			else
			{  if ((mes == "04") || (mes == "06") || (mes == "09") || (mes == "11"))
				{	if (dia>30)
					{	error +="- El mes no puede tener mas de 30 dias.\n"
					   ok = false;
					}
				}
				if (mes == "02")
				{  valor = ano/4;
				   valor=valor.toString();
					res = valor.indexOf(".");
					res = valor.indexOf(",");
					if (res != -1)
					{  if (dia>29)
					   {  error +="- El mes no puede tener mas de 29 dias.\n"
					   	ok = false;
					   }
					}
					else
					{  //Año no bisiesto
					   if (dia>28)
					   {  error +="- El mes no puede tener mas de 28 dias.\n"
					   	ok = false;
					   }
					}
				}
			}
		}
		else
		{  ok = false
		   error += "- Escriba la fecha tal como se indica\n";
		}
		if (fechaf.length == 6)
		{ 	ano = fechaf.substring(0,2)
			mes = fechaf.substring(2,4)
			if ((mes>12) || (mes < 01))
			{  error +="- Escriba un mes correcto\n";
			   ok = false
			}
	 		dia = fechaf.substring(4,6)
	 		if ((dia>31) || (dia<01))
	 		{  error +="- Escriba un dia correcto.\n";
			   ok = false
			}
			else
			{  if ((mes == "04") || (mes == "06") || (mes == "09") || (mes == "11"))
				{	if (dia>30)
					{	error +="- El mes no puede tener mas de 30 dias.\n"
					   ok = false;
					}
				}
				if (mes == "02")
				{  valor = ano/4;
				   valor=valor.toString();
					res = valor.indexOf(".");
					res = valor.indexOf(",");
					if (res != -1)
					{  if (dia>29)
					   {  error +="- El mes no puede tener mas de 29 dias.\n"
					   	ok = false;
					   }
					}
					else
					{  //Año no bisiesto
					   if (dia>28)
					   {  error +="- El mes no puede tener mas de 28 dias.\n"
					   	ok = false;
					   }
					}
				}
			}
		}
		else
		{  ok = false
		   error += "- Escriba la fecha tal como se indica\n";
		}
		if (fechai > fechaf)
		{	ok = false
		   error += "- La fecha inicial ha de ser anterior a la final\n";
		}

	if (ok == false)
	{  alert(error)
	}
 	return ok
}

function comprobar_calendario()
{  form = document.getElementById("calendario")
	act = form.act.value;
	
	error = "";
 	ok = true;
 	
	if ((act== "1_cal")||(act== "3_cal"))
	{		fecha = form.ano.value+form.mes.value+form.dia.value;
			if (fecha.length == 6)
			{ 	ano = fecha.substring(0,2)
				mes = fecha.substring(2,4)
				if ((mes>12) || (mes < 01))
				{  error +="- Escriba un mes correcto\n";
				   ok = false
				}
		 		dia = fecha.substring(4,6)
		 		if ((dia>31) || (dia<01))
		 		{  error +="- Escriba un dia correcto.\n";
				   ok = false
				}
				else
				{  if ((mes == "04") || (mes == "06") || (mes == "09") || (mes == "11"))
					{	if (dia>30)
						{	error +="- El mes no puede tener mas de 30 dias.\n"
						   ok = false;
						}
					}
					if (mes == "02")
					{  valor = ano/4;
					   valor=valor.toString();
						res = valor.indexOf(".");
						res = valor.indexOf(",");
						if (res != -1)
						{  if (dia>29)
						   {  error +="- El mes no puede tener mas de 29 dias.\n"
						   	ok = false;
						   }
						}
						else
						{  //Año no bisiesto
						   if (dia>28)
						   {  error +="- El mes no puede tener mas de 28 dias.\n"
						   	ok = false;
						   }
						}
					}
				}
			}
		 	
			else
			{  ok = false
			   error += "- Escriba la fecha tal como se indica\n";
			}
			if (form.option_type_cal.selectedIndex == "0")
		 	{  ok = false
			   error += "- Seleccione un tipo de fecha\n";
		 	}
		 	//Titulo
			if (form.titulo.value == "")
			{  ok = false
			   error += "- Escriba un titulo\n";
			}
			//Checked.
			
		 	if (form.activado[1].checked == true)
			{  if (form.option_per_cal.selectedIndex == "0")
			   {  ok = false
			   	error += "- Seleccione un tipo de acceso.\n";
			   }
			   if (form.option_des_cal.selectedIndex == "0")
			   {  ok = false
			   	error += "- Seleccione el acceso detallado.";
			   }
			}
	
	
	}
	if ((act== "7_cal")||(act== "8_cal"))
	{	//Titulo
		if (form.titulo.value == "")
		{  ok = false
		   error += "- Escriba un titulo\n";
		}
	}

	if (ok == false)
	{  alert(error)
	}
	
 	return ok

}

function comprobar_mensajes()
{	var ok = true;
	error="";
	form = document.getElementById("mensajes")
	act = form.act.value;
	
	if (act=="1_men")
	{	if (form.receptor.value.length=="0")
		{	var ok=false
			error += "- Escoja un receptor a través de la agenda.\n";
		}
		if (form.asunto.value.length=="0")
		{	var ok=false
			error += "- Introduzca un asunto en el mensaje.\n";
		}
	}
	if ((act=="6_men")||(act=="5_men"))
	{	if (form.asunto.value.length=="0")
		{	var ok=false
			error += "- Introduzca un asunto en el mensaje.\n";
		}
	}
	if (ok==false)
	{	alert(error)
	}	
	return ok;
}
function comprobar_servicio()
{	var ok = true;
	error="";
	form = document.getElementById("servicios")
	act = form.act.value;
	
	if ((act=="1_ser")||(act=="3_ser"))
	{	if (form.titulo.value.length=="0")
		{	var ok=false
			error += "- Esriba un titulo.\n";
		}
		if ((form.activado[0].checked == false) && (form.activado[1].checked == false))
		{	var ok=false
			error += "- Elija si desea que salga en la Portada o no\n";
		}
		
	}
	
	if (ok==false)
	{	alert(error)
	}	
	return ok;
}

function comprobar_enlaces()
{	var ok = true;
	error="";
	form = document.getElementById("enlaces")
	if ((form.act.value=="1_cat") || (form.act.value=="3_cat"))
	{	//Comprueba titulo
		if (form.titulo.value.length==0)
		{	var ok=false
			error += "- Escriba un titulo\n";
		}
		
	}
	if ((form.act.value=="1_enl") || (form.act.value=="3_enl"))
	{	//Comprueba titulo
		if (form.titulo.value.length==0)
		{	var ok=false
			error += "- Escriba un titulo\n";
		}
		
		if(form.option_cat.selectedIndex == 0)
		{	var ok=false
			error += "- Seleccione una categoria\n";
		}
		
		//Compruebo la direccion:
		if (form.texto.value.length==0)
		{	var ok=false
			error += "- Escriba una dirección web\n";
		}
		else
		{	// texto + punto + texto.
			letras = form.texto.value;
			punto_inicial = letras.indexOf(".")
			punto_final = letras.lastIndexOf(".")
			largo = letras.length;
			letras_medio = letras.slice(punto_inicial,punto_final)
			letras_delante = letras.slice(0,punto_inicial)
			letras_detras = letras.slice(punto_final,largo)
			if((punto_final-punto_inicial)>0)
			{	if ((letras_delante!="http://") && (letras_delante!="http://www"))
				{	direccion ="http://www"+letras_medio;
				}
				if (letras_detras.length >1)
				{	direccion +=letras_detras
					
					form.texto.value = direccion
				}
				else
				{	var ok = false
					error += "- Escribe una direccion web correcta\n";
				}
			}
			else
			{	var ok = false
				error += "- Escribe una direccion web correcta\n";
			}
		}
	}
	if (ok == false)
	{	alert(error)
	}
	
	return ok;
}
function comprobar_clase()
{	form = document.getElementById("clase")
	var ok = true;
	error="";
	if (form.titulo.value.length=="0")
	{	var ok = false;
		error +="- Escriba el nombre de la clase\n";
	}
	if (ok == false)
	{	alert(error)
	}
	return ok;
}
function comprobar_documentos()
{	
	forma = document.getElementById("documentos")
	
	var ok = true;
	error="";
	act = forma.act.value;
	
	if (act=="3_doc")
	{	if (forma.option_car.selectedIndex=="0")
		{	var ok = false;
			error +="- Seleccione una carpeta";
		}
	
	}
	if (act=="1_doc")
	{	if (forma.can.value.length=="0")
		{	if ((forma.cantidad.value.length=="0")||(forma.cantidad.value=="0"))
			{	var ok = false;
				error +="- Introduzca el número de documentos a insertar";	
			}
		}
		else
		{	if (forma.option_car.value=="0")
			{	var ok = false;
				error +="- Seleccione una carpeta";	
			}
		}
		
	}
	if (act=="1_car")
	{	if (forma.nombre.value.length=="0")
		{	var ok = false;
			error +="- Esriba un nombre a la carpeta";
		}
	}
	if (ok==false)
	{	alert(error)
	}
	return ok;

}

function comprobar_galeria()
{	
	forma = document.getElementById("galeria")
	var ok = true;
	error="";
	act = forma.act.value;
	
	if (act=="3_gal")
	{	if (forma.option_alb.selectedIndex=="0")
		{	var ok = false;
			error +="- Seleccione un album";
		}
	
	}

	if (act=="1_gal")
	{	if (forma.can.value.length=="0")
		{	if ((forma.cantidad.value.length=="0")||(forma.cantidad.value=="0"))
			{	var ok = false;
				error +="- Introduzca el número de imagenes a insertar";	
			}
		}
		else
		{	if (forma.option_alb.value=="0")
			{	var ok = false;
				error +="- Seleccione un album";	
			}
		}
		
	}
	if (act=="1_alb")
	{	if (forma.nombre.value.length=="0")
		{	var ok = false;
			error +="- Esriba un nombre al album";
		}
	}
	if (ok==false)
	{	alert(error)
	}
	return ok;

}
function comprobar_alumno()
{	form = document.getElementById("alumno")
	var ok = true;
	error="";
	act = form.act.value;
	
	if (act=="2_alu")
	{	if (form.nombre.value.length=="0")
		{	var ok = false;
			error +="- Escriba su búsqueda\n";
		}
	}
	if ((act=="1_alu") ||(act=="3_alu")) 
	{	
		if (form.nombre.value.length=="0")
		{	var ok = false;
			error +="- Escriba un nombre\n";
		}
		if (form.apellidos.value.length=="0")
		{	var ok = false;
			error +="- Escriba los apellidos\n";
		}
		
		if (form.option_cla.selectedIndex=="0")
		{	var ok = false;
			error +="- Seleccione una clase al alumno\n";
		}
		fecha = form.ano.value+form.mes.value+form.dia.value;
		if (fecha.length == 6)
		{ 	ano = fecha.substring(0,2)
			mes = fecha.substring(2,4)
			if ((mes>12) || (mes < 01))
			{  error +="- Escriba un mes correcto\n";
			   ok = false
			}
			dia = fecha.substring(4,6)
			if ((dia>31) || (dia<01))
			{  error +="- Escriba un dia correcto.\n";
			   ok = false
			}
			else
			{  if ((mes == "04") || (mes == "06") || (mes == "09") || (mes == "11"))
				{	if (dia>30)
					{	error +="- El mes no puede tener mas de 30 dias.\n"
					   ok = false;
					}
				}
				if (mes == "02")
				{  valor = ano/4;
				   valor=valor.toString();
					res = valor.indexOf(".");
					res = valor.indexOf(",");
					if (res != -1)
					{  if (dia>29)
					   {  error +="- El mes no puede tener mas de 29 dias.\n"
					   	ok = false;
					   }
					}
					else
					{  //Año no bisiesto
					   if (dia>28)
					   {  error +="- El mes no puede tener mas de 28 dias.\n"
					   	ok = false;
					   }
					}
				}
			}
		}
		else
		{  ok = false
		   error += "- Escriba la fecha tal como se indica\n";
		}
	}
	if (ok == false)
	{	alert(error);
	}
	return ok;

}
function comprobar_anuncios()
{	form = document.getElementById("anuncios")
	act = form.act.value;
	var ok = true;
	error="";
	if (form.titulo.value.length==0)
	{	var ok=false
		error += "- Escriba un titulo\n";
	}
	
	if ((form.activado[0].checked == false) && (form.activado[1].checked == false))
	{	var ok=false
		error += "- Elija si desea que salga en la Portada o no\n";
	}
	
	if (ok==false)
	{	alert(error)
	}
	return ok
}

function comprobar_menus()
{	form = document.getElementById("menus")
	act = form.act.value;
	
	var ok = true;
	error="";
	if ((act == "1_apa") || (act == "3_apa"))
	{	if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
		if (form.option_men.selectedIndex == 0)
		{	var ok = false;
			error +="- Seleccione un menu\n";
		}
	}
	if (act == "3_men")
	{	if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
	}
	if ((act == "1_blo") || (act == "3_blo"))
	{	if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
		if (form.option_men.selectedIndex == 0)
		{	var ok = false;
			error +="- Seleccione un menu\n";
		}
		if (form.option_apa.selectedIndex == 0)
		{	var ok = false;
			error +="- Seleccione un apartado\n";
		}
	
	}
	if (ok == false)
	{	alert(error)
	}
	return ok;
}

function comprobar_niveles()
{	form = document.getElementById("niveles")
	act = form.act.value;
	
	var ok = true;
	error="";
	if ((act == "1_gru") || (act == "3_gru"))
	{	
		if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
		if (form.option_cic.selectedIndex == 0)
		{	var ok = false;
			error +="- Seleccione un ciclo\n";
		}
	}
	if ((act == "3_cic") || (act == "1_cic"))
	{	if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
	}
	if ((act == "1_car") || (act == "3_car"))
	{	if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
		if (form.option_cic.selectedIndex == 0)
		{	var ok = false;
			error +="- Seleccione un ciclo\n";
		}
		if (form.option_gru.selectedIndex == 0)
		{	var ok = false;
			error +="- Seleccione un grupo\n";
		}
	
	}
	if (ok == false)
	{	alert(error)
	}
	return ok;
}
function comprobar_organizacion()
{	form = document.getElementById("organizacion")

	act = form.act.value;
	
	var ok = true;
	error="";
	if ((act == "1_gru") || (act == "3_gru"))
	{	
		if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
		if (form.option_cic.selectedIndex == 0)
		{	var ok = false;
			error +="- Seleccione un departamento\n";
		}
	}
	
	if ((act == "3_cic") || (act == "1_cic"))
	{	if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
	}
	if ((act == "1_car") || (act == "3_car"))
	{	if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
		if (form.option_cic.selectedIndex == 0)
		{	var ok = false;
			error +="- Seleccione un departamento\n";
		}
		if (form.option_gru.selectedIndex == 0)
		{	var ok = false;
			error +="- Seleccione una agrupacion\n";
		}
	
	}
	
	if (ok == false)
	{	alert(error)
	}
	return ok;
}
	
function comprobar_usuario()
{	form = document.getElementById("usuarios")
	
	var ok = true;
	error="";
	act = form.act.value;
	tipo = form.tip.value;
	
	if ((act=="1_usu")||(act=="3_usu"))
	{	if (form.nombre.value.length=="0")
		{	var ok = false;
			error +="- Escriba un nombre\n";
		}
		if (form.apellidos.value.length=="0")
		{	var ok = false;
			error +="- Escriba un apellido\n";
		}
		if ((form.usuari.value.length<"6") || (form.usuari.value.length>"28"))
		{	var ok = false;
			error +="- Escriba un usuario de 6 caracteres como minimo y 30 como maximo\n";
		}
		if ((form.contra.value.length<"6") || (form.contra.value.length>"28"))
		{	var ok = false;
			error +="- Escriba una contraseña de 6 caracteres como minimo y 30 como maximo\n";
		}
	}
	if (ok == false)
	{	alert(error);
	}
	return ok;

}

function comprobar_horario()
{	forma = document.getElementById("horario")
	var ok = true;
	error="";
	act = forma.act.value;
	
	if ((act=="3_hor")||(act=="4_hor"))
	{	if (forma.ihh.value.length == 1) {forma.ihh.value = "0"+forma.ihh.value}
		if (forma.imm.value.length == 1) {forma.imm.value = "0"+forma.imm.value}
		if (forma.fhh.value.length == 1) {forma.fhh.value = "0"+forma.fhh.value}
		if (forma.fmm.value.length == 1) {forma.fmm.value = "0"+forma.fmm.value}
		hori1 = forma.ihh.value;
		hori2 = forma.imm.value;
		horf1 = forma.fhh.value;
		horf2 = forma.fmm.value;
		if ((forma.ihh.value+forma.imm.value)>=(forma.fhh.value+forma.fmm.value))
		{	var ok = false;
			error +="- La hora final ha de ser posterior a la hora de inicio\n";
		}
		if ((hori1 > 23) || (horf1 > 23) || (hori2 > 59) || (horf2 > 59))
		{	var ok = false;
			error +="- Como máximo puede añadir la hora 23 y el minuto 59\n";
		}
		horat = hori1+hori2+horf1+horf2
		if (horat.length != 8)
		{	var ok = false;
			error +="- Escriba 2 digitos por casillas: 0/23 horas y 0/59 minutos\n";
		}  
	}
	if (ok == false)
	{	alert(error);
	}
	return ok;
}

function comprobar_proyectos_form()
{	form = document.getElementById("proyectos")
	act = form.act.value;
	var ok = true;
	error="";
	if ((act == "1_ico") || (act == "3_ico"))
	{  if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un nombre\n";
		}
	}
	if (act == "1_ico")
	{	if (form.imagen.value.length == 0)
		{	var ok = false;
			error +="- Incluya una imagen de 20 px anchura / 15 px altura\n";
		}
	}
	if ((act == "1_apa") || (act == "3_apa"))
	{	if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
		if (form.option_pro.selectedIndex == 0)
		{	var ok = false;
			error +="- Seleccione un menu\n";
		}
	}
	if (act == "3_pro")
	{	if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
	}
	if ((act == "1_blo") || (act == "3_blo"))
	{	if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
		if (form.option_pro.selectedIndex == 0)
		{	var ok = false;
			error +="- Seleccione un menu\n";
		}
		if (form.option_apa.selectedIndex == 0)
		{	var ok = false;
			error +="- Seleccione un apartado\n";
		}

	}
	if ((act == "1_pro") || (act == "3_pro"))
	{  if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
		if (form.accion.value.length == 0)
		{	var ok = false;
			error +="- Escriba una accion principal del proyecto\n";
		}
		if (form.objetivo.value.length == 0)
		{	var ok = false;
			error +="- Escriba el objetivo principal del proyecto\n";
		}
		if ((form.activado[1].checked != true) & (form.activado[0].checked != true))
		{  var ok = false;
			error +="- Elija la opción activación del proyecto\n";
		}
		if ((form.activado_pri[1].checked != true) & (form.activado_pri[0].checked != true))
		{  var ok = false;
			error +="- Elija la opción Proyecto Principal o Secundario\n";
		}
		if ((form.activado_por[1].checked != true) & (form.activado_por[0].checked != true))
		{  var ok = false;
			error +="- Elija la opción Portada\n";
		}
	}
	if (ok == false)
	{	alert(error)
	}
	return ok;
}

function comprobar_actividad()
{	form = document.getElementById("actividad");
	act = form.act.value;
	
	error = "";
 	ok = true;

 	if ((act== "3_act") || (act== "1_act"))
	{	fechai = form.iano.value+form.imes.value+form.idia.value;
		fechaf = form.fano.value+form.fmes.value+form.fdia.value;
		if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
		if (fechai.length == 6)
		{ 	ano = fechai.substring(0,2)
			mes = fechai.substring(2,4)
			if ((mes>12) || (mes < 01))
			{  error +="- Escriba un mes correcto\n";
			   ok = false
			}
	 		dia = fechai.substring(4,6)
	 		if ((dia>31) || (dia<01))
	 		{  error +="- Escriba un dia correcto.\n";
			   ok = false
			}
			else
			{  if ((mes == "04") || (mes == "06") || (mes == "09") || (mes == "11"))
				{	if (dia>30)
					{	error +="- El mes no puede tener mas de 30 dias.\n"
					   ok = false;
					}
				}
				if (mes == "02")
				{  valor = ano/4;
				   valor=valor.toString();
					res = valor.indexOf(".");
					res = valor.indexOf(",");
					if (res != -1)
					{  if (dia>29)
					   {  error +="- El mes no puede tener mas de 29 dias.\n"
					   	ok = false;
					   }
					}
					else
					{  //Año no bisiesto
					   if (dia>28)
					   {  error +="- El mes no puede tener mas de 28 dias.\n"
					   	ok = false;
					   }
					}
				}
			}
		}
		else
		{  ok = false
		   error += "- Escriba la fecha tal como se indica\n";
		}
		if (fechaf.length == 6)
		{ 	ano = fechaf.substring(0,2)
			mes = fechaf.substring(2,4)
			if ((mes>12) || (mes < 01))
			{  error +="- Escriba un mes correcto\n";
			   ok = false
			}
	 		dia = fechaf.substring(4,6)
	 		if ((dia>31) || (dia<01))
	 		{  error +="- Escriba un dia correcto.\n";
			   ok = false
			}
			else
			{  if ((mes == "04") || (mes == "06") || (mes == "09") || (mes == "11"))
				{	if (dia>30)
					{	error +="- El mes no puede tener mas de 30 dias.\n"
					   ok = false;
					}
				}
				if (mes == "02")
				{  valor = ano/4;
				   valor=valor.toString();
					res = valor.indexOf(".");
					res = valor.indexOf(",");
					if (res != -1)
					{  if (dia>29)
					   {  error +="- El mes no puede tener mas de 29 dias.\n"
					   	ok = false;
					   }
					}
					else
					{  //Año no bisiesto
					   if (dia>28)
					   {  error +="- El mes no puede tener mas de 28 dias.\n"
					   	ok = false;
					   }
					}
				}
			}
		}
		else
		{  ok = false
		   error += "- Escriba la fecha tal como se indica\n";
		}
		if (fechai > fechaf)
		{	ok = false
		   error += "- La fecha inicial ha de ser anterior a la final\n";
		}
	}
	if (ok == false)
	{  alert(error)
	}
 	return ok
}

function comprobar_banners()
{	form = document.getElementById("banners");
	act = form.act.value;
	error = "";
 	ok = true;
	if ((act== "3_ban") || (act== "1_ban"))
	{ 	if (form.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un titulo\n";
		}
		if (form.enlace.value.length == 0)
		{	var ok = false;
			error +="- Escriba un enlace\n";
		}
	}
	if (act== "1_ban")
	{ 	if (form.imagen.value.length == 0)
		{	var ok = false;
			error +="- Añada una imagen\n";
		}
	}

		if (ok == false)
	{  alert(error)
	}
 	return ok
}

function comprobar_ano()
{ 	forma = document.getElementById("anos_escolares");
 	act = forma.act.value;
	error = "";
	ok = true;
	if ((act== "1_ano") || (act== "3_ano"))
	{ 	if (forma.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un año\n";
		}
	}
	if (ok == false)
	{  alert(error)
	}
 	return ok
}
function comprobar_ingrediente()
{ 	formaa = document.getElementById("ingrediente");
 	act = formaa.act.value;
 	
	error = "";
	ok = true;
	if ((act== "1_ing") || (act== "3_ing"))
	{ 	if (formaa.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba un ingrediente\n";
		}
	}
	if (ok == false)
	{  alert(error)
	}
 	return ok
}
function comprobar_materia()
{ 	forma = document.getElementById("materia");
 	act = forma.act.value;
	error = "";
	ok = true;
	if ((act== "1_mat") || (act== "3_mat"))
	{ 	if (forma.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba una materia\n";
		}
	}
	if (ok == false)
	{  alert(error)
	}
 	return ok
}
function comprobar_boletin()
{ 	forma = document.getElementById("boletin");
 	act = forma.act.value;
	error = "";
	ok = true;
	if ((act== "1_bol") || (act== "3_bol"))
	{  if (forma.option_tri.selectedIndex == "0")
	 	{  ok = false
		   error += "- Seleccione un trimestre\n";
		}
		if (forma.option_alu.selectedIndex == "0")
	 	{  ok = false
		   error += "- Seleccione un alumno\n";
		}
		if (forma.option_ano.selectedIndex == "0")
	 	{  ok = false
		   error += "- Seleccione un año escolar\n";
		}
		
	}
	if (ok == false)
	{  alert(error)
	}
 	return ok
}

function comprobar_notas()
{ 	forma = document.getElementById("notas");
 	act = forma.act.value;
	error = "";
	ok = true;
	if ((act== "1_nota") || (act== "3_nota"))
	{ 	if (forma.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba una nota\n";
		}
		if (forma.option_tri.selectedIndex == "0")
	 	{  ok = false
		   error += "- Seleccione un trimestre\n";
		}
		if (forma.option_mat.selectedIndex == "0")
	 	{  ok = false
		   error += "- Seleccione una materia\n";
		}
		if (forma.option_alu.selectedIndex == "0")
	 	{  ok = false
		   error += "- Seleccione un alumno\n";
		}
		if (forma.option_ano.selectedIndex == "0")
	 	{  ok = false
		   error += "- Seleccione un año escolar\n";
		}
		
	}

	if (ok == false)
	{  alert(error)
	}
 	return ok
}

function comprobar_comedor()
{ 	forma = document.getElementById("comedor");
 	act = forma.act.value;
	error = "";
	ok = true;
	if ((act== "1_com") || (act== "3_com"))
	{ 	if (forma.titulo.value.length == 0)
		{	var ok = false;
			error +="- Escriba el titulo de la comida\n";
		}
							
		if ((forma.activado[0].checked == false) && (forma.activado[1].checked == false))
		{	var ok=false
			error += "- Elija si desea que este activado o desactivado\n";
		}
		fecha = forma.ano.value+forma.mes.value+forma.dia.value;
			if (fecha.length == 6)
			{ 	ano = fecha.substring(0,2)
				mes = fecha.substring(2,4)
				if ((mes>12) || (mes < 01))
				{  error +="- Escriba un mes correcto\n";
				   ok = false
				}
		 		dia = fecha.substring(4,6)
		 		if ((dia>31) || (dia<01))
		 		{  error +="- Escriba un dia correcto.\n";
				   ok = false
				}
				else
				{  if ((mes == "04") || (mes == "06") || (mes == "09") || (mes == "11"))
					{	if (dia>30)
						{	error +="- El mes no puede tener mas de 30 dias.\n"
						   ok = false;
						}
					}
					if (mes == "02")
					{  valor = ano/4;
					   valor=valor.toString();
						res = valor.indexOf(".");
						res = valor.indexOf(",");
						if (res != -1)
						{  if (dia>29)
						   {  error +="- El mes no puede tener mas de 29 dias.\n"
						   	ok = false;
						   }
						}
						else
						{  //Año no bisiesto
						   if (dia>28)
						   {  error +="- El mes no puede tener mas de 28 dias.\n"
						   	ok = false;
						   }
						}
					}
				}
			}

			else
			{  ok = false
			   error += "- Escriba la fecha tal como se indica\n";
			}

	}

	if (ok == false)
	{  alert(error)
	}
 	return ok
}
