// Scripts para el sitio web de la Facultad
// Implementados por Didier Fabián Granados M.
// Septiembre de 2003

function AbrirVentana(direccion,nombre,caracteristicas) { //v2.0
  window.open(direccion,nombre,caracteristicas);
}

function ValFrmCambiarPriv() {

	var priv = document.frm_aprobar.privilegio;
	
	if (priv.value == "") {
		alert("Por favor ingrese los privilegios del usuario");
		priv.select();
		return false;
	}
	if (confirm("¿Está seguro de cambiar los privilegios del usuario?")) document.frm_aprobar.submit();
}

function ValFrmAprobar() {

	var priv = document.frm_aprobar.privilegio;
	
	if (priv.value == "") {
		alert("Por favor ingrese los privilegios del usuario");
		priv.select();
		return false;
	}
	if (confirm("¿Está seguro de aprobar al usuario en el sistema?")) document.frm_aprobar.submit();
}

function ValidarPrever() {
	var nombre = document.frm_prever.nombre;
	var cantidad = document.frm_prever.cantidad;
	var telefono = document.frm_prever.telefono;
	var dia = document.frm_prever.dia;
	var mes = document.frm_prever.mes;
	var anio = document.frm_prever.anio;
	var aleatorio = document.frm_prever.aleatorio;
	
	if (nombre.value == "") {
		alert("Favor ingresar su nombre");
		nombre.focus();
		return false;
	}
	if (cantidad.value == "") {
		alert("Favor ingresar la cantidad");
		cantidad.focus();
		return false;
	}
	if (telefono.value == "") {
		alert("Favor ingresar el telefono");
		telefono.focus();
		return false;
	}
	if (dia.value == "") {
		alert("Favor ingresar el dia de la fecha de nacimiento");
		dia.focus();
		return false;
	}
	if (mes.value == "") {
		alert("Favor ingresar el mes de la fecha de nacimiento");
		mes.focus();
		return false;
	}
	if (anio.value == "") {
		alert("Favor ingresar el año de la fecha de nacimiento");
		anio.focus();
		return false;
	}
	if (aleatorio.value == "") {
		alert("Favor ingresar el numero indicado");
		aleatorio.focus();
		return false;
	}
	
	return confirm('¿Desea enviar los datos ingresados?');
	document.frm_prever.submit();
	
}
function ValidarGeneralidades() {
	var titulo = document.miforma.titulo;
	var descripcion = document.miforma.descripcion;
	
	if (titulo.value == "") {
		alert("Favor ingresar el título");
		nombre.focus();
		return false;
	}
	if (descripcion.value == "") {
		alert("Favor ingresar la descripcion");
		descripcion.focus();
		return false;
	}
	
	return true;
	
}

