function arreglarMenuExplorer()
{
	if(window.navigator.appName=="Microsoft Internet Explorer")
	{
		var arreglo=document.getElementsByTagName('P');
		for(i=0;i<arreglo.length;i++)
		{
		arreglo[i].firstChild.style.width='165 px';
		};
	};
}
function validarFechas()
{
  
  document.write(hola); 
 
}

function elimuser(form)
{
	var ok=confirm("Realmente desea eliminar al usuario?");
	if(ok)
	{
	   document.getElementById(form).submit();
  
	}
}
function elimclie(form)
{
	var ok=confirm("Realmente desea eliminar al usuario?");
	if(ok)
	{
	   document.getElementById(form).submit();
  
	}
}

function edituser(id)
{
  var path="./edituser.php?idUser="+id;
  window.open(path,"","toolbar=no,scrollbars=1,resizable=1,fullscreen=no");
}

function listUserType()
{
	var ventana=window.open('userstype.php','','width=300,height=150');
}

function listAutores(idLibro)
{
	var url="autores.php?idLibro="+idLibro;
	var ventana=window.open(url,'','width=300,height=400');
}

function listPerm(idTipoPersona,idPersona)
{
	var url="userperm.php?idPersona="+idPersona+"&idTipoPersona="+idTipoPersona;
	var ventana=window.open(url,'','width=310,height=505,scrollbars=yes');
}

function addUser()
{
	parent['body'].document.location="adduser.php";
}

function validarNumeros (e)
{

	var key;
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		key = event.keyCode;	
	}
	else
	{
		key = e.which;
	}
	return ((key==8) || (key==0) || (key >= 48 && key <= 57) );
}

function validarTexto(e)
{
	var key;	
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		key = event.keyCode;
	}
	else
	{
		key = e.which;
	}
	return ((key <= 48 || key >= 57)&& (key!=13));
}

function elimproyecto(id)
{
	var ok=confirm("Realmente desea eliminar el proyecto?");
	if(ok)
	{
	 document.location="index.php?tipo=configuracion-eliminarproyecto-"+id;
	return true;
	}
}

function editproyect(id)
{
	parent['body'].document.location="editproyect.php?idProy="+id;
	return false;
}

function addboletin()
{
	parent['body'].document.location="addboletin.php";
	return false;
}

function elimboletin(id,boletin,elibol)
{
	var ok=confirm("Realmente desea eliminar el boletin: "+boletin+"?");
	if(ok)
	{
	parent['body'].document.location="elimboletin.php?idBol="+id+"&elibol="+elibol;
	}
}

function addProyect()
{
	parent['body'].document.location="addproyect.php";
	return false;
}


function elimarchivo(id,archivo,eliarchive,idCurso,materia,anio,nivel)
{
	var ok=confirm("Realmente desea eliminar el archivo: "+archivo+"?");
	if(ok)
	{
	parent['body'].document.location="elimarchivo.php?idArch="+id+"&eliarchive="+eliarchive+"&idCurso="+idCurso+"&materia="+materia+"&anio="+anio+"&nivel="+nivel;
	}
}

function validarnueboletin()
{
	var fecha = document.getElementById("fechaboletin");
	var nombre = document.getElementById("nombre");
	var archivo = document.getElementById("sourceFile");
	
	if (fecha.value=="" || nombre.value=="" || archivo.value=="" )
	{
		window.alert("Faltan establecer datos.");
		return false;
	}
	else 
	{
		return true;
	}
}

/////////////////////////////////////////////////
////Variable declarada para controlar///////////
////que un campo no tenga espacios en blanco///
var whitespace = " \t\n\r";
/////////////////////////////////////////////

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isWhitespace (s)
{   var i;

    if (isEmpty(s)) return true;
    for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }
    // All characters are whitespace.
    return true;
}

