<?php 
session_start();
include('../cfg/cfg.php');
include('../cfg/res.php');
include('php_gene1.php');
include('php_session.php');

if(empty($user_tipo) || !isset($user_tipo))
{
	die('<a href="../salir.php">SU SESSION EXPIRO.</a>');
}

// $user_tipo=$user_tipo;
$pagina_descri='ENTIDAD ';
$pagina_nivel;
$pagina_tipo;

$enti_codigo=$_GET['idx'];
$persona=0;
if(substr($enti_codigo,0,2)=='99'){$persona=1;}
if(substr($enti_codigo,2,1)<='6'){$persona=1;}
$user_cedula=r_fiel('user',$user_codigo,'cedula');
// echo '*/*/*'.$user_tipo.$user_cedula.$user_codigo;

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="http://vcrxol.com/_lib/vrgets.css">  
  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title><?php echo $empr_nombre .' - ' . $_SESSION['user_vcrx_descri'];?></title>
<link rel="stylesheet" href="http://vcrxol.com/css/ambiente.css"  type="text/css" />
<script type="text/javascript" src="../js/jquery-1.11.1.js"></script>
<script type="text/javascript" src="../js/busca_maes.js"></script>
<style type="text/css">
body{background:#ffffff;}
.dper_txt{border:solid 1px #000000; border-radius:2px; padding:2px; margin:2px;}
.txt_adr{ width:100%;}
</style>
<script type="text/javascript">
<?php include('../../_js/busca_maes3.js');?>
<?php include('../../_js/lista_maes3.js');?>
<?php include('../../_js/fecha_format.js');?>

	
	
	
function onload()
{
	document.getElementById('dper_txt_ci').disabled='disabled';	
	document.getElementById('dper_txt_ci').tabindex='-1';	
<?php if (isset($_GET['idx']) && !empty($_GET['idx'])){?>	
			document.getElementById('dper_txt_ci').value='<?php echo $_GET['idx']; ?>';	
<?php } ?>	

<?php if (mb_stristr('admi.sist.supe',strtolower($user_tipo))){?>	
<?php }else{ ?>	
			document.getElementById('dper_txt_ci').value='<?php echo $user_cedula;  ?>';	
			document.getElementById('dper_txt_ci').disabled='disabled';	
			document.getElementById('dper_txt_ci').tabindex='-1';	
			document.getElementById('dper_txt_ci').onblur='';	
			document.getElementById('dper_txt_ref_btn').onclick='';	
<?php } ?>	
 _carga(document.getElementById('dper_txt_ci').value,'1');

}
	
function numbloq(e,e2)
{
	var xnumbloq=document.getElementById(e2).value.toUpperCase();
		xvnum='0123456789';
		xnum='';
		for (i=0; i<xnumbloq.length;i++)
			{
				xcar=xnumbloq.substring(i,i+1);	
				if (xvnum.indexOf(xcar)>=0){xnum+=xcar;}
			}
		 	document.getElementById(e2).value=xnum;
}
	
	
	function _pais(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('pais',document.getElementById('pais').value,'pais','pais_descri','');
		
	}
}

function _ciudad(e)
{
console.log(e.keyCode);
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('cdad',document.getElementById('ciudad').value,'ciudad','ciudad_descri','');
	}
}
function _cdad(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{
		busca_maes2('cdad',document.getElementById('cdad').value,'cdad','cdad_decri','');
		
	}
}


function _referidox(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{busca_maes2('enti',document.getElementById('dper_txt_ref').value,'dper_txt_ref','dper_txt_ref_descri','');}
}

function _zsub(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{busca_maes2('zsub',document.getElementById('dper_txt_zsub').value,'dper_txt_zsub','dper_txt_zsub_descri','');}
}

function _csub(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{busca_maes2('csub',document.getElementById('dper_txt_csub').value,'dper_txt_csub','dper_txt_csub_descri','');}
}

function _vndd(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{busca_maes2('vndd',document.getElementById('dper_txt_vndd').value,'dper_txt_vndd','dper_txt_vndd_descri','');}
}

