function empirefe(){
	url="";
	url+="&tipo="+"l";
	url+="&atmosphere="+VGmodo;
	url+="&document="+VGdocumento;
	console.log(url)
    Rpage="/xades/facturaem.php"
	send_data(url,Rpage,"ímprimirpdf");

    
}
function doCallback(callback,item) {
	eval(callback + '(item)');
}

function send_data(parameters,ruta,funcion){
    console.log(parameters+ruta)
    var XHR= new XMLHttpRequest();
    XHR.open('POST',ruta,true);
    XHR.setRequestHeader('content-type','application/x-www-form-urlencoded');
    XHR.send('codemp='+VGempresa+'&'+parameters);
    XHR.onreadystatechange=function(){
        if(this.readyState==4 && this.status==200){
            var response=this.responseText;
           // console.log(response)
            doCallback(funcion, response);
            //LLAMAR PARA QUE SE ABRA LA NUEVA VENTANA Y CREE EL FORMULARIO
        }
    }
}

function doCallback(callback,item) {
	eval(callback + '(item)');
}


function ímprimirpdf(answer){
	swAdj=0
	estadofe=answer.slice(-2);
	console.log(estadofe)
	if (estadofe=='00'){//mandar a imprimir
		cRuta="facturaem.php?document="+VGdocumento+"&codemp="+VGempresa+"&atmosphere=1"
		window.open(cRuta, '_blank');
		setTimeout(() => {
    		cRuta="report/facturapost.php?document="+VGdocumento+"&codemp="+VGempresa
			window.open(cRuta, '_blank');
		}, 4000);
		
	}
	return;
}

function getGET(){
    var loc = document.location.href;
    var getString = loc.split('?')[1];
    try {
          var GET = getString.split('&');
             var get = {};//this object will be filled with the key-value pairs and returned.
          for(var i = 0, l = GET.length; i < l; i++){
              var tmp = GET[i].split('=');
              get[tmp[0]] = unescape(decodeURI(tmp[1]));
          }
     } catch(e) {
         get="NOPARAM";
     }
    return get;
 }