function validarCamposGenerico()
{
	args=validarCamposGenerico.arguments;
	i=0;
	ok=false;
	while(i<args.length)
	{
		if(isWhitespace(document.getElementById(args[i]).value))
		{
		ok=true;
		foco=document.getElementById(args[i]);
		break;
		}
		i++;
	}

	if(ok)
	{
		alert("Por favor ingrese todos los campos\r\n\r\nNo deje espacios en blanco");
		foco.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function abrirVentana()
{
	var ancho = 800-(screen.width/2);
	var alto = 600-(screen.height/2);
	var configuracion ='width=350,height=200,top='+alto+',left='+ancho+',resizable=no';
	ventana=window.open('','',configuracion);
	encabezado="<html><head><title>Recordatorio</title><link rel=\"stylesheet\" href=\"estilos/recordapass.css\" type=\"text/css\"></link><script>function validarCampos(){if(document.getElementById('username').value==''){alert('Complete su nombre de usuario');return false}else{return true;}}</script></head><body class=\"bodymenurecordapass\">";
	form="<form action=\"recordarpass.php\" method=\"post\" onsubmit=\"return validarCampos();\"><label>Nombre de usuario</label><br /><input type=\"text\" name=\"username\" id=\"username\" /><br /><input type=\"submit\" value=\"Aceptar\" class=\"okbutton\"></form>"
	fin="</body>";
	ventana.document.write(encabezado);
	ventana.document.write(form);
	ventana.document.write(fin);
}

function isEmailAddress(theElement)
{
var s = document.getElementById(theElement).value;
var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
if (s.length == 0 ) return true;
if (filter.test(s))
return true;
else
alert("Ingrese una dirección de correo válida");
document.getElementById(theElement).focus();
return false;
}

function elimnormativa(idNormativa,normativa,eliNorm)
{
  var ok=confirm("Realmente desea eliminar el archivo:"+normativa+"?");
	if(ok)
	{
	    document.location="index.php?tipo=configuracion-eliminarnormativa-"+idNormativa+"&eliNorm="+eliNorm;
	}

}

function elimtaller(id)
{
	var ok=confirm("Realmente desea eliminar el taller");
	if(ok)
	{
	 document.location="index.php?tipo=configuracion-eliminartaller-"+id;
	return true;
	}
}

function addTaller()
{
	parent['body'].document.location="addtaller.php";
	return false;
}


function edittaller(id)
{
	parent['body'].document.location="edittaller.php?idTall="+id;
	return false;
}


function addBook()
{
	parent['body'].document.location="addbook.php";
	return false;
}

function editbook(id)
{
	parent['body'].document.location="editbook.php?idBook="+id;
	return false;
}

function elimbook(id,book)
{
	var ok=confirm("Realmente desea eliminar el libro: "+book+"?");
	if(ok)
	{
	parent['body'].document.location="elimlibro.php?idBook="+id;
	return true;
	}
}

function addTema()
{
	parent['body'].document.location="addtema.php";
	return false;
}

function editTema(id)
{
	parent['body'].document.location="edittema.php?idTema="+id;
	return false;
}

function elimTema(id,tema)
{
	var ok=confirm("Si elimina un tema se eliminaran todos los libros asociados al mismo.\r\nRealmente desea eliminar el tema: "+tema+"?");
	if(ok)
	{
	parent['body'].document.location="elimtema.php?idTema="+id;
	return true;
	}
}


function editLink(id)
{
	parent['body'].document.location="editlink.php?idLink="+id;
	return false;
}

function elimLink(id,link)
{
	var ok=confirm("Realmente desea eliminar el link: "+link+"?");
	if(ok)
	{
	parent['body'].document.location="elimlink.php?idLink="+id;
	return true;
	}
}

function addLink()
{
	parent['body'].document.location="addlink.php";
	return false;
}


function addAutor()
{
	parent['body'].document.location="addautor.php";
	return false;
}

function editAutor(id)
{
	parent['body'].document.location="editautor.php?idAutor="+id;
	return false;
}

function elimAutor(id,autor)
{
	var ok=confirm("Se eliminara el autor seleccionado en cada libro asociado al mismo.\r\nRealmente desea eliminar el autor: "+autor+"?");
	if(ok)
	{
	parent['body'].document.location="elimautor.php?idAutor="+id;
	return true;
	}
	 
}
function abrirVentanaUser ()
{
    window.open("./adduser.php","","toolbar=no,scrollbars=1,resizable=1,fullscreen=no");return true;
}    

function abrirVentanaProducto ()
{
    window.open("./addproducto.php","","toolbar=no,scrollbars=1,resizable=1,fullscreen=no");return true;
}    

function validarHora(tipo)
  {
    var ok=true;
    var hora=document.getElementById(tipo).value;
    if(hora.indexOf(":")!=-1)
    {
     if (hora=="")
     {
        alert('se debe ingresar un horario de ' + tipo);
        return false;
     }
      var strH=hora.substr(0,(hora.indexOf(':')));
      var strM=hora.substr((hora.indexOf(':'))+1,hora.length);
      if ((parseInt(strH)>23) || (parseInt(strH)<0))
     {
       ok=false;
       alert('la hora de '+ tipo +' ingresada es incorrecta!' );    
     }
     if ((parseInt(strM)>59) || (parseInt(strM)<0))
     {
       ok=false;
       alert('Los minutos ingresados en la hora de '+tipo+' son incorrectos! ');      
     }  
     return ok;
    }
    else
      {
        ok=false;
        alert("el formato de la hora ingresada es incorrecto(hh:mm)");  
      }
    return ok;
  }
  
  function saltarConOption(x)
{
	document.location= x;
}
  