function Primas() {
	
	var forma_pago = document.frm_prestamo.forma_pago;
	// Primas
	var prima1 = document.frm_prestamo.prima1;
	var periodo1 = document.frm_prestamo.periodo1;
	var anio1 = document.frm_prestamo.anio1;
	var cantidad_prima1 = document.frm_prestamo.cantidad_prima1;
	
	var prima2 = document.frm_prestamo.prima2;
	var periodo2 = document.frm_prestamo.periodo2;
	var anio2 = document.frm_prestamo.anio2;
	var cantidad_prima2 = document.frm_prestamo.cantidad_prima2;
	
	var prima3 = document.frm_prestamo.prima3;
	var periodo3 = document.frm_prestamo.periodo3;
	var anio3 = document.frm_prestamo.anio3;
	var cantidad_prima3 = document.frm_prestamo.cantidad_prima3;
	
	var prima4 = document.frm_prestamo.prima4;
	var periodo4 = document.frm_prestamo.periodo4;
	var anio4 = document.frm_prestamo.anio4;
	var cantidad_prima4 = document.frm_prestamo.cantidad_prima4;
	
	
	//$total_primas = $cantidad_prima1+$cantidad_prima2+$cantidad_prima3+$cantidad_prima4;
	//if(($total_en_quincenas < ($cantidad*0.5)) or ($total_primas > ($cantidad*0.5)) or (($total_primas + $total_en_quincenas) != $cantidad))  $error_pago = 1;

	
	if(forma_pago.selectedIndex == 2)
	{
		prima1.disabled = false;
		periodo1.disabled = false;
		anio1.disabled = false;
		cantidad_prima1.disabled = false;
		
		prima2.disabled = false;
		periodo2.disabled = false;
		anio2.disabled = false;
		cantidad_prima2.disabled = false;
		
		prima3.disabled = false;
		periodo3.disabled = false;
		anio3.disabled = false;
		cantidad_prima3.disabled = false;
		
		prima4.disabled = false;
		periodo4.disabled = false;
		anio4.disabled = false;
		cantidad_prima4.disabled = false;
		
		return true;
	}
	else
	{
		prima1.disabled = true;
		periodo1.disabled = true;
		anio1.disabled = true;
		cantidad_prima1.disabled = true;
		
		prima2.disabled = true;
		periodo2.disabled = true;
		anio2.disabled = true;
		cantidad_prima2.disabled = true;
		
		prima3.disabled = true;
		periodo3.disabled = true;
		anio3.disabled = true;
		cantidad_prima3.disabled = true;
		
		prima4.disabled = true;
		periodo4.disabled = true;
		anio4.disabled = true;
		cantidad_prima4.disabled = true;
		
		return false;
	}
	
	
	if(prima1.checked == true) {
		if (cantidad_prima1.value == "") {
			alert("Favor ingresar la informacion faltante de las primas");
			prima1.focus();
			return false;
		}
	}
	if(prima2.checked == true) {
		if (cantidad_prima2.value == "") {
			alert("Favor ingresar la informacion faltante de las primas");
			prima2.focus();
			return false;
		}
	}
	if(prima3.checked == true) {
		if (cantidad_prima3.value == "") {
			alert("Favor ingresar la informacion faltante de las primas");
			prima3.focus();
			return false;
		}
	}
	//periodo4.value == "" || anio4.value == "" || 
	if(prima4.checked == true) {
		if (cantidad_prima4.value == "") {
			alert("Favor ingresar la informacion faltante de las primas");
			prima4.focus();
			return false;
		}
	}
	
	return true
}


function ValidarPrestamo() {
	
	var cantidad = document.frm_prestamo.cantidad;
	var carnet = document.frm_prestamo.carnet;
	var telefono = document.frm_prestamo.telefono;
	var email = document.frm_prestamo.email;
	var forma_pago = document.frm_prestamo.forma_pago;
	var num_quincenas = document.frm_prestamo.num_quincenas;
	var total_en_quincenas = document.frm_prestamo.total_en_quincenas;
	var aleatorio = document.frm_prestamo.aleatorio;
	
	if (isNaN(cantidad.value) || cantidad.value == "") {
		alert("Favor ingresar la cantidad solicitada");
		cantidad.focus();
		return false;
	}
	if (isNaN(carnet.value) || carnet.value == "") {
		alert("Favor ingresar el numero de carne");
		carnet.focus();
		return false;
	}
	if (telefono.value == "") {
		alert("Favor ingresar el numero telefonico");
		telefono.focus();
		return false;
	}
	if (email.value == "") {
		alert("Favor ingresar su correo electronico");
		email.focus();
		return false;
	}
	
	if (forma_pago.value == "") {
		alert("Favor ingresar la forma de pago");
		forma_pago.focus();
		return false;
	}
	if (isNaN(num_quincenas.value) || num_quincenas.value == "") {
		alert("Favor ingresar el numero de quincenas a pagar el prestamo");
		num_quincenas.focus();
		return false;
	}
	if (isNaN(total_en_quincenas.value) || total_en_quincenas.value == "") {
		alert("Favor ingresar el total a pagar en quincenas");
		total_en_quincenas.focus();
		return false;
	}
	
	//if(!Primas()) return false;
	
	if (aleatorio.value == "") {
		alert("Favor ingresar el numero indicado");
		aleatorio.focus();
		return false;
	}
	
	return confirm('¿Desea enviar los datos ingresados?');
	document.frm_prestamo.submit();
}