function _rcdd(e)
{
	if(e.keyCode==9 || e.keyCode==13)
	{busca_maes2('rcdd',document.getElementById('dper_txt_rcdd').value,'dper_txt_rcdd','dper_txt_rcdd_descri','');}
}

	
function valida_dper()
{ 

  var n1=document.getElementById('dper_txt_n1').value;
	var n2=document.getElementById('dper_txt_n2').value;
	var a1=document.getElementById('dper_txt_a1').value;
	var a2=document.getElementById('dper_txt_a2').value;
	var matriz=document.getElementById('dper_txt_matriz').value;
	var parroq=document.getElementById('dper_txt_parroq').value;
	var calle1=document.getElementById('dper_txt_calle1').value;
	var calle2=document.getElementById('dper_txt_calle2').value;
	var calle3=document.getElementById('dper_txt_calle3').value;
	var callen=document.getElementById('dper_txt_callen').value;
	var telefono=document.getElementById('dper_txt_telefono').value;
	var email=document.getElementById('dper_txt_email').value;
	var emailce=document.getElementById('dper_txt_emailce').value;
	var c1=document.getElementById('c1').value;
 	var c2=document.getElementById('c2').value;
	var c3=document.getElementById('c3').value;
	var cn=document.getElementById('cn').value;
	var ref=document.getElementById('dper_txt_ref').value;
	var e1=document.getElementById('dper_txt_e1').value.toLowerCase().trim().replace('  ',' ');
 	var t1=document.getElementById('dper_txt_t1').value.trim().replace('  ',' ');
	var ciudad=document.getElementById('ciudad').value;
// 	var pais=document.getElementById('pais').value;
 	var nik=document.getElementById('dper_txt_nik').value;
 	var struc=document.getElementById('dper_txt_struc').value;
 	var pspt=document.getElementById('dper_txt_pspt').value;
 	var idex=document.getElementById('dper_txt_idex').value;
 	var pais=document.getElementById('dper_txt_pais').value;
 	var ciudad=document.getElementById('dper_txt_ciudad').value;
 	var provincia=document.getElementById('dper_txt_provincia').value;
 	var conadis=document.getElementById('dper_txt_conadis').value;
 	var factura=document.getElementById('dper_txt_factura').value;
 	var sexo=document.getElementById('dper_txt_sexo').value;
	var fn=document.getElementById('dper_txt_fn').value;
	var fi=document.getElementById('dper_txt_fi').value;
	var rs=document.getElementById('dper_txt_rs').value;
	var nc=document.getElementById('dper_txt_nc').value;

	var cix=document.getElementById('dper_txt_ci').value.trim().replace('  ',' ');
	var valx = cix.substring(2,3);
// 	n1=n1.trim();
	
    if(n1.length<2 && valx < 6)
	{
		document.getElementById('dper_txt_n1_err').innerHTML='*Obligatorio';
		return false;
	}
	else
	{
		document.getElementById('dper_txt_n1_err').innerHTML='';
	}

	a1=a1.trim();
	if(a1.length<2 && valx < 6)
	{
		document.getElementById('dper_txt_a1_err').innerHTML='*Obligatorio';
		return false;
	}
	else
	{
		document.getElementById('dper_txt_a1_err').innerHTML='';
	}

	c1=c1.trim();
	if(c1.length<2)
	{
		c1='-';
		//document.getElementById('dper_err_c1').innerHTML='*Obligatorio';
		//return false;
	}
	else
	{
// 		document.getElementById('dper_err_c1').innerHTML='';
	}
	c2=c2.trim();
	if(c2.length<1)
	{
		c2='-';
		//document.getElementById('dper_err_c2').innerHTML='*Obligatorio';
		//return false;
	}
	else
	{
// 		document.getElementById('dper_err_c2').innerHTML='';
	}

	c3=c3.trim();
	if(c3.length<1)
	{
		c3='-';
		//document.getElementById('dper_err_c3').innerHTML='*Obligatorio';
		//return false;
	}
	else
	{
// 		document.getElementById('dper_err_c3').innerHTML='';
	}
	
	e1=e1.trim();
	if(e1.length<2)
	{
		e1=n1+'@'+a1+'.com';
		document.getElementById('dper_txt_e1').value=e1;
		//document.getElementById('dper_err_e1').innerHTML='*Obligatorio';
		//return false;
	}
	else
	{
// 		document.getElementById('dper_err_e1').innerHTML='';
	}
	t1=t1.trim();
	if(t1.length<2)
	{
		t1='000000';
		document.getElementById('dper_txt_t1').value=t1;
		//document.getElementById('dper_err_t1').innerHTML='*Obligatorio';
		//return false;
	}
	else
	{
// 		document.getElementById('dper_err_e1').innerHTML='';
	}
	
	nik=nik.trim();
	if(nik.length!=0)
	{
		//document.getElementById('dper_err_t1').innerHTML='*Obligatorio';
		//return false;
	}
}


function _limpia(ced)
{
if(ced=='1'){document.getElementById('dper_txt_ci').value='';}

document.getElementById('dper_txt_n1').value='';
document.getElementById('dper_txt_n2').value='';
document.getElementById('dper_txt_a1').value='';
document.getElementById('dper_txt_a2').value='';
document.getElementById('dper_txt_matriz').value='';
document.getElementById('dper_txt_parroq').value='';
document.getElementById('dper_txt_calle1').value='';
document.getElementById('dper_txt_calle2').value='';
document.getElementById('dper_txt_calle3').value='';
document.getElementById('dper_txt_callen').value='';
document.getElementById('dper_txt_telefono').value='';
document.getElementById('dper_txt_email').value='';
document.getElementById('dper_txt_emailce').value='';
document.getElementById('c1').value='';
document.getElementById('c2').value='';
document.getElementById('c3').value='';
document.getElementById('cn').value='';
document.getElementById('dper_txt_e1').value='';
document.getElementById('dper_txt_t1').value='';
document.getElementById('dper_txt_nik').value='';
document.getElementById('dper_txt_struc').value='';
document.getElementById('dper_txt_sexo').value='';
document.getElementById('dper_txt_fn').value='';
document.getElementById('dper_txt_fi').value='';
document.getElementById('dper_txt_rs').value='';
document.getElementById('dper_txt_nc').value='';
document.getElementById('dper_txt_ref').value='';
document.getElementById('dper_txt_tpro').value='';
document.getElementById('dper_txt_zsub').value='';
document.getElementById('dper_txt_csub').value='';
document.getElementById('dper_txt_cargo').value='';
document.getElementById('dper_txt_dcto').value='';
document.getElementById('dper_txt_comi').value='';
document.getElementById('dper_txt_vndd').value='';
document.getElementById('dper_txt_rcdd').value='';
document.getElementById('dper_txt_pspt').value='';
document.getElementById('dper_txt_idex').value='';
document.getElementById('dper_txt_pais').value='';
document.getElementById('dper_txt_ciudad').value='';
document.getElementById('dper_txt_provincia').value='';
document.getElementById('dper_txt_conadis').value='';
document.getElementById('dper_txt_factura').value='';
document.getElementById('pais').value='';
document.getElementById('ciudad').value='';
// document.getElementById('dper_err_n1').innerHTML='';
// document.getElementById('dper_err_n2').innerHTML='';
// document.getElementById('dper_err_a1').innerHTML='';
// document.getElementById('dper_err_a2').innerHTML='';
// document.getElementById('dper_err_rs').innerHTML='';
// document.getElementById('dper_err_nc').innerHTML='';
// document.getElementById('dper_err_fn').innerHTML='';
// document.getElementById('dper_err_nik').innerHTML='';
// document.getElementById('dper_err_struc').innerHTML='';
// document.getElementById('dper_err_sexo').innerHTML='';
// document.getElementById('dper_err_vndd').innerHTML='';
// document.getElementById('dper_err_zsub').innerHTML='';
// document.getElementById('pais_descri').innerHTML='';
// document.getElementById('ciudad_descri').innerHTML='';
// document.getElementById('dper_txt_ref_descri').innerHTML='';
// document.getElementById('dper_txt_zsub_descri').innerHTML='';
// document.getElementById('dper_txt_csub_descri').innerHTML='';
// document.getElementById('dper_txt_vndd_descri').innerHTML='';
// document.getElementById('dper_txt_rcdd_descri').innerHTML='';



}

