<?php session_start();
if(empty($_SESSION['user_vcrx_id']) && !empty($_GET['opt'])){header('Location: index.php');}

require('cfg/cfg.php');

?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0'  />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<!-- <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> -->
<!-- <meta name="viewport" content="target-densitydpi=device-dpi, initial-scale=1.0, user-scalable=no" /> -->

<title>Carrito de Compras</title>

<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
<script type="text/javascript" src="js/valida_ci_ruc_112.js"></script>


<script type="text/javascript">
window.onload = function (){
var alto=screen.height; 
/*
	document.getElementById('frm_contenedor').style.display='none';	
	alto+=260;
	document.getElementById('frm_contenedor').style.height=alto+'px';
*/
	document.getElementById('responsitive_cont_mnu').style.height=alto+'px';
	if(document.getElementById('con_dir')){
		var ancho=screen.width;
		
		//document.getElementById('con_dir').style.width=ancho+'px';
	}
};
//window.onresize = _tamanio();
function _tamanio(){
/*
	var alto=screen.height;
	alto+=260;
	document.getElementById('frm_contenedor').style.height=alto+'px';
	document.getElementById('frm_contenedor').style.display='block';
*/	
}

var errorx=99;
var ci_tmp='';
var email_tmp='';

var obj_chk;
function _imagen(foto,archivo)
{
	document.getElementById(foto).src='../imgi/'+archivo+'?abc='+Math.floor((Math.random() * 10) + 1);
}

function _carro(rad){
document.getElementById(rad+'_error').innerHTML='';
var nele=document.getElementsByClassName(rad).length-1;
var chk=0;
var item='';
for(i=0;i<=nele;i++){
		if(document.getElementsByClassName(rad).item(i).checked){
			chk=1;
			item=document.getElementsByName(rad).item(i).value;
			break;
		}
	}

if(chk!=1){return false;}

document.getElementById(rad).disabled=true;
document.body.style.cursor='wait';	

$.ajax({
		url:'lib/carr2.php',
		type:'POST', 
		async:false,
		data:{item:item},
		success:function(dato){
			console.log(dato);
			document.body.style.cursor='auto';
			document.getElementById(rad+'_error').innerHTML=dato;
			//alert(dato);
			document.getElementById(rad).disabled=false;
			document.getElementsByClassName(rad).item(i).checked=false;
			obj_chk=rad+'_error';
			if(dato==='Debe iniciar sesion'){ 
			document.getElementById('frm_login').style.display='block';
			document.getElementById('cat_contenedor').style.display='none';
 				_tamanio();
			}
			
		}, 

		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              alert('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'){setTimeout(_limpia, 5000);}
			},
		timeout:30000
	});
	
chk=0;

}
function _limpia()
{
	//obj_chk
	document.getElementById(obj_chk).innerHTML='';
	//setTimeout(document.getElementById(div_err).innerHTML='', 100000);
//var 	myVar = setTimeout(console.log('abc'), 10000);
//var 	myVar =setInterval(console.log('abc'), 10000);
 	//console.log('123');
	//clearTimeout(myVar);
}






function usuario(e,t)
{

	if(t.length!=0)
	{	
		if(e.keyCode==13)
		{
			$('#txt_clave').focus();
		}
	}

}
function clave(e)
{
	if(e.keyCode==13)
	{
		valida_ci_ingreso();
	}
}

function valida_ci_ingreso()
{
	document.getElementById('boton').disabled=true;
	var ci=document.getElementById('txt_ci').value;
	var clave=document.getElementById('txt_clave').value;
	var error_ci=valida_ci_ruc(ci);

	var email = ci.indexOf("@");
	if (email>0){error_ci=0;}
	clave=clave.substring(0,6);
	clave=clave.trim();
	
	if(error_ci!=0)
	{
		document.getElementById('error').innerHTML='Ci/Ruc Incorrecto';
		document.getElementById('boton').disabled=false;
		return false;
	}
	else
	{
		document.getElementById('error').innerHTML='';
	}
	if(clave.length!=6)
	{
		document.getElementById('error').innerHTML='Clave debe ser 6 Digitos';
		document.getElementById('boton').disabled=false;
		return false;
	}
	else
	{


	$.ajax({
		cache:false,
		url:'lib/procesa_usr.php',
		datatype: "text",
	    async:false,
		type:'POST',
		data:{txt_ci:document.getElementById('txt_ci').value,txt_clave:document.getElementById('txt_clave').value}, 
    	beforeSend: function(jqXHR, textStatus)
		{
                
		}, 
		
		success:function(dato, textStatus, jqXHR)
		{
			console.log(dato);
			document.getElementById('boton').disabled=false;
			
			if(dato==='0')
			{
				//document.getElementById('frm_contenedor').style.display='none';
				
				//window.location ='main/index.php';
				document.getElementById('frm_login').style.display='none';
				document.getElementById('cat_contenedor').style.display='block';			
				document.getElementById('sesion_btn').style.display='none';
				document.getElementById('responsitive_btn').style.display='block';
							
				
				
			}
			else
			{
				document.getElementById('error').innerHTML=dato;
			}
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              document.getElementById('error').innerHTML='Sin conexion: Verifique Red.';
           } else if (jqXHR.status == 404) {
               document.getElementById('error').innerHTML='Respuesta pagina not encontrada [404]';
           } else if (jqXHR.status == 500) {
               document.getElementById('error').innerHTML='Internal Server Error [500].';
           } else if (exception === 'parsererror') {
               document.getElementById('error').innerHTML='Requested JSON parse failed.';
           } else if (exception === 'timeout') {
			   document.getElementById('error').innerHTML='Servidor no Responde';
           } else if (exception === 'abort') {
               document.getElementById('error').innerHTML='Ajax request aborted.';
           } else {
               document.getElementById('error').innerHTML='Uncaught Error: ' + jqXHR.responseText;
           }

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

			}           
		},
		timeout:60000
	});		
	}
}