function ValidarRetiro() {
	var cantidad = document.frm_retiro.cantidad;
	var letras = document.frm_retiro.letras;
	var carnet = document.frm_retiro.carnet;
	var email = document.frm_retiro.email;
	var telefono = document.frm_retiro.telefono;
	var aleatorio = document.frm_retiro.aleatorio;
	
	if (cantidad.value == "") {
		alert("Favor ingresar la cantidad");
		cantidad.focus();
		return false;
	}
	if (letras.value == "") {
		alert("Favor ingresar la centidad en letras");
		letras.focus();
		return false;
	}
	if (carnet.value == "") {
		alert("Favor ingresar el numero de carnet");
		carnet.focus();
		return false;
	}
	if (telefono.value == "") {
		alert("Favor ingresar el numero telefonico");
		telefono.focus();
		return false;
	}
	if (email.value == "") {
		alert("Favor ingresar su correo electronico");
		email.focus();
		return false;
	}
	if (aleatorio.value == "") {
		alert("Favor ingresar el numero indicado");
		aleatorio.focus();
		return false;
	}
	
	return confirm('¿Desea enviar los datos ingresados?');
	document.frm_retiro.submit();
}

function Cargando(flag) {
	var str = "Cargando página...";
	if (flag == 1) str = "";
	window.status = str;
}

Cargando(0);

function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function Iluminar(s) {
  if ("INPUT" == event.srcElement.tagName) event.srcElement.className = s;
}

function VBuscar() {
  if (document.busquedas.q.value == "") {
    alert('Búsqueda\n\nPor favor escriba la(s) palabra(s) clave para realizar su búsqueda.');
	document.busquedas.q.focus();
	return false;
  }
  document.busquedas.submit();
}

// Validación de una dirección de Correo Electrónico
// Versión en Español por Didier Granados (Flash)
// No se quién carajos es el autor la versión original (en Inglés),
// pero ahí le va el crédito por si aparece.
function SiEsUnCorreo( sCorreo )  {
  var Posicion = sCorreo.indexOf('@')
  var Periodo = sCorreo.lastIndexOf('.')
  var Espacio = sCorreo.indexOf(' ')
  var Longitud = sCorreo.length - 1   // Arreglo desde 0 hasta length-1
  var NoValidos = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // Caracteres no válidos
  var Validos = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // Caracteres válidos
  var Final = /\.[a-zA-Z]{2,3}$/; // Final del Correo
  if ((Posicion < 3) || // El número de caracteres antes del signo @ debe ser mayor a 2
  (Periodo <= Posicion+1) || // Debe existir al menos un caracter válido entre la '@' y el '.'
  (Periodo == Longitud) || // Debe existir al menos un caracter válido después del '.'
  (Espacio != -1) || // No son permitidos los espacios en blanco
  (NoValidos.test(sCorreo)) || // No puede contener caracteres no válidos
  (!Validos.test(sCorreo)) || // Debe contener caracteres válidos
  (sCorreo.search(Final) == -1))  // Chequea el final del Correo (.com, .net, etc)
  {  // Si al menos una de las condiciones anteriores se cumplen
      return false;
  }
   return true;
}