function guarda_dper()
{
	
	//valida_dper();
	
	var ci=document.getElementById('dper_txt_ci').value;
  var n1=document.getElementById('dper_txt_n1').value;
	var n2=document.getElementById('dper_txt_n2').value;
	var a1=document.getElementById('dper_txt_a1').value;
	var a2=document.getElementById('dper_txt_a2').value;
	var matriz=document.getElementById('dper_txt_matriz').value;
	var parroq=document.getElementById('dper_txt_parroq').value;
	var calle1=document.getElementById('dper_txt_calle1').value;
	var calle2=document.getElementById('dper_txt_calle2').value;
	var calle3=document.getElementById('dper_txt_calle3').value;
	var callen=document.getElementById('dper_txt_callen').value;
	var telefono=document.getElementById('dper_txt_telefono').value;
	var email=document.getElementById('dper_txt_email').value;
	var emailce=document.getElementById('dper_txt_emailce').value;
	var c1=document.getElementById('c1').value;
 	var c2=document.getElementById('c2').value;
	var c3=document.getElementById('c3').value;
	var cn=document.getElementById('cn').value;
	var ref=document.getElementById('dper_txt_ref').value;
	var e1=document.getElementById('dper_txt_e1').value.toLowerCase().trim().replace('  ',' ');
 	var t1=document.getElementById('dper_txt_t1').value;
	var cdad=document.getElementById('cdad').value;
	var pais=document.getElementById('pais').value;
 	var nik=document.getElementById('dper_txt_nik').value;
 	var struc=document.getElementById('dper_txt_struc').value;
	var fn=document.getElementById('dper_txt_fn').value;
	var fi=document.getElementById('dper_txt_fi').value;
	var sexo=document.getElementById('dper_txt_sexo').value;
	var rs=document.getElementById('dper_txt_rs').value;
	var nc=document.getElementById('dper_txt_nc').value;
	fn=fecha_format(fn);
	fi=fecha_format(fi);

	var tpro=document.getElementById('dper_txt_tpro').value;
	var zsub=document.getElementById('dper_txt_zsub').value;
	var csub=document.getElementById('dper_txt_csub').value;
	var cargo=document.getElementById('dper_txt_cargo').value;
	var dcto=document.getElementById('dper_txt_dcto').value;
	var comi=document.getElementById('dper_txt_comi').value;
	var vndd=document.getElementById('dper_txt_vndd').value;
	var rcdd=document.getElementById('dper_txt_rcdd').value;
	var pspt=document.getElementById('dper_txt_pspt').value;
	var idex=document.getElementById('dper_txt_idex').value;
	var pais=document.getElementById('dper_txt_pais').value;
	var ciudad=document.getElementById('dper_txt_ciudad').value;
	var provincia=document.getElementById('dper_txt_provincia').value;
	var conadis=document.getElementById('dper_txt_conadis').value;
	var factura=document.getElementById('dper_txt_factura').value;
	
	var descri=a1+' '+a2+' '+n1+' '+n2;
	if (rs==""){a1+' '+a2+' '+n1+' '+n2;}
	if (descri==""){descri=rs;}
	var direccion=c1+' '+c2+' '+cn+' '+c3;
	
// 	console.log(descri);
	
	var error_dper='';
	
	var tel2=document.getElementById('tel2').value;
	var c12=document.getElementById('c12').value;
	var c22=document.getElementById('c22').value;
	var c32=document.getElementById('c32').value;
	var cn2=document.getElementById('cn2').value;
	var cdad=document.getElementById('cdad').value;
	var email2=document.getElementById('email2').value;
	var ext2=document.getElementById('ext2').value;
	var contacto2=document.getElementById('contacto2').value;

	
	if(rs=="" && n1==""){alert('NO HAY DATOS');}
	else
	{	
	msgconfir='GUARDAR --> '+ci+' - '+rs+' ?';
	if (confirm(msgconfir)) 
	{
	
	document.body.style.cursor='wait';
	document.getElementById('direc_error').innerHTML='';
	
	$.ajax({
		url:'nenti2.php',
		type:'POST',
		data:{ci:ci,n1:n1,n2:n2,a1:a1,a2:a2,c1:c1,c2:c2,cn:cn,c3:c3,e1:e1,t1:t1,
    matriz:matriz,calle1:calle1,calle2:calle2,calle3:calle3,callen:callen,parroq:parroq,
    telefono:telefono,email:email,emailce:emailce,
		zsub:zsub,tpro:tpro,csub:csub,cargo:cargo,
    dcto:dcto,comi:comi,
    vndd:vndd,rcdd:rcdd,pspt:pspt,idex:idex,conadis:conadis,factura:factura,
    ref:ref,nik:nik,struc:struc,
    pais:pais,ciudad:ciudad,provincia:provincia,cdad:cdad,
		sexo:sexo,fn:fn,fi:fi,rs:rs,nc:nc,descri:descri,direccion:direccion,
		tel2:tel2,c12:c12,c22:c22,c32:c32,cn2:cn2,cdad:cdad,email2:email2,contacto2:contacto2
		},
		success:function(dato)
		{
			alert('Datos Guardados OK');
			console.log(dato);
			document.body.style.cursor='auto';
			document.getElementById('direc_error').innerHTML=$(dato).find("error1").text()+$(dato).find("error2").text()+$(dato).find("error3").text();
			_carga(ci,'');
		}, 
		error:function(objeto)
		{
			alert('ERROR al Guardar');
			console.log(objeto);
			
		}
	});
	
	document.body.style.cursor='auto';
	}
	}
}