function val_form1()
{
var ci=document.getElementById('frm_reg_ci').value;
var ci_error=valida_ci_ruc(ci);
var email=document.getElementById('frm_reg_email').value;
var fono=document.getElementById('frm_reg_fono').value;
var nombre=document.getElementById('frm_reg_descri').value;
var clave=document.getElementById('frm_reg_clave').value;



//+++++++++++++++
	
 if(ci_error!=0 )
 {
	document.getElementById('frm_reg_error').innerHTML='Cedula Incorrecta';
	document.getElementById('frm_reg_ci').focus();
	return false;
 }
 else
 {

	if(ci!=ci_tmp)
	{
	
	$.ajax({
		cache:false,
		url:'lib/vrvalusrt.php',
		datatype: "text",
	    async:false,
		type:'POST',
		data:{valor:ci,tipo:'cedula'}, 
    	beforeSend: function(jqXHR, textStatus)
		{
    	  document.getElementById('frm_reg_error').innerHTML='procesando.....';
	      document.body.style.cursor='wait';
	      document.getElementById('reg_btn').style.cursor='wait';
		  document.getElementById('reg_btn').style.background='#C1FFFF';
	      document.getElementById('reg_btn').disabled=true;
                
		}, 
		
		success:function(dato, textStatus, jqXHR)
		{
			errorx=dato;
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              document.getElementById('frm_reg_error').innerHTML='Sin conexion: Verifique Red.';
           } else if (jqXHR.status == 404) {
               document.getElementById('frm_reg_error').innerHTML='Respuesta pagina not encontrada [404]';
           } else if (jqXHR.status == 500) {
               document.getElementById('frm_reg_error').innerHTML='Internal Server Error [500].';
           } else if (exception === 'parsererror') {
               console.log('Requested JSON parse failed.');
           } else if (exception === 'timeout') {
               //console.log('Time out error.');
			   document.getElementById('frm_reg_error').innerHTML='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')
	        {
    	    	

			}           
		},
		timeout:30000
	});
	
	if(errorx!='0')
	{
		document.body.style.cursor='auto';
		document.getElementById('reg_btn').style.cursor='pointer';
  		document.getElementById('reg_btn').disabled=false;
		document.getElementById('reg_btn').style.background='#09c';
		
		document.getElementById('frm_reg_error').innerHTML='CI Ya Existe';
		document.getElementById('frm_reg_ci').focus();
		return false;
	}
	else
	{
		document.getElementById('frm_reg_error').innerHTML='';
		ci_tmp=ci;
	}

 }
}


//++++++++++++

 
 var filtro_email=/[\w-\.]{3,}@([\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}/;
 if(!filtro_email.test(email))
 {
	document.body.style.cursor='auto';
	document.getElementById('reg_btn').style.cursor='pointer';
	document.getElementById('reg_btn').disabled=false;
	document.getElementById('reg_btn').style.background='#09c';	
	 
	document.getElementById('frm_reg_error').innerHTML='Email Incorrecto';
	document.getElementById('frm_reg_email').focus();
	return false;
 }
 else
 {
	if(email!=email_tmp)
	{

	$('#frm_reg_error').html('');
	$.ajax({
		cache:false,
		url:'lib/vrvalusrt.php',
		datatype: "text",
	    async:false,
		type:'POST',
		data:{valor:email,tipo:'email'},
    	beforeSend: function(jqXHR, textStatus)
		{
    	  document.getElementById('frm_reg_error').innerHTML='procesando.....';
	      document.body.style.cursor='wait';
	      document.getElementById('reg_btn').style.cursor='wait';
		  document.getElementById('reg_btn').style.background='#C1FFFF';
	      document.getElementById('reg_btn').disabled=true;
                
		},
		success:function(dato, textStatus, jqXHR)
		{
			errorx=dato;
			
		},
		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')
	        {
    	    	
			}           
		},
		timeout:30000
		
	});
	
	if(errorx!='0')
	{

		document.body.style.cursor='auto';
		document.getElementById('reg_btn').style.cursor='pointer';
  		document.getElementById('reg_btn').disabled=false;
		document.getElementById('reg_btn').style.background='#09c';

		document.getElementById('frm_reg_error').innerHTML='Email Ya Existe';
		document.getElementById('frm_reg_email').focus();
		return false;
	}
 	else
 	{
 		document.getElementById('frm_reg_error').innerHTML='';
		email_tmp=email;
 	}
 }
 
}