var Open = ""
var Closed = ""
function ME(estado1,estado2){
  if (estado1.style.display=='none'){
	estado1.style.display='';
    estado2.src=Open.src;
  } else {
    estado1.style.display='none';
    estado2.src=Closed.src;
  }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MostrarEsconder(src) {
	if (src.style.display == 'none')
		src.style.display = 'block';
	else
		src.style.display = 'none';
}


// Mensajes en la Barra de Estado

function MM_displayStatusMsg(msgStr) { //v1.0
  status = msgStr;
  document.MM_returnValue = true;
}

// Cambio de Categoria
function cambiar_noticia() {
  valor = document.frm_select.category.value;
  if (valor == "") return false;
  location.href = "index.php?category=" + valor;
}

function cambiar_art() {
  valor = document.frm_select.category.value;
  
  if (valor == "") return false;
  location.href = "index.php?link=navegador&category=" + valor;
  
  //document.frm_select.submit();
}
function cambiar_doc() {
  valor = document.frm_select.tipo_doc.value;
  
  if (valor == "") return false;
  location.href = "index.php?link=navegador&tipo_doc=" + valor;
  
  //document.frm_select.submit();
}


function HabilitarEnviar() {
	var contrato = document.frm_reg.contrato;
	if(contrato[0].checked == true) 
	{
		document.frm_reg.frm_registro.disabled=false;
		return true;
	}
	else  
	{	
		document.frm_reg.frm_registro.disabled=true;
		return false;
	}
	//formulario.miradio[idradio].blur() 
}
function ValidarPregunta() {
	var pregunta = document.frm_reg.pregunta;
	var respuesta = document.frm_reg.respuesta;
	if(pregunta.selectedIndex != 0 && respuesta.value == "")   
	{
		alert("Usted no ha respondido la pregunta secreta");
	  	return false;
	}
	else if(pregunta.selectedIndex == 0 && respuesta.value != "")   
	{
		alert("Usted no ha seleccionado la pregunta secreta");
	  	return false;
	}
	else return true;
}
function ValidarReg() {
	if(ValidarPregunta() == true)
	{
		document.frm_reg.submit();
	}
	else 
	{	return false; }
}

// Encuestas

function ValidarEnc() {
  var respuesta = document.encuesta.resp;
  var longitud = document.encuesta.resp.length;
  var cont = 0;
  for (i = 0; i < longitud; i++) {
    if (document.encuesta.resp[i].checked) {
      cont = 0;
	  break;
    } else {
      cont++;
    }
  }

  if (cont != 0) {
    alert("Para poder votar en la encuesta, debe seleccionar una respuesta");
	return false;
  }
  document.encuesta.submit();  
}

function ValFecha() {
  var dia = document.FrmCalendario.d;
  var mes = document.FrmCalendario.m;
  var anio = document.FrmCalendario.a;
  
  // Los tres valores vacíos
  if (dia.value == "" && mes.value == "" && anio.value == "") {
	  alert("Usted no ha seleccionado una fecha");
	  return false;
  }

  // Alguno de los tres valores vacíos
  if (dia.value == "" || mes.value == "" || anio.value == "") {
	  alert("Fecha no válida");
	  return false;
  }

  // Meses de 30 días
  if (mes.value == 4 || mes.value == 6 || mes.value == 9 || mes.value == 11) {
    if (dia.value > 30) {
	  alert("Fecha no válida:\nEl mes seleccionado no tiene más de 30 días.");
	  dia.focus();
	  return false;
	}
  }
  
  // Asuntos de Febrero
  if (mes.value == 2) {
    var res = anio.value % 4;
	if (dia.value == 29 && res != 0) {
	  alert("Fecha no válida:\nFebrero no tiene 29 días en el año seleccionado.");
	  dia.focus();
	  return false;
	} else if (dia.value > 29) {
	  alert("Error:\nFecha no válida.");
	  dia.focus();
	  return false;
	}
  }

  document.FrmCalendario.submit();
  
}

function DarValores(d,m,a) {
	opener.FrmCalendario.d.value = d;
	opener.FrmCalendario.m.value = m;
	opener.FrmCalendario.a.value = a;
	opener.FrmCalendario.submit();
	self.close();
}

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_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_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); 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];}
}

// Desplegable Departamento Ingeniería Agrícola
function Mostrar(s) {
	ME(Mt,Mt);
	ME(Ot,Ot);
    M1.style.display = s;
	M2.style.display = s;
	M3.style.display = s;
	M4.style.display = s;
	M5.style.display = s;
}


function mOvr(src,clrOver) {
 if (!src.contains(event.fromElement)) {
	 src.style.cursor = 'hand';
	 src.bgColor = clrOver;
	}
 }
 
function mOvr2(src,clr,clrOver) {
 if (!src.contains(event.fromElement)) {
	 src.style.cursor = 'hand';
	 src.bgColor = clrOver;
	}
 if (src.contains(event.toElement)) {
  	 src.style.color = clr;
  }
}

function mOut(src,clrIn) {
	if (!src.contains(event.toElement)) {
	 src.style.cursor = 'default';
	 src.bgColor = clrIn;
	}
 }

function mOut2(src,clr,clrIn) {
  if (!src.contains(event.toElement)) {
	 src.style.cursor = 'default';
	 src.bgColor = clrIn;
	}
  if (src.contains(event.FromElement)) {
  	 src.style.color = clr;
  }
}