function _carga(cie,opc)
{
	
	
	$.ajax({
		url:'nenti3.php',
		async:false,
		type:'POST', 
		data:{ci:cie},
		beforeSend: function(){},
		success: function(dato){
				
				document.getElementById('direc_d').innerHTML=dato;
				//if($(dato).find("error").text()!='0'){return false;}
				if(opc=='1')
				{
					_limpia('');
					
					document.getElementById('dper_txt_n1').value=document.getElementById('hn1').value;
					document.getElementById('dper_txt_n2').value=document.getElementById('hn2').value;
					document.getElementById('dper_txt_a1').value=document.getElementById('ha1').value;
					document.getElementById('dper_txt_a2').value=document.getElementById('ha2').value;
					document.getElementById('dper_txt_matriz').value=document.getElementById('hmatriz').value;
					document.getElementById('dper_txt_parroq').value=document.getElementById('hparroq').value;
					document.getElementById('dper_txt_calle1').value=document.getElementById('hcalle1').value;
					document.getElementById('dper_txt_calle2').value=document.getElementById('hcalle2').value;
					document.getElementById('dper_txt_calle3').value=document.getElementById('hcalle3').value;
					document.getElementById('dper_txt_callen').value=document.getElementById('hcallen').value;
					document.getElementById('dper_txt_telefono').value=document.getElementById('htelefono').value;
					document.getElementById('dper_txt_email').value=document.getElementById('hemail').value;
					document.getElementById('dper_txt_emailce').value=document.getElementById('hemailce').value;
					document.getElementById('dper_txt_rs').value=document.getElementById('hrazsoc').value;
					document.getElementById('dper_txt_nc').value=document.getElementById('hnomcom').value;
					document.getElementById('dper_txt_fn').value=document.getElementById('hfn').value;
					document.getElementById('dper_txt_fi').value=document.getElementById('hfi').value;
					document.getElementById('dper_txt_sexo').value=document.getElementById('hsexo').value;
					document.getElementById('dper_txt_nik').value=document.getElementById('hnik').value;
					document.getElementById('dper_txt_struc').value=document.getElementById('hstruc').value;
					document.getElementById('dper_txt_tpro').value=document.getElementById('htpro').value;
					document.getElementById('dper_txt_tpro_descri').value=document.getElementById('htprod').value;
					document.getElementById('dper_txt_zsub').value=document.getElementById('hzsub').value;
					document.getElementById('dper_txt_zsub_descri').value=document.getElementById('hzsubd').value;
					document.getElementById('dper_txt_csub').value=document.getElementById('hcsub').value;
					document.getElementById('dper_txt_cargo').value=document.getElementById('hcargo').value;
					document.getElementById('dper_txt_dcto').value=document.getElementById('hdcto').value;
					document.getElementById('dper_txt_comi').value=document.getElementById('hcomi').value;
					document.getElementById('dper_txt_vndd').value=document.getElementById('hvndd').value;
					document.getElementById('dper_txt_rcdd').value=document.getElementById('hrcdd').value;
					document.getElementById('dper_txt_pspt').value=document.getElementById('hpspt').value;
					document.getElementById('dper_txt_idex').value=document.getElementById('hidex').value;
					document.getElementById('dper_txt_pais').value=document.getElementById('hpais').value;
					document.getElementById('dper_txt_ciudad').value=document.getElementById('hciudad').value;
					document.getElementById('dper_txt_provincia').value=document.getElementById('hprovincia').value;
					document.getElementById('dper_txt_conadis').value=document.getElementById('hconadis').value;
					document.getElementById('dper_txt_factura').value=document.getElementById('hfactura').value;
					document.getElementById('c1').value=document.getElementById('hc1').value;
					document.getElementById('c2').value=document.getElementById('hc2').value;
					document.getElementById('cn').value=document.getElementById('hcn').value;
					document.getElementById('c3').value=document.getElementById('hc3').value;
					document.getElementById('dper_txt_e1').value=document.getElementById('he1').value;
					document.getElementById('dper_txt_t1').value=document.getElementById('ht1').value;
					document.getElementById('dper_txt_ref').value=document.getElementById('href').value;
					document.getElementById('pais').value=document.getElementById('hpais').value;
					document.getElementById('ciudad').value=document.getElementById('hciudad').value;
					//document.getElementById('ciudad_descri').innerHTML=$(dato).find("ciudad_descri").text();
					

				}
    /*
    <td><div id="tcontacto2"></div></td>
    <td><div id="tc12"></div></td>
    <td><div id="tc22"></div></td>
    <td><div id="tc32"></div></td>
    <td><div id="tcn2"></div></td>
    <td><div id="tcdad"></div></td>
    <td><div id="temal2"></div></td>
*/
				
			},
		error: function(err_e){ console.log(err_e);},
		timeout: 60000
		
		
		
		});
			
				//document.getElementById('tel2').style.width=document.getElementById('tel2').offsetWidth+'px';
				//document.getElementById('text2').style.width=document.getElementById('ext2').offsetWidth;
// 				console.log(document.getElementById('tdtel').offsetWidth);
// 				var ancho=document.getElementById('tdtel').offsetWidth;
  ancho=20;
				document.getElementById('ttel2').style.width=ancho+'px'; 
				document.getElementById('text2').style.width=ancho+'px'; 
				document.getElementById('tcontacto2').style.width=ancho+'px';
				document.getElementById('tc12').style.width=ancho+'px';
				document.getElementById('tc22').style.width=ancho+'px';
				document.getElementById('tc32').style.width=ancho+'px';
				document.getElementById('tcn2').style.width=ancho+'px';
// 				document.getElementById('tcdad').style.width=ancho+'px';
				document.getElementById('temal2').style.width=ancho+'px';
				document.getElementById('tico').style.width='20px';
				

}