//****


if(fono.length<5)
{
	document.body.style.cursor='auto';
	document.getElementById('reg_btn').style.cursor='pointer';
	document.getElementById('reg_btn').disabled=false;
	document.getElementById('reg_btn').style.background='#09c';	
	
	document.getElementById('frm_reg_error').innerHTML='Telefono Obligatorio';
	document.getElementById('frm_reg_fono').focus();
	return false;
}
else
{
	document.getElementById('frm_reg_error').innerHTML='';
}


if(nombre.length<5)
{
	document.body.style.cursor='auto';
	document.getElementById('reg_btn').style.cursor='pointer';
	document.getElementById('reg_btn').disabled=false;
	document.getElementById('reg_btn').style.background='#09c';	
	
	document.getElementById('frm_reg_error').innerHTML='Nombre Completo';
	document.getElementById('frm_reg_descri').focus();
	return false;
}
else
{
	document.getElementById('frm_reg_error').innerHTML='';
}

if(clave.length!=6)
{
	document.body.style.cursor='auto';
	document.getElementById('reg_btn').style.cursor='pointer';
	document.getElementById('reg_btn').disabled=false;
	document.getElementById('reg_btn').style.background='#09c';	
	
	document.getElementById('frm_reg_error').innerHTML='Clave debe ser de 6 Digitos';
	document.getElementById('frm_reg_clave').focus();
	return false;
}
else
{
	document.getElementById('frm_reg_error').innerHTML='';
}

if(clave!=document.getElementById('frm_reg_rclave').value)
{
	document.body.style.cursor='auto';
	document.getElementById('reg_btn').style.cursor='pointer';
	document.getElementById('reg_btn').disabled=false;
	document.getElementById('reg_btn').style.background='#09c';	
		
	document.getElementById('frm_reg_error').innerHTML='Claves no Coinciden';
	document.getElementById('frm_reg_rclave').focus();
	return false;
}
else
{
	document.getElementById('frm_reg_error').innerHTML='';
}

															

	
$.ajax({
	cache:false,
	url:'lib/correom.php',
	datatype: "text",
    async:false,
	type:'POST',
	data:{nombre:nombre.toUpperCase(),email:email,cedula:ci,clave:clave,fono:fono},
   	beforeSend: function(jqXHR, textStatus)
	{
		document.getElementById('frm_reg_error').innerHTML='procesando.....';
		document.body.style.cursor='wait';
		document.getElementById('reg_btn').style.cursor='wait';
		document.getElementById('reg_btn').style.background='#C1FFFF';
		document.getElementById('reg_btn').disabled=true;
    },
	success:function(dato)
	{

		document.getElementById('frm_reg_error').innerHTML=dato;
		
	},
	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')
	    {
			document.getElementById('frm_reg_ci').value='';
			document.getElementById('frm_reg_email').value='';
			document.getElementById('frm_reg_descri').value='';
			document.getElementById('frm_reg_fono').value='';
		    document.getElementById('frm_reg_clave').value='';
     		document.getElementById('frm_reg_rclave').value='';
			
			document.body.style.cursor='auto';
			document.getElementById('reg_btn').style.cursor='pointer';
			document.getElementById('reg_btn').style.background='#09c';
    	  	document.getElementById('reg_btn').disabled=false;
			errorx=99;
			ci_tmp='';
			semail_tmp='';

		}
	},
	timeout:30000

});								
								
}


function _autocompletar(e){
if(e.keyCode==8 || e.keyCode==46){return false;}
if(e.keyCode==13){_buscar();}
var criterio = document.getElementById('criterio').value;


if(criterio.length<2){ console.log(criterio); return false;}
$.ajax({
	cache:false,
	url:'/lib/autocompletar.php',
	datatype: "text",
    async:true,
	type:'POST',
	data:{criterio:criterio},
   	beforeSend: function(jqXHR, textStatus){},
	success:function(dato){
		document.getElementById('datox').innerHTML=dato; 
		//document.getElementById('busqueda').innerHTML=dato; 
		console.log(dato)
		},
	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.');
           } else if (exception === 'abort') {
               console.log('Ajax request aborted.');
           } else {
               console.log('Uncaught Error: ' + jqXHR.responseText);
           }

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

});								


}

function _buscar()
{
var criterio = document.getElementById('criterio').value;
//if(criterio.length<2){ console.log(criterio); return false;}
location.href='index.php?id='+criterio;
}

