function validanumero(id,num){
if (!/^([0-9])*$/.test(num))
	{
	alert("El numero  " + num + " no esta escrito correctamente.");
	document.getElementById(id).value='';
	document.getElementById(id).focus();
	}
}

function validausuario(id,num){
if (!/^([0-9])*$/.test(num))
	{
	alert("El usuario" + num + " no esta escrito correctamente.");
	document.getElementById(id).value='';
	document.getElementById(id).focus();
	}
}

function iniload(){
	div = document.getElementById('cargando');
	div.style.display ='';
}
function limpiar(){
	document.getElementById('tb_espepa').value='';
	//document.getElementById('tb_espeas').value='';
	document.getElementById('tb_dat').value='';
	document.getElementById('tb_ndep').value='';
	document.getElementById('tb_npro').value='';
	document.getElementById('tb_ndis').value='';
	document.getElementById('tb_dep').value='';
	document.getElementById('tb_pro').value='';
	document.getElementById('tb_dis').value='';
	document.getElementById('tb_miemes').value='';
	document.getElementById('tb_dvot').value='';
	document.getElementById('tb_cvot').value='';
	document.getElementById('tb_grvo').value='';
	document.getElementById('tb_mevo').value='';
	

}

function finload(){
div = document.getElementById('cargando');
div.style.display ='none';
}

function openmulta()
{

		var cadena='http://www.web.onpe.gob.pe/omisos/e_omisos_web.php';

		if (window.showModalDialog) {
			window.showModalDialog(cadena,"name","dialogWidth:700px;dialogHeight:380px");
		} else {
			window.open(cadena,'name','width=700px,height=380px,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no ,modal=yes');
		}
}

function openmiembro(dni)
{
		var cadena='http://www.infogob.com.pe/eg_2011/DatoHandler.ashx?IdDni='+dni;

		if (window.showModalDialog) {
			window.showModalDialog(cadena,"name","dialogWidth:810px;dialogHeight:200px");
		} else {
			window.open(cadena,'name','width=810px,height=200px,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no ,modal=yes');
		}
		
}


function verperso(tip,mes) {	
	var cadena='intra/poppersonero.php?tip='+tip+'&mes='+mes;
	
		if (window.showModalDialog) {
			window.showModalDialog(cadena,"name","dialogWidth:770px;dialogHeight:280px");
		} else {
			window.open(cadena,'name','width=770px,height=280px,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');
		}
}

function asiperso(mes)
{
	var dni=prompt("Ingrese el dni: ");
	if (dni!=null && dni!=""){
		location.href='http://www.fonavistasdelperu.org/fdp_sis/?con=pdn&mes='+mes+'&dni='+dni;
	}else{
		alert('Error de ingreso');
	}
}

function asignaperso(tip,ope,dat,dni,mes,idm){
	 if(confirm('Esta seguro de registrar al Sr(a):\n \n'+dat+'\n\ncomo personero.')) { 

		var cadena='intra/cardatper.php?tip='+tip+'&ope='+ope+'&dat='+dat+'&dni='+dni+'&mes='+mes+'&idm='+idm;

		if (window.showModalDialog) {
			window.showModalDialog(cadena,"name","dialogWidth:430px;dialogHeight:380px");
		} else {
			window.open(cadena,'name','width=430px,height=380px,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');
		}
	 }
}


function anularper(ope,mes){
if(mes!=''){
			
			 if(confirm('Esta seguro de anular personero')) { 
					CreateXmlHttp();
	
				var ajaxRequest = 'intra/recoger.php';
				var ajaxPara='o=14&ope='+ope+'&mes='+mes;
				
				
				
				xmlHttp.open("POST", ajaxRequest, true);
				xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				xmlHttp.setRequestHeader("Content-length", ajaxPara.length);
				xmlHttp.setRequestHeader("Connection", "close");
				xmlHttp.onreadystatechange = function(){
					
				if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
					alert("Se anulo correctamente al personero");
				}
				}
				xmlHttp.send(ajaxPara);
				}
			}
			
}

function generarcrede(ope,mes,tip){
		if(mes!=''){
				
			 if(confirm('Esta seguro de generar la credencial para la mesa de votacion'+mes)) { 
				var cadena='/fdp_sis/intra/pdfcredencial.php?ope='+ope+'&mes='+mes+'&tip='+tip+'&formato=.pdf';
				window.location.replace(cadena);
			}
		 }
}



function checkear(f)	{
alert('Revisando');
	
	function no_prever() {
			alert("El fichero seleccionado no es válido...");
		}
	
	function prever() {
		formfoto.submit();

				
		}

	(/\.(gif|jpg|png)$/i.test(f.value)) ? prever() : no_prever();
}

function actonline()
{
/*
CreateXmlHttp();
	ajaxRequest = 'intra/recoger.php';
	ajaxPara='o=15';
	xmlHttp.open("POST", ajaxRequest, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", ajaxPara.length);
	xmlHttp.setRequestHeader("Connection", "close");
				
				
				xmlHttp.onreadystatechange = function()
				{
					if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
						{
								var usuario=xmlHttp.responseXML.getElementsByTagName('usuario');
								var thtml;
								thtml=thtml+'<h3>Hay '+usuario.length+' usuarios conectados al sistema </h3>';
								thtml=thtml+'<table  border="0">';
								
								for(i=0;i<usuario.length;i++)
								{
									var usu=usuario[i];
								
									try
									{var nic_usu = usu.getElementsByTagName("nic_usu")[0].firstChild.nodeValue;}
									catch(err)
									{var nic_usu='';}
									
										thtml=thtml+'<tr><td width="18" align="center" valign="baseline"><div align="center"><img src="img/conec.png">&nbsp;</div></td>'
										thtml=thtml+'<td width="180"><div align="left"><a href="?con=cma&mail='+nic_usu+'@fonavistasdelperu.com">'+nic_usu+'</a></div></td></tr>'
								}
									thtml=thtml+'</table>';
									thtml=thtml.replace('undefined','')
									document.getElementById('conectados').innerHTML=thtml;
									thtml='';
						}
				}
				xmlHttp.send(ajaxPara);
				*/
}

function actest(tip)
{
/*
	CreateXmlHttp();
	
	var ajaxRequest = 'intra/estado.php';
	var ajaxPara='t='+tip;
	xmlHttp.open("POST", ajaxRequest, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", ajaxPara.length);
	xmlHttp.setRequestHeader("Connection", "close");	
	
	xmlHttp.onreadystatechange = function(){}
	xmlHttp.send(ajaxPara);
	
	actonline();
	*/
}

function online()
{
	actest(1);
	setInterval('actest(1)',180000);
}


function offline()
{
	actest(2);
}