function _enti(e)
{
	console.log('***');
	if(e.keyCode==13)
	{
		//_edit_e(document.getElementById('dper_txt_ci').value);
	}
		_carga(document.getElementById('dper_txt_ci').value,'1');
	
}

function _fecha_formatobj(e){

	if(e.keyCode==13 || e.keyCode==9)
	{	
	var fn=document.getElementById('dper_txt_fn').value;
	fn=fecha_format(fn);
	document.getElementById('dper_txt_fn').value=fn;
	}

}

function _defa_adr(idx,ci)
{
	var ci=document.getElementById('dper_txt_ci').value;
  if(confirm("Establecer como Principal ?")) 
	{
	$.ajax({
		url:'../lib/vradrs4.php',
		type:'POST',
		data:{idx:idx,ci:ci},
		success: function(dato)
		{
			switch(dato)
			{
				case '0':
// 					document.getElementById(idx).style.display='none';
				break;
				case '1':
					//alert('Ocurrio Error de Conexion');
				break;
				case '500':
					alert('No Tiene Permiso');
				break;
				default:
					alert('Error');
				break;
			}
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              console.log('Not connect: Verify Network.');
           } else if (jqXHR.status == 404) {
               console.log('Requested page not found [404]');
           } else if (jqXHR.status == 500) {
               console.log('Internal Server Error [500].');
           } else if (exception === 'parsererror') {
               console.log('Requested JSON parse failed.');
           } else if (exception === 'timeout') {
               //console.log('Time out error.');
			   alert('Servidor no Responde');
           } else if (exception === 'abort') {
               console.log('Ajax request aborted.');
           } else {
               console.log('Uncaught Error: ' + jqXHR.responseText);
           }

		},
	    complete:function(jqXHR, textStatus)
    	{
			if(textStatus==='success')
	    {
//     	 window.location.reload();	
			}           
		},
	});
// 	guarda_dper();	
	}
// 	 window.location.reload();	
}



function _delete_adr(idx,ci)
{
    if(!confirm("Seguro que desea Eliminar?")) {return false;}
	
	$.ajax({
		url:'../lib/vradrs2.php',
		type:'POST',
		data:{idx:idx,ci:ci},
		success: function(dato)
		{
			switch(dato)
			{
				case '0':
					//alert('Se Elimino');
					document.getElementById(idx).style.display='none';
				break;
				case '1':
					//alert('Ocurrio Error de Conexion');
				break;
				case '500':
					alert('No Tiene Permiso');
				break;
				default:
					alert('Error');
				break;
			}
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              console.log('Not connect: Verify Network.');
           } else if (jqXHR.status == 404) {
               console.log('Requested page not found [404]');
           } else if (jqXHR.status == 500) {
               console.log('Internal Server Error [500].');
           } else if (exception === 'parsererror') {
               console.log('Requested JSON parse failed.');
           } else if (exception === 'timeout') {
               //console.log('Time out error.');
			   alert('Servidor no Responde');
           } else if (exception === 'abort') {
               console.log('Ajax request aborted.');
           } else {
               console.log('Uncaught Error: ' + jqXHR.responseText);
           }

		},
	    complete:function(jqXHR, textStatus)
    	{
			if(textStatus==='success')
	        {
    	    	
			}           
		},
	});
}