function mOut3(src,clr,clrIn) {
  if (!src.contains(event.toElement)) {
	 src.style.cursor = 'default';
	 src.bgColor = clrIn;
	 src.style.color = clr;
	}
}

function mClk(src) {
 if(event.srcElement.tagName=='TD')
	 src.children.tags('A')[0].click();
 }
 
function bordes(src, v) {
	if (v == 1) {
		if (src.contains(event.toElement)) {
			src.style.border = '1px solid #759775';
			src.style.color = '#003300';
		}
	} else {
		src.style.border = '';
		src.style.color = '#1F311F';
	}
}

function Restablecer() {
  var n = 7;
  var arrMenu = new Array(mf,mdpt,mdpr,mpub,msrv,minv,mext);
  for (var i=0; i<n; i++) {
    mOut3(arrMenu[i],'#FFFFFF','#547754');
  }
  return;
}

function VerMenus(menu, s) {
	menu.style.display = s;
}

function EsconderMenus() {
	menu_f.style.display = 'none';
	menu_dp.style.display = 'none';
	menu_pr.style.display = 'none';
	menu_pb.style.display = 'none';
	menu_s.style.display = 'none';
	menu_i.style.display = 'none';
	menu_e.style.display = 'none';
//	MM_swapImgRestore();
}

function Esconder(src) {
	src.style.display = 'none';
}

function AccOvr(id1,id2) {
	EsconderMenus();
	Restablecer();
	VerMenus(id1,'');
	mOvr2(id2,'#003300','#B3C6B3');
}

function MenuSecOut(src,flag) {
	setTimeout("EsconderMenus()",2000);
}

function AccOut(id1,id2) {
	mOut3(id2,'#FFFFFF','#547754');
}



function PMouseOver(src1,src2,clr) {
	if (src2.style.display != '') {
		src1.style.cursor = 'pointer';
		src1.bgColor = clr;
	}
}

function PMouseOut(src1,src2) {
	if (src2.style.display != '') {
		src1.bgColor = '';
		src1.style.borderBottom = '1px solid #759775';
	}
}

// Validación de fechas genéricas

function SiEsUnaFecha(dia, mes, anio) {
  
  // Los tres valores vacíos
  if (dia.value == "" && mes.value == "" && anio.value == "") {
	  alert("Usted no ha seleccionado una fecha");
	  MostrarPestana(dp,p1,'#EEEEEE');
	  EsconderPestanas(ip,il,ig,rf,p2,p3,p4,p5);
	  dia.focus();
	  return false;
  }

  // Alguno de los tres valores vacíos
  if (dia.value == "" || mes.value == "" || anio.value == "") {
	  alert("Fecha no válida");
	  MostrarPestana(dp,p1,'#EEEEEE');
	  EsconderPestanas(ip,il,ig,rf,p2,p3,p4,p5);
	  dia.focus();
	  return false;
  }

  // Meses de 30 días
  if (mes.value == 4 || mes.value == 6 || mes.value == 9 || mes.value == 11) {
    if (dia.value > 30) {
	  alert("Fecha no válida:\nEl mes seleccionado no tiene más de 30 días.");
	  MostrarPestana(dp,p1,'#EEEEEE');
	  EsconderPestanas(ip,il,ig,rf,p2,p3,p4,p5);
	  dia.focus();
	  return false;
	}
  }
  
  // Asuntos de Febrero
  if (mes.value == 2) {
    var res = anio.value % 4;
	if (dia.value == 29 && res != 0) {
	  alert("Fecha no válida:\nFebrero no tiene 29 días en el año seleccionado.");
	  MostrarPestana(dp,p1,'#EEEEEE');
  	  EsconderPestanas(ip,il,ig,rf,p2,p3,p4,p5);
	  dia.focus();
	  return false;
	} else if (dia.value > 29) {
	  alert("Error:\nFecha no válida.");
	  MostrarPestana(dp,p1,'#EEEEEE');
	  EsconderPestanas(ip,il,ig,rf,p2,p3,p4,p5);
	  dia.focus();
	  return false;
	}
  }
  return true;
}


// Panel de Administración