function _responsitive_mnu()
{

	if(document.getElementById('responsitive_cont_mnu').style.display=='block'){
		document.getElementById('responsitive_cont_mnu').style.display='none';
		document.getElementById('contenedor2').style.display='block';
		document.getElementById('criterio_btn').style.display='block';
		document.getElementById('criterio').style.display='block';
		document.getElementById('contenedor1').style.position='fixed';
		//document.getElementById('contenedor1').style.position='absolute';
		
	}else{
		document.getElementById('responsitive_cont_mnu').style.display='block';
		document.getElementById('contenedor2').style.display='none';
		document.getElementById('criterio_btn').style.display='none';
		document.getElementById('criterio').style.display='none';
		document.getElementById('contenedor1').style.position='absolute';
		//document.getElementById('contenedor1').style.position='fixed';
			
	}

}
/*
function _limpia()
{
	document.getElementById('err_msg').innerHTML='';
}
*/
function _adr_dato(idx){

$.ajax({
		cache:false,
		url:'lib/op_hoja_addr.php',
		datatype: "text",
	    async:true,
		type:'POST',
		data:{idx:idx},
		beforeSend: function(jqXHR, textStatus){}, 
		success:function(dato, textStatus, jqXHR)
		{		
			
			document.getElementById('nom_lbl').innerHTML=$(dato).find("nombre").text();
			document.getElementById('dir_lbl').innerHTML=$(dato).find("direccion").text();
			document.getElementById('ciu_lbl').innerHTML=$(dato).find("ciudad").text();
			document.getElementById('tel_lbl').innerHTML=$(dato).find("telefono").text();
			document.getElementById('ema_lbl').innerHTML=$(dato).find("email").text();
			document.getElementById('con_lbl').innerHTML=$(dato).find("contacto").text();
			
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              alert('Sin Conexion: Verifique Red.');
           } 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') {
               alert('Servidor no Responde');
			   location.href='../salir.php';
           } else if (exception === 'abort') {
               console.log('Ajax request aborted.');
           } else {
               console.log('Uncaught Error: ' + jqXHR.responseText);
           }

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



}

function _cesto()
{
	
	$.ajax({
			cache:false,
			url:'lib/cesm.php',
			datatype: "text",
			async:false,
			type:'POST',
			data:{},
			beforeSend: function(jqXHR, textStatus){}, 
			success:function(dato, textStatus, jqXHR)
			{		
				
				document.getElementById('contenedor2').innerHTML=dato
				
			},
			error:function(jqXHR,textStatus,errorThrown )
			{
			   if (jqXHR.status === 0) {
				  alert('Sin Conexion: Verifique Red.');
			   } 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') {
				   alert('Servidor no Responde');
				   location.href='../salir.php';
			   } else if (exception === 'abort') {
				   console.log('Ajax request aborted.');
			   } else {
				   console.log('Uncaught Error: ' + jqXHR.responseText);
			   }
	
			}, 
			 complete:function(jqXHR, textStatus){if(textStatus==='success'){ 
			 _responsitive_mnu();
			 window.history.pushState({}, "", "index.php?opt=ces");
			 }},
				timeout:90000
			});


}

function _iniciar_sesion()
{
	document.getElementById('frm_login').style.display='block';
	document.getElementById('sesion_btn').style.display='none';
	document.getElementById('cat_contenedor').style.display='none';
	document.getElementById('txt_ci').focus();

}
function _cerrar_frm()
{
	document.getElementById('frm_login').style.display='none';
	document.getElementById('cat_contenedor').style.display='block';
	document.getElementById('sesion_btn').style.display='block';
}

function _enviar_dir(dir)
{
	return false;
	$.ajax({
		cache:false,
		url:'lib/direnviom2.php',
		datatype: "text",
	    async:false,
		type:'POST',
		data:{},
		beforeSend: function(jqXHR, textStatus){}, 
		success:function(dato, textStatus, jqXHR)
		{		
			
			document.getElementById('contenedor2').innerHTML=dato
			
		},
		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              alert('Sin Conexion: Verifique Red.');
           } 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') {
               alert('Servidor no Responde');
			   location.href='../salir.php';
           } else if (exception === 'abort') {
               console.log('Ajax request aborted.');
           } else {
               console.log('Uncaught Error: ' + jqXHR.responseText);
           }

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

}

/*
function _agregar(idx)
{
	var cant=document.getElementById('item_'+idx).value;
	document.getElementById('err_msg').innerHTML='';

	var arr=document.getElementsByClassName('txt_cant').length-1;
	var cantx,pvpx,subx;
	var subx_tmp=0;
	var ivax=0;
	var iva_tmp;
	var iva_acum=0;
	for(i=0;i<=arr;i++)
	{
		cantx=parseInt(document.getElementsByClassName('txt_cant').item(i).value);
		cantx=cantx*100000000;
		pvpx=parseFloat(document.getElementsByClassName('txt_pvp').item(i).value);
		pvpx=pvpx*100000000;
		
		ivax=parseFloat(document.getElementsByClassName('txt_iva').item(i).value);
		
		subx=cantx*pvpx;
		subx=Math.round(subx);
		subx_tmp+=subx;
		iva_tmp=subx*(ivax/100);
		
		iva_acum+=iva_tmp;
		iva_tmp=iva_tmp/10000000000000000;
		
		subx=subx/10000000000000000;
		
		document.getElementsByClassName('txt_sub').item(i).value=subx.toFixed(2);
	}
	subx_tmp=subx_tmp/10000000000000000;
	iva_acum=iva_acum/10000000000000000;
	document.getElementById('subtotal').value=subx_tmp.toFixed(2);
	document.getElementById('iva').value=iva_acum.toFixed(2);


$.ajax({
		url:'ces2.php',
		type:'POST', 
		async:false,
		data:{idx:idx,cant:cant},
		success:function(dato){
			
			document.body.style.cursor='auto';
			document.getElementById('err_msg').innerHTML=dato;
		}, 

		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              alert('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'){setTimeout(_limpia, 5000);}
			},
		timeout:30000
	});

}
*/