<?php if(isset($_GET['idx']) && !empty($_GET['idx'])){?>
// window.onload = function(e){ 
//  _carga('<?php echo $_GET['idx']; ?>','1');
// }
<?php }?>

<?php if ( !mb_stristr('admi.sist.supe',strtolower($user_tipo)) ) {?>
// window.onload = function(e){ 
//  _carga('<?php echo $_SESSION['user_vcrx_id']; ?>','1');
// }
<?php }?>

</script>

</head>

<body>
<div align="center">
<div>
<div align="center"><?php include('../../_lib/cabecera2.php');?></div>

<table width="100%" border="0" cellpadding="0" cellspacing="0"  style="border-collapse:collapse; background:#fff;">
<tr align="left">
<?php if(mb_stristr('admi.sist.supe',strtolower($user_tipo))){ ?> 
  <?php }?>
<td align="left">
<?php  $pcaption='LIMPIAR';  $pidtxt='dper_btn_l'; if(mb_stristr('admi.sist.supe',strtolower($user_tipo))){$ponclick='_limpia(1)';};  include('vrbutton.php') ?>
</td>	
<td align="left">
<?php  $pcaption='GRABAR';  $pidtxt='dper_btn_g'; $ponclick='guarda_dper();';  include('vrbutton.php') ?>
</td>	
<!-- <input type="button" value="Guardar"    onclick="guarda_dper();"    id="dper_btn_g"/> -->
<!-- <input type="button" value="Limpiar"    onclick="_limpia('<?php if (mb_stristr('admi.sist.supe',strtolower($user_tipo)) ){echo '1';}?>');"    id="dper_btn_l"/> -->
</tr>
</table>
<input type="image" width="20" src="http://vcrxol.com/_img/add_address.png" onclick="add_adr('<?php echo $_POST['ci'];?>');" style="display:none;" />
<br>

<table border="0" width="100%" cellpadding="0" cellspacing="0" style="font-size:12px;" >
<tr valign="top">
<td>
<!--+++++ -->
<table border="0" cellpadding="2" cellspacing="0" style=" font-size:12px; font-weight:bolder;">
<tr>
	<?php  $pcaption='CI/RUC'; $pidtxt='dper_txt_ci'; $plong=13; $ponblur='_enti(event);'; include('vrgettxt.php') ?>
	<?php  //$pcaption='CI/RUC'; $pidtxt='dper_txt_ci'; $ptabla='enti'; $ponblur='_enti(event);'; include('vrgetcod.php') ?>
</tr>
<tr>
	<?php  $pcaption='RAZON SOCIAL'; $pidtxt='dper_txt_rs'; $plong=30;  include('vrgettxt.php') ?>
</tr>
<tr>
	<?php  $pcaption='NOMBRE COMERCIAL'; $pidtxt='dper_txt_nc'; $plong=30;  include('vrgettxt.php') ?>
</tr>
<tr <?php if($persona==0){echo 'style="display:none;"';}?> >
	<?php  $pcaption='PRIMER NOMBRE '; $pidtxt='dper_txt_n1'; $plong=15;  include('vrgettxt.php') ?>
</tr>
<tr <?php if($persona==0){echo 'style="display:none;"';}?> >
	<?php  $pcaption='SEGUNDO NOMBRE '; $pidtxt='dper_txt_n2'; $plong=15;  include('vrgettxt.php') ?>
</tr>
<tr <?php if($persona==0){echo 'style="display:none;"';}?> >
	<?php  $pcaption='APE.PATERNO '; $pidtxt='dper_txt_a1'; $plong=15;  include('vrgettxt.php') ?>
</tr>
<tr <?php if($persona==0){echo 'style="display:none;"';}?> >
	<?php  $pcaption='APE.MATERNO '; $pidtxt='dper_txt_a2'; $plong=15;  include('vrgettxt.php') ?>
</tr>

<tr>
	<td>
  <br>
  </td>
</tr>

<tr>
	<?php  $pcaption='MATRIZ '; $pidtxt='dper_txt_matriz'; $plong=30; $prows=3;  include('vrgettxt.php') ?>
</tr>

<tr>
	<?php  $pcaption='CALLE 1 / CDLA '; $pidtxt='dper_txt_calle1'; $plong=30;   include('vrgettxt.php') ?>
</tr>

<tr>
	<?php  $pcaption='CALLE 2 / MZ. '; $pidtxt='dper_txt_calle2'; $plong=30;  include('vrgettxt.php') ?>
</tr>

<tr>
	<?php  $pcaption='NUMERO / DPTO '; $pidtxt='dper_txt_callen'; $plong=5;   include('vrgetnum.php') ?>
</tr>

<tr>
	<?php  $pcaption='REFERENCIA '; $pidtxt='dper_txt_calle3'; $plong=50;  include('vrgettxt.php') ?>
</tr>

<tr>
	<?php  $pcaption='PARROQUIA '; $pidtxt='dper_txt_parroq'; $plong=30;   include('vrgettxt.php') ?>
</tr>

<tr>
	<?php  $pcaption='TELEFONO '; $pidtxt='dper_txt_telefono'; $plong=30;  include('vrgettxt.php') ?>
</tr>

<tr>
	<?php  $pcaption='E-MAIL '; $pidtxt='dper_txt_email'; $plong=30;  include('vrgettxt.php') ?>
</tr>
<tr>
	<?php  $pcaption='E-MAIL C.ELEC '; $pidtxt='dper_txt_emailce'; $plong=30;  include('vrgettxt.php') ?>
