var nav4 = window.Event ? true : false;
var enlace=0;
var cierra=0;
var MAX=180;
var count;
var count2;
function ingresarcurso(cod){
document.form1.cod.value=cod;	  
document.form1.action='contenido.php';
document.form1.submit();
}
function ingresarinfo(cod){
document.form1.cod.value=cod;	  
document.form1.action='informacion.php';
document.form1.submit();
}
function ingresarinfotext(cod){
document.form1.cod.value=cod;	  
document.form1.action='informaciontxt.php';
document.form1.submit();
}
function ingresardetalle(cod,op){
document.form1.cod.value=cod;	  
document.form1.op.value=op;	  
document.form1.action='detalle.php';
document.form1.submit();
}
function ingresarmod(cod){
document.form1.cod.value=cod;	  
document.form1.action='modulo.php';
document.form1.submit();
}
function ingresarlec(cod,mod){
document.form1.cod.value=cod;	  
document.form1.mod.value=mod;	  
document.form1.action='leccion.php';
document.form1.submit();
}
function ingresarmodulo(cod){
document.form1.cod.value=cod;	  
document.form1.action='informacionmod.php';
document.form1.submit();
}
function ingresarextra(cod){
document.form1.cod.value=cod;	  
document.form1.action='infoextrasmod.php';
document.form1.submit();
}
function ingresardetallemod(cod,op){
document.form1.cod.value=cod;	  
document.form1.op.value=op;	  
window.open("detallemod.php?cod="+cod+"&op="+op,"ventana1","width=760,height=600,top=0,left=50,scrollbars=yes,location=0,resizable=yes");
//		document.form1.submit();
}
//-----------------------------------------------------
function counter()
{
var str = new String(document.form1.enunciado.value);
count = MAX - str.length;
var antstr = str.substring(0,(MAX))
if (str.length <= MAX) {
document.all.divCount.innerHTML=count;
} else {
alert("Se supero el numero de caracteres permitidos")
document.form1.enunciado.value=antstr
document.form1.enunciado.focus();
}
}
//-----------------------------------------------------
function counter2()
{
var str = new String(document.form1.sustento.value);
count2 = MAX - str.length;
var antstr = str.substring(0,(MAX))
if (str.length <= MAX) {
document.all.divCount2.innerHTML=count2;
} else {
alert("Se supero el numero de caracteres permitidos")
document.form1.sustento.value=antstr
document.form1.sustento.focus();
}
}
//-----------------------------------------------------
function ValidarCorreo1(valor) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
rpt = 1;
} else {
rpt = -1;
}
return rpt;
}
//-----------------------------------------------------
function validadoc(son){
if (son==1) {
var er_cp = /(^([0-9]{8,8})|^)$/			//5 numeros o cadena vacia
var rpta='1';
//comprueba campo codigo postal
if(!er_cp.test(document.form1.nrodoc.value)) { 
rpta='-1'
}  
} else if (son==2) {
var er_cp = /(^([0-9]{6,6})|^)$/		//5 numeros o cadena vacia
var rpta='1';
//comprueba campo codigo postal
if(!er_cp.test(document.form1.nrodoc.value)) { 
rpta='-1'
}  
}
return rpta
}
//-----------------------------------------------------
function acceptNum2(evt){ 
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57 
var key = nav4 ? evt.which : evt.keyCode; 
return (key <= 13 || key == 46 || (key >= 48 && key <= 57));
}
//-----------------------------------------------------
function acceptNum(evt){ 
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57 
var key = nav4 ? evt.which : evt.keyCode; 
return (key <= 13 || (key >= 48 && key <= 57));
}
//-----------------------------------------------------
function validacion3() {
var er_cp = /(^([0-9]{5,5})|^)$/				//5 numeros o cadena vacia
var rpta='1';
//comprueba campo codigo postal
if(!er_cp.test(document.form1.cmp.value)) { 
alert('Mensaje de alerta')
document.form1.cmp.focus();
rpta='-1'
}  
return rpta
}
//-----------------------------------------------------
function buscausuario(){
cierra=1;
estado=1;
if ( document.form1.user.value == '' && estado == 1) {
alert("Ingrese su número de Documento de Identidad");
estado = -1;
document.form1.user.focus();
}
if ( document.form1.pwd.value == '' && estado == 1) {
alert("Ingrese su Contraseña");
estado = -1;
document.form1.pwd.focus();
}
if (estado== 1) {
document.form1.action='validarusuario.php';	  
document.form1.submit()
}
}
//-----------------------------------------------------
function buscausuario2(){
cierra=1;
estado=1;
if ( document.formlogin.user.value == '' && estado == 1) {
alert("Ingrese Nombre de usuario / Documento de Identidad");
estado = -1;
document.formlogin.user.focus();
}
if ( document.formlogin.pwd.value == '' && estado == 1) {
alert("Ingrese su Contraseña");
estado = -1;
document.formlogin.pwd.focus();
}
if (estado== 1) {
document.formlogin.action='admcursos/validarusuario.php';	  
document.formlogin.submit()
}
}
//-----------------------------------------------------
function admpost(cod){
document.form1.cod.value=cod;	  
document.form1.action='doc_listapost.php';	  
document.form1.submit();
}
function okpost(cod){
document.form1.cod.value=cod;	  
document.form1.action='doc_listaaceptados.php';	  
document.form1.submit();
}
function okcompost(cod){
document.form1.cod.value=cod;	  
document.form1.action='doc_listaaceptadoscom.php';	  
document.form1.submit();
}
function kopost(cod){
document.form1.cod.value=cod;	  
document.form1.action='doc_listarechazados.php';	  
document.form1.submit();
}
function aceptapost(dato1,user,hacer,cod){
document.form2.cod.value=cod;	  
document.form2.aux.value=dato1;
document.form2.accion.value=hacer;
document.form2.usuario.value=user;
document.form2.action='doc_aceptarpost.php'; 
document.form2.submit();
}
function enviamail(dato1,user,cod){
document.form2.cod.value=cod;	  
document.form2.aux.value=dato1;
document.form2.usuario.value=user;
document.form2.action='doc_enviamail.php'; 
document.form2.submit();
}
//-----------------------------------------------------
function admpwd(){
document.form1.action='doc_ingresopwd.php';	  
document.form1.submit();
}
function adminpwd(){
estado = 1;
if ( document.form1.oldpwd.value=='' && estado == 1) {
alert("Ingrese la contraseña anterior");
estado = -1;
document.form1.oldpwd.focus();
}
if ( ( document.form1.npwd.value != document.form1.cnpwd.value || document.form1.npwd.value=='' ) && estado == 1) {
alert("Las contraseñas no coinciden o son vacias");
estado = -1;
document.form1.npwd.focus();
}
if ( estado == 1) {
document.form1.action='doc_ingresarpwd.php';	  
document.form1.submit();
}
}
//-----------------------------------------------------
function alumnopwd(){
estado = 1;
if ( ( document.form1.npwd.value != document.form1.cnpwd.value || document.form1.npwd.value=='' ) && estado == 1) {
alert("Las contraseñas no coinciden o son vacias");
estado = -1;
document.form1.npwd.focus();
}
if ( estado == 1) {
document.form1.action='cambiarpwd.php';	  
document.form1.submit();
}
}
//-----------------------------------------------------
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];}
}
//-->