function admValFecha(dia, mes, anio) {
  
  // Los tres valores vacíos
  if (dia.value == "" && mes.value == "" && anio.value == "") {
	  alert("Usted no ha seleccionado una fecha");
	  dia.focus();
	  return false;
  }

  // Alguno de los tres valores vacíos
  if (dia.value == "" || mes.value == "" || anio.value == "") {
	  alert("Fecha no válida");
	  dia.focus();
	  return false;
  }

  // Meses de 30 días
  if (mes.value == 4 || mes.value == 6 || mes.value == 9 || mes.value == 11) {
    if (dia.value > 30) {
	  alert("Fecha no válida:\nEl mes seleccionado no tiene más de 30 días.");
	  dia.focus();
	  return false;
	}
  }
  
  // Asuntos de Febrero
  if (mes.value == 2) {
    var res = anio.value % 4;
	if (dia.value == 29 && res != 0) {
	  alert("Fecha no válida:\nFebrero no tiene 29 días en el año seleccionado.");
	  dia.focus();
	  return false;
	} else if (dia.value > 29) {
	  alert("Error:\nFecha no válida.");
	  dia.focus();
	  return false;
	}
  }
  
  return true;
  
}



function admValEncuesta() {

	var titulo = document.admEncuesta.titulo;
	var pregunta = document.admEncuesta.pregunta;
	var dia = document.admEncuesta.d;
	var mes = document.admEncuesta.m;
	var anio = document.admEncuesta.a;
	var resp1 = document.admEncuesta.resp1;
	var resp2 = document.admEncuesta.resp2;
	
	if (titulo.value == "") {
		alert('Por favor ingrese el título de la encuesta');
		titulo.focus();
		return false;
	}
	
	if (pregunta.value == "") {
		alert('Por favor ingrese la pregunta de la encuesta');
		pregunta.focus();
		return false;
	}
	
	if (resp1.value == "") {
		alert('Por favor ingrese la primera respuesta de la encuesta');
		resp1.focus();
		return false;
	}
	if (resp2.value == "") {
		alert('Por favor ingrese la segunda respuesta de la encuesta');
		resp2.focus();
		return false;
	}
	
	if (dia.value == "" || mes.value == "" || anio.value == "") {
		alert('Fecha no válida');
		return false;
	}

	if (!admValFecha(dia, mes, anio)) return false;
	
	return confirm('¿Desea continuar?');
	document.admEncuesta.submit();
}



function admValNoticia() {

	var titulo = document.admNoticia.titulo;
	var descripcion = document.admNoticia.descripcion;
	var contenido = document.admNoticia.contenido;
	var dia = document.admNoticia.d;
	var mes = document.admNoticia.m;
	var anio = document.admNoticia.a;
	var lecturas = document.admNoticia.lecturas;
	var cat = document.admNoticia.cat;
	var resaltar = document.admNoticia.resaltar;
	
	if (titulo.value == "") {
		alert('Por favor ingrese el título de la noticia');
		titulo.focus();
		return false;
	}
	
	if (descripcion.value == "") {
		alert('Por favor ingrese un subtitulo descriptivo de la noticia');
		descripcion.focus();
		return false;
	}
	
	if (contenido.value == "") {
		alert('Por favor ingrese el contenido de la noticia');
		contenido.focus();
		return false;
	}
	
	if (dia.value == "" || mes.value == "" || anio.value == "") {
		alert('Fecha no válida');
		return false;
	}

	if (!admValFecha(dia, mes, anio)) return false;
	
	if (lecturas.value == "") {
		lecturas.value = '0';
	} else if (isNaN(lecturas.value)) {
		alert('El valor de las lecturas debe ser numérico');
		lecturas.focus();
		return false;
	}
	
	return confirm('¿Desea continuar?');
	document.admNoticia.submit();
}

// Menús

function MostrarMenu(menu, x, y, nom, img) {
	if (window.ActiveMenu && window.ActiveMenu.Menu.hideOnMouseOut) MM_startTimeout();
	MM_showMenu(menu,x,y,null,nom);
	MM_swapImage(nom,'',img,1);
}

function EsconderMenu() {	
	if (window.ActiveMenu && window.ActiveMenu.Menu.hideOnMouseOut) {
		MM_startTimeout();
	} else if (!window.ActiveMenu) {
		MM_swapImgRestore();
	}
}