</tr>



</table>
<!--+++++ -->
</td>

<td>
<table border="0" cellpadding="2" cellspacing="0" style=" font-size:12px; font-weight:bolder;">
<tr>
	<?php  $pcaption='STATUS RUC'; $pidtxt='dper_txt_struc'; $plong=1;  include('vrgettxt.php') ?>
</tr>
<tr>
	<?php  $pcaption='FECHA INI.'; $pidtxt='dper_txt_fi';  include('vrgetfec.php') ?>
</tr>
<tr <?php if($persona==0){echo 'style="display:none;"';}?> >
	<?php  $pcaption='FECHA NAC.'; $pidtxt='dper_txt_fn';  include('vrgetfec.php') ?>
</tr>
<tr <?php if($persona==0){echo 'style="display:none;"';}?> >
  <?php  $pcaption='SEXO'; $pidtxt='dper_txt_sexo'; $plong=1;  include('vrgetnum.php') ?>
</tr>
<tr>
	<?php  $pcaption='PAIS'; $ptabla='pais'; $pidtxt='dper_txt_pais'; $plong=4;  include('vrgetcod.php') ?>
</tr>
<tr>
	<?php  $pcaption='PROVINCIA'; $ptabla='enti'; $pcolu='enti_provincia'; $pidtxt='dper_txt_provincia';   include('vrgettxt.php') ?>
</tr>
<tr>
	<?php  $pcaption='CIUDAD'; $ptabla='enti'; $pcolu='enti_ciudad'; $pidtxt='dper_txt_ciudad';   include('vrgettxt.php') ?>
</tr>
  <tr><td colspan=2><hr></td></tr>
<tr>
	<?php  $pcaption='FACTURA'; $pidtxt='dper_txt_factura'; $plong=20;  $ptabla='enti'; include('vrgetcod.php') ?>
</tr>
<tr>
	<?php  $pcaption='PASAPORTE'; $pidtxt='dper_txt_pspt'; $plong=20;  include('vrgettxt.php') ?>
</tr>
<tr>
	<?php  $pcaption='ID.EXTERIOR'; $pidtxt='dper_txt_idex'; $plong=20;  include('vrgettxt.php') ?>
</tr>
<tr>
	<?php  $pcaption='CONADIS'; $pidtxt='dper_txt_conadis'; $plong=20;  include('vrgettxt.php') ?>
</tr>

<tr>
	<?php  $pcaption='ALIAS / NICK'; $pidtxt='dper_txt_nik'; $plong=20;  include('vrgettxt.php') ?>
</tr>
</table>	
</td>


<td>
<table border="0" cellpadding="2" cellspacing="0" style=" font-size:12px; font-weight:bolder; <?php if(!mb_stristr('gnya.leie.demo',$empr_codigo)){echo 'display:none;';}?>">
<tr>
	<?php  $pcaption='REFERIDO X'; $ptabla='enti'; $pidtxt='dper_txt_ref';  include('vrgetcod.php') ?>
</tr>
</table>	

<table border="0" cellpadding="2" cellspacing="0" style=" font-size:12px; font-weight:bolder; <?php if (!mb_stristr('sist.supe.admi',$user_tipo)){echo 'display:none;';}?>">
<tr >
	<?php  $pcaption='T.PROV.'; $ptabla='tpro'; $pidtxt='dper_txt_tpro';  include('vrgetcod.php') ?>
</tr>
<br/>	
<tr >
	<?php  $pcaption='ZONA'; $ptabla='zsub'; $pidtxt='dper_txt_zsub';  include('vrgetcod.php') ?>
</tr>
<tr >
	<?php  $pcaption='VENDEDOR'; $ptabla='vndd'; $pidtxt='dper_txt_vndd';  include('vrgetcod.php') ?>
</tr>
<tr>
	<?php  $pcaption='RECAUDADOR'; $ptabla='rcdd'; $pidtxt='dper_txt_rcdd';  include('vrgetcod.php') ?>
</tr>
</table>	

<br/>	
<table border="0" cellpadding="2" cellspacing="0" style=" font-size:12px; font-weight:bolder; <?php if (!mb_stristr('sist.supe.admi',$user_tipo)){echo 'display:none;';}?>">
<tr>
	<?php  $pcaption='CENTRO-S'; $ptabla='csub'; $pidtxt='dper_txt_csub';  include('vrgetcod.php') ?>
</tr>
<tr>
	<?php  $pcaption='CARGO';  $pidtxt='dper_txt_cargo'; $plong=20;  include('vrgettxt.php') ?>
</tr>
</table>	

<br/>	
<table border="0" cellpadding="2" cellspacing="0" style=" font-size:12px; font-weight:bolder; <?php if (!mb_stristr('sist.supe.admi',$user_tipo)){echo 'display:none;';}?>">
<tr>
	<?php  $pcaption='DESCUENTO';  $pidtxt='dper_txt_dcto';  include('vrgetval.php') ?>
</tr>
<tr>
	<?php  $pcaption='COMISION';  $pidtxt='dper_txt_comi'; include('vrgetval.php') ?>
</tr>
</table>	


	
</td>	
	
<td>
<!--+++++ -->
<table border="0" cellpadding="2" cellspacing="0" style=" font-size:12px; font-weight:bolder; display:none;">
<tr>
	<td><input type="hidden" id="pais_btn" value="PAIS:" onClick="list_carga('pais','pais','pais_descri');" style="text-transform:uppercase;"/></td>
    <td><input type="hidden" id="pais" onkeydown="_pais(event);" class="dper_txt" style="text-transform:uppercase;"/></td>
    <td><span id="pais_descri" style="font-weight:bold; height:25px;"></span></td>