function _modifica(idn,idd,opt){
	var cant=0;
	if(opt==''){
			cant=document.getElementById('cant_'+idd).value;
		}
	$.ajax({
		url:'lib/ces2.php',
		type:'POST', 
		async:false,
		data:{idn:idn,idd:idd,opt:opt,cant:cant},
		success:function(dato){
			console.log(dato);
			document.body.style.cursor='auto';
			if($(dato).find("error").text()=="0"){
				if(opt=='d'){
					document.getElementById('filla_'+idn+idd+'1').style.display='none';
					document.getElementById('filla_'+idn+idd+'2').style.display='none';
					document.getElementById('filla_'+idn+idd+'3').style.display='none';
				}
				if(opt!='e'){
					document.getElementById('subt_'+idd).value=$(dato).find("subt").text();
					document.getElementById('subtotal').value=$(dato).find("subtotal").text();
					document.getElementById('iva').value=$(dato).find("ivat").text();
					document.getElementById('total').value=$(dato).find("total").text();
				}
				if(opt=='e'){window.location='index.php?opt=cesfm';}
			}
			else{alert($(dato).find("error").text());}
			
		}, 

		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              alert('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'){}},
		timeout:30000
	});

}

function _dperm(){
	var razoc=document.getElementById('razoc').value;
	var nomcom=document.getElementById('nomcom').value;
	var n1=document.getElementById('n1').value;
	var n2=document.getElementById('n2').value;
	var a1=document.getElementById('a1').value;
	var a2=document.getElementById('a2').value;
/*	var c1=document.getElementById('c1').value;
	var c2=document.getElementById('c2').value;
	var cn=document.getElementById('cn').value;
	var c3=document.getElementById('c3').value; */
//	var e1=document.getElementById('e1').value;
//	var t1=document.getElementById('t1').value;
	var statusr=document.getElementById('statusr').value;
	var fn=document.getElementById('fn').value;
	var sexo=document.getElementById('sexo').value;
	var pais=document.getElementById('pais').value;
//	var ciudad=document.getElementById('ciudad').value;
	var pasaporte=document.getElementById('pasaporte').value;
	var nick=document.getElementById('nick').value;
	
/*	
	document.getElementById('dper_err_razoc').innerHTML='';
	document.getElementById('dper_err_nomcom').innerHTML='';
	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_c1').innerHTML='';
	document.getElementById('dper_err_c2').innerHTML='';
	document.getElementById('dper_err_cn').innerHTML='';
	document.getElementById('dper_err_c3').innerHTML='';
	document.getElementById('dper_err_e1').innerHTML='';
	document.getElementById('dper_err_t1').innerHTML='';
	document.getElementById('dper_err_fn').innerHTML='';
	document.getElementById('dper_err_pasaporte').innerHTML='';
	document.getElementById('dper_err_nick').innerHTML='';
*/	
	document.getElementById('dper_err').innerHTML='';
	
	if(n1.length<2){
		document.getElementById('n1').focus;
		document.getElementById('dper_err').innerHTML='Nombre es Requerido'; 
		return false;
	}
	if(a1.length<2){
		document.getElementById('a1').focus;
		document.getElementById('dper_err_a1').innerHTML='Apellido es Requerido'; 
		return false;
	}
/*	if(c1.length<5){
		document.getElementById('c1').focus;
		document.getElementById('dper_err_c1').innerHTML='Calle es Requerida'; 
		return false;
	}
	if(t1.length<5){
		document.getElementById('t1').focus;
		document.getElementById('dper_err_t1').innerHTML='Telefono es Requerido;'; 
		return false;
	}
	if(fn.length==0){
		document.getElementById('f1').focus;
		document.getElementById('dper_err_fn').innerHTML='Fecha Nacimiento es Requerida'; 
		return false;
	}*/

	$.ajax({
		url:'lib/dperm2.php',
		type:'POST', 
		async:false,
		data:{
		razoc:razoc,
		nomcom:nomcom,
		n1:n1,
		n2:n2,
		a1:a1,
		a2:a2,
	//	c1:c1,
	//	c2:c2,
	//	cn:cn,
	//	c3:c3,
	//	e1:e1,
	//	t1:t1,
		statusr:statusr,
		fn:fn,
		sexo:sexo,
		pais:pais,
	//	ciudad:ciudad,
		pasaporte:pasaporte,
		nick:nick
		},
		success:function(dato){
			console.log(dato);
			document.getElementById('dper_err').innerHTML=$(dato).find("error").text();
		}, 

		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              alert('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'){}},
		timeout:30000
	});



}