</tr>

<tr>
	<td><input type="hidden" id="ciudad_btn" value="PROV /CIUDAD:" onClick="list_carga('cdad','ciudad','ciudad_descri');" style="text-transform:uppercase;"/></td>
    <td><input type="hidden" id="ciudad" onkeydown="_ciudad(event);" class="dper_txt" style="text-transform:uppercase;"/> </td>
    <td><span id="ciudad_descri" style="font-weight:bold; height:25px;"></span></td>
</tr>

<tr>
<!-- 	<td>CALLE 1 /CDLA. /EDIF.</td> -->
    <td><input type="hidden" id="c1" class="dper_txt" maxlength="20"  style="text-transform:uppercase;" /></td>
    <td width="50"><span id="dper_err_c1" class="dper_err" style="text-transform:uppercase;"></span></td>
</tr>

<tr>
<!-- 	<td>CALLE 2 /MZ /PISO </td> -->
    <td><input type="hidden" id="c2" class="dper_txt" maxlength="20"  style="text-transform:uppercase;"  /></td>
    <td><span id="dper_err_c2" class="dper_err" style="text-transform:uppercase;"></span></td>
</tr>

<tr>
<!-- 	<td>NUM. /VILLA /DPTO</td> -->
    <td><input type="hidden" id="cn" class="dper_txt" maxlength="20"   style="text-transform:uppercase;" /></td>
    <td><span id="dper_err_cn" class="dper_err" style="text-transform:uppercase;"></span></td>
</tr>

<tr>
<!-- 	<td>REFERENCIA(casa):</td> -->
    <td><input type="hidden" id="c3" class="dper_txt" maxlength="20"  style="text-transform:uppercase;"  /></td>
    <td><span id="dper_err_c3" class="dper_err" style="text-transform:uppercase;"></span></td>
</tr>

<tr>
<!-- 	<td>EMAIL:</td> -->
    <td><input type="hidden" id="dper_txt_e1" class="dper_txt" maxlength="45" style="text-transform:lowercase;"   /></td>
    <td><span id="dper_err_e1" class="dper_err" style="text-transform:lowercase;"></span></td>
</tr>

<tr>
<!-- 	<td>TEL. CONVENCIONAL:</td> -->
    <td><input type="hidden" id="dper_txt_t1" class="dper_txt" maxlength="20"    /></td>
    <td><span id="dper_err_t1" class="dper_err"></span></td>
</tr>


</table>

<!--+++++ -->

</td>
</tr>
</table>

</table>


<div id="direc_error" style="height:20px; color:#F00;"></div>


	
<table width="100%" border="0" cellpadding="0" cellspacing="0"  style="border-collapse:collapse; background:#eee; display:none;">
<tr align="center" valign="bottom" style="border-top: solid 1px;border-bottom: solid 1px;font-size:12px;">
	<?php  $pcaption='EMAIL';  $pidtxt='email2';  $pobj=2; $plong=20; include('vrgettxt.php') ?>
	<?php  $pcaption='CALLE1 - CDLA - EDIF.';  $pidtxt='c12';  $pobj=2; $plong=20; include('vrgettxt.php') ?>
	<?php  $pcaption='CALLE2  - MZ. -PISO';  $pidtxt='c22';  $pobj=2; $plong=20; include('vrgettxt.php') ?>
	<?php  $pcaption='NUM.VLLA.DPT.';  $pidtxt='cn2';  $pobj=2; $plong=4; include('vrgettxt.php') ?>
	<?php  $pcaption='REFERENCIA';  $pidtxt='c32';  $pobj=2; $plong=20; include('vrgettxt.php') ?>
	<?php  $pcaption='TELEFONO';  $pidtxt='tel2';  $pobj=2; $plong=10; include('vrgettxt.php') ?>
	<?php  $pcaption='ext.';  $pidtxt='ext2';  $pobj=2; $plong=4; include('vrgettxt.php') ?>
	<?php  $pcaption='CIUDAD'; $ptabla='cdad'; $pobj=2;  include('vrgetcod.php') ?>
	<?php  $pcaption='CONTACTO';  $pidtxt='contacto2';  $pobj=2; $plong=20; include('vrgettxt.php') ?>
<th><div style="width:20px;"></div></th>
</tr>
</table>

<div id="direc_d"></div>


<?php		
// $xwidth=40;	
require('lista_car.php');
?>	
<!-- 
<div id="lista_temporal_contenedor" style=" display:none; padding:0px; margin:0px; background: #666; opacity:0.5; width:100%; min-height: 100%; height:auto !important;position: fixed;top:0;left:0; z-index:1;" ></div>
<div id="lista_cargador" style=" display:none; background:#FFF;position: fixed; top:50px;z-index:10;" ><img src="../img/ajax-loader.gif" /></div>    
<div id="lista_temporal" style=" display:none; background:#FFF;position: fixed; top:50px;z-index:10; overflow-y:scroll; min-height:50px; max-height:400px; width:100%;" ><img src="../img/ajax-loader.gif" /></div>    
 -->



</div>
</div>

<input type="hidden" id="dper_hdd_ci" />
</body>

<script>
window.onload=onload();
</script>


</html>