function _adrsm(idx,action)
{

	var email=document.getElementById('email').value;
	var calle1=document.getElementById('calle1').value;
	var calle2=document.getElementById('calle2').value;
	var callen=document.getElementById('callen').value;
	var calle3=document.getElementById('calle3').value;
	var tlfn=document.getElementById('tlfn').value;
	var ext=document.getElementById('ext').value;
	var contacto=document.getElementById('contacto').value;
	var ciudad=document.getElementById('ciudad').value;

	
	if(idx=='0'){
		
		if(email.length!=0){
			var filtro_email=/[\w-\.]{3,}@([\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}/;
			if(!filtro_email.test(email)){document.getElementById('dper_err').innerHTML='Email Incorrecto';return false;}
		}
		if(calle1.length==0){document.getElementById('dper_err').innerHTML='Calle, Cdla o Edif requerido';return false;}
	
	
	}	
	
	
	$.ajax({
		url:'lib/adrsm2.php',
		type:'POST', 
		async:false,
		data:{idx:idx,action:action,
		email:email,
		calle1:calle1,
		calle2:calle2,
		callen:callen,
		calle3:calle3,
		tlfn:tlfn,
		ext:ext,
		contacto:contacto.toUpperCase(),
		ciudad:ciudad},
		success:function(dato){
			
			document.body.style.cursor='auto';
			alert($(dato).find("error").text());
			location.reload();
			
		}, 

		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              alert('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'){/*setTimeout(_limpia, 5000);*/}
			},
		timeout:30000
	});

}

function _finalizar()
{
	document.body.style.cursor='wait';
	$.ajax({
		url:'lib/carf2.php',
		type:'POST', 
		async:false,
		data:{},
		success:function(dato){
			
			document.body.style.cursor='auto';
			alert($(dato).find("error").text());
			if($(dato).find("error").text()=='Finalizo con exito'){
				window.location ='index.php';
			}
			
			//console.log(dato);
			
			
		}, 

		error:function(jqXHR,textStatus,errorThrown )
		{
           if (jqXHR.status === 0) {
              alert('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'){/*setTimeout(_limpia, 5000);*/}
			},
		timeout:30000
	});


}
function _imagengrande(ruta){
	console.log(ruta);
	document.getElementById('img_display').src=ruta;
	//document.getElementById('frm_contenedor').clientwidth=screen.width;
	//document.getElementById('frm_contenedor').clientheight=screen.height;
	
	//document.getElementById('frm_contenedor').style.width=screen.width+'px';
	//document.getElementById('frm_contenedor').style.height=screen.height+'px';
	//document.getElementById('frm_contenedor').style.display='none';
//document.getElementById('frm_contenedor').clientwidth=800;
console.log(screen.width);
console.log(screen.height);
//document.getElementById('img_cont').style.height=screen.height+'px';
document.getElementById('img_cont').style.display='block';
document.getElementById('cat_contenedor').style.display='none';

document.getElementById('img_display').style.width='80%';
//var altura=screen.height-200;
//document.getElementById('img_display').style.height=altura+'px';
//document.getElementById('img_display').style.maxHeight=screen.height-50;

}
function _imagenpeque()
{
	document.getElementById('img_cont').style.display='none';
	document.getElementById('cat_contenedor').style.display='block';

}

</script>

<style type="text/css">
body{ margin:0px; padding:0px;}
#contenedor{ width:96%; padding:4px; margin:0px; box-sizing:border-box; box-sizing:content-box; max-width:1000px;}
.talla_error{ height:20px; padding:0px; margin:0px;}
#frm_contenedor{/*position: absolute; z-index:1;*/ width:99%;  padding-right:0px; margin:0px; display:none; box-sizing:border-box; box-sizing:content-box;}
#cat_contenedor{ width:100%;}


.frm_ingreso_lbl{font-weight:bolder; font-size:18px;}

.frm_txt        {width:97%; height:40px; font-size:22px; border:solid 1px #000000; padding:2px; margin:0px; }
.frm_txt:hover{ border-color:#9C0;}
.btn_log{background:#09c; border:solid 1px #039; font-size:18px; font-weight:bolder; width:98%; height:40px; padding:2px; margin:0px; color:#FFF; }
.btn_log:hover{ cursor:pointer;}
#frm_login{ width:100%; margin-right:2px; box-sizing:border-box; box-sizing:content-box; box-sizing:content-box; padding:2px;}
#criterio{ height:40px; border:solid 1px #09c; box-sizing:border-box; width:100%; font-size:18px; }
#criterio_btn{}
#logo2_img{ height:40px; box-sizing:border-box; box-sizing:content-box;}
#sesion_btn{ height:35px; box-sizing:border-box; box-sizing:content-box;}
.cat_img{ width:100%; max-width:250px;}
#responsitive_btn{ padding:0px; margin:0px; cursor:pointer;}
#responsitive_mnu{ list-style:none; margin:0px; padding:0px;}
#responsitive_cont_mnu{ background-color:#19aeff; box-sizing:border-box; box-sizing:content-box;width:100%; margin-top:-5px; }
#responsitive_cont_mnu a{ text-decoration:none;}
.responsitive_mnu_opt{ font-size:18px; font-weight:bolder; 
border:#09c solid 1px; 
box-sizing:border-box; 
box-sizing:content-box; 
height:40px; color:#FFF;
vertical-align:middle; 
padding:4px; margin:0px; 
padding-top:20px; 
background-color:#19aeff;
}
.responsitive_mnu_opt a{color:#FFF; }
.txt_cant{    width:100%; border:#000 solid 1px; text-align:right; height:35px; font-size:16px; padding-right:2px;}
.txt_pvp{     width:100%; border:#000 solid 1px; text-align:right; height:35px; font-size:16px; padding-right:2px; background: #FFF; color:#000;}
.txt_sub{     width:100%; border:#000 solid 1px; text-align:right; height:35px; font-size:16px; padding-right:2px; background: #FFF; color:#000;}
#subtotal{     width:100%; border:#000 solid 1px; text-align:right; height:35px; font-size:16px; padding-right:2px; background: #FFF; color:#000;}
#iva{     width:100%; border:#000 solid 1px; text-align:right; height:35px; font-size:16px; padding-right:2px; background: #FFF; color:#000;}
#total{     width:100%; border:#000 solid 1px; text-align:right; height:35px; font-size:16px; padding-right:2px; background: #FFF; color:#000;}
.agrega_btn{  width:100%; border:#000 solid 1px; text-align:center; height:35px; }
.elitmina_btn{width:100%; border:#000 solid 1px;                   height:40px;}
.cesto_img{ max-width:100px !important;}
.dper_lbl{ width:98%; text-align:left; font-size:18px; word-wrap:break-word; font-weight:bolder; padding-top:5px; }
.dper_txt{ width:98%;text-align:left; font-size:16px; height:30px; border:solid 1px #000000; padding:5px; padding-top:10px; box-sizing:border-box; box-sizing:content-box; vertical-align:middle;}
.dper_err{ width:98%;text-align:left; font-size:18px; height:30px; }
#dper_btn{width:98%; height:45px; background:#09c; color:#FFF; border:solid 1px #09c; font-size:16px; font-weight:bolder; cursor:pointer;}
.c2{ border-bottom:#09c solid 1px; font-size:16px; font-weight:bolder; margin-bottom:5px; }

#img_cont{ width:100%;  display:none;}
</style>
</head>

<body>
<div align="center">
<div id="contenedor">


<div align="center" id="contenedor1" style=" position:fixed; z-index:1; top:0px; left:0px; right:0px; width:98%; background:#FFF; padding:4px; box-sizing:border-box; box-sizing:content-box;">
	<table width="98%" cellpadding="0" cellspacing="0" border="0" style="max-width:1000px;">
<tr valign="top">
	<td align="left"><a href="index.php"><img src="http://vcrxol.com/_logo/logo<?php echo $empr_codigo ?>1.png"   id="logo2_img" /></a></td>
	<td align="right" style="background:http://vcrxol.com/_img/menu_responsitive_btn.png;">
		<input type="button" value="Iniciar Secion" id="sesion_btn" onclick="_iniciar_sesion();" style=" <?php if(!empty($_SESSION['user_vcrx_id'])){echo 'display:none;';}?> ">	
		<img  src="http://vcrxol.com/_img/menu_responsitive.png" id="responsitive_btn" style=" <?php if(empty($_SESSION['user_vcrx_id'])){echo 'display:none;';}?> " onClick="_responsitive_mnu();" />
	</td>
</tr>    
<tr valign="top">
<td colspan="2">
        <div id="responsitive_cont_mnu" style=" display:none; ">
		   		<div><a href="index.php?opt=catm"><div class="responsitive_mnu_opt" >CATALOGO</div></a></div>
                <div><a href="index.php?opt=cesm"><div class="responsitive_mnu_opt" >CARRITO</div></a></div>
			    <div><a href="index.php?opt=dperm"><div class="responsitive_mnu_opt" >DATOS PERSONALES</div></a></div>
                <div><a href="index.php?opt=dirm"><div class="responsitive_mnu_opt" >DIRECCIONES</div></a></div>
			   <!-- <div><a href="#"                ><div class="responsitive_mnu_opt" >PEDIDOS</div></a></div> -->
			    <div><a href="index.php?opt=depo"><div class="responsitive_mnu_opt" >DEPOSITOS</div></a></div>
			    <div><a href="salir.php"><div class="responsitive_mnu_opt" >SALIR</div></a></div>
		</div>
</td>
</tr>
<tr valign="top">
	<td  align="right"><input type="search" id="criterio"  autocomplete="off" list="busqueda"  onKeyDown="_autocompletar(event);" value="<?php echo $_GET['id'];?>" /></td>
    <td  align="left" style="background:http://vcrxol.com/_img/search_bgn.png"><input type="image" src="http://vcrxol.com/_img/search.png" onClick="_buscar();" id="criterio_btn"  /></td>
</tr>
<tr><td colspan="2"><div id="datox"><datalist id="busqueda"></datalist></div></td></tr>
</table>
</div>




<div id="contenedor2" style="margin-top:100px;">
	<div id="frm_login" align="center" style="display:none;">
    <div id="frm_cerrar" align="right"><input type="button" value="Cerrar" onclick="_cerrar_frm();" />    </div>
	<table width="100%" border="0" cellpadding="4">
	<tr><td><div class="frm_ingreso_lbl">E-mail/Cedula</div></td></tr>
	<tr><td><input type="text"     id="txt_ci"    class="frm_txt" placeholder="CI/RUC" onKeyPress="usuario(event,this);" autocomplete="off"/></td></tr>
    <tr><td><div class="frm_ingreso_lbl">Clave</div></td></tr>
	<tr><td><input type="password" id="txt_clave" class="frm_txt" placeholder="Clave"  onKeyPress="clave(event);"        autocomplete="off"/></td></tr>
	<tr><td><input type="button"   value="Iniciar Sesion" id="boton"  onClick="valida_ci_ingreso();"  class="btn_log"  /></td></tr>
	<tr><td><div id="error"></div></td></tr>
	<tr><td><a href="../pas.php" style="color:#09c; font-weight:bolder;">Olvido su Clave?</a></td></tr>
	<tr><td>Si no tienes una cuenta</td></tr>
	<tr><td><h1 style="margin:0px; padding:0px;">REGÍSTRATE</h1></td></tr>
	<tr><td><div class="frm_reg_lbl">Cedula</div></td></tr>
	<tr><td><input type="text" id="frm_reg_ci"         class="frm_txt" placeholder="Cedula" maxlength="13"  /></td></tr>
	<tr><td><div class="frm_reg_lbl">Email</div></td></tr>
	<tr><td><input type="email" id="frm_reg_email"     class="frm_txt" placeholder="Email" maxlength="40"   /></td></tr>
	<tr><td><div class="frm_reg_lbl">Telefono</div></td></tr>
	<tr><td><input type="text" id="frm_reg_fono"       class="frm_txt" placeholder="Telefono" maxlength="14" /></td></tr>
	<tr><td><div class="frm_reg_lbl">Nombres</div></td></tr>
	<tr><td><input type="text" id="frm_reg_descri"     class="frm_txt" style="text-transform:uppercase;" placeholder="Nombre Completo" maxlength="50" /></td></tr>
	<tr><td><div class="frm_reg_lbl">Clave</div></td></tr>
	<tr><td><input type="password" id="frm_reg_clave"  class="frm_txt" placeholder="Clave" maxlength="6" /></td></tr>
	<tr><td><div class="frm_reg_lbl">Repita Clave</div></td></tr>
	<tr><td><input type="password" id="frm_reg_rclave" class="frm_txt" placeholder="Repita Clave" maxlength="6" /></td></tr>
    <tr><td><div align="center" id="frm_reg_error" style="word-wrap:break-word; min-height:30px; color:#F00;"></div></td></tr>
    <tr><td><input type="button" onClick="val_form1();" value="Termina de Registrarte!" id="reg_btn" class="btn_log"  /></td></tr>
	
	</table>
    </div>
	
    <div id="cat_contenedor">
	<?php 
        
        if($_GET['opt']=='cesm' ){require('../_lib/cesm.php');}
		if($_GET['opt']=='ces2m' ){require('../_lib/direnviom.php');}
		if($_GET['opt']=='dperm' ){require('../_lib/dperm.php');}
		if($_GET['opt']=='dirm' ){require('../_lib/adrsm.php');}
		if($_GET['opt']=='depo' ){require('../_lib/dcnotifica0m.php');}
		if($_GET['opt']=='cesfm' ){require('../_lib/carfm.php');}
        //if($_GET['opt']=='catm' ){require('../_lib/catm.php');}
		if($_GET['opt']=='catm' || empty($_GET['opt']) || empty($_SESSION['user_vcrx_id']) ){require('../_lib/catm.php');}
		
    ?>
	</div>
</div>

</div>
</div>



<?php
/*
$user_agent = $_SERVER['HTTP_USER_AGENT'];

function getBrowser($user_agent){

if(strpos($user_agent, 'MSIE') !== FALSE)
   return 'Internet explorer';
 elseif(strpos($user_agent, 'Edge') !== FALSE) //Microsoft Edge
   return 'Microsoft Edge';
 elseif(strpos($user_agent, 'Trident') !== FALSE) //IE 11
    return 'Internet explorer';
 elseif(strpos($user_agent, 'Opera Mini') !== FALSE)
   return "Opera Mini";
 elseif(strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR') !== FALSE)
   return "Opera";
 elseif(strpos($user_agent, 'Firefox') !== FALSE)
   return 'Mozilla Firefox';
 elseif(strpos($user_agent, 'Chrome') !== FALSE)
   return 'Google Chrome';
 elseif(strpos($user_agent, 'Safari') !== FALSE)
   return "Safari";
 else
   return 'No hemos podido detectar su navegador';


}


$navegador = getBrowser($user_agent);
 
echo "El navegador con el que estás visitando esta web es: ".$navegador;
*/
?>



<div id="img_cont">
	<div align="right" onClick="_imagenpeque();" style="padding-right:20px; font-size:30px; font-weight:bolder;">X</div>
    <div align="center">
    <img id="img_display"  />
    </div>
</div>


</body>
</html>