   var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) {
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      var imprime=true;
      if (http_request.readyState == 4) {
      if (http_request.status == 200) {
      result = http_request.responseText;
    if(result.indexOf("[PED2]",0)!=-1){imprime=false;
	document.getElementById('salida2').innerHTML=result.substring(result.indexOf("[PED2]",0)+6,result.length);}
    if(result.indexOf("[PED]",0)!=-1){
    window.opener.counter_productos=window.opener.counter_productos+1;
	imprime=false;
	window.opener.document.getElementById('salida2').innerHTML=result.substring(result.indexOf("[PED]",0)+5,result.length);
	window.close();
	}
	if(result.indexOf("[EVE]",0)!=-1){imprime=false;	
	document.getElementById('e_titulo').value="";
	document.getElementById('evento').innerHTML = result.substring(result.indexOf("[EVE]",0)+5,result.length);
	}
	if(result.indexOf("[OKF]",0)!=-1){
	imprime=false;	
	document.getElementById('boton1').disabled=true;
	document.getElementById('boton2').style.visibility="visible";
	document.getElementById("razon_social").value="";document.getElementById("razon_social").disabled=true;
    document.getElementById("direccion_empresa").value="";document.getElementById("direccion_empresa").disabled=true;
	document.getElementById("distrito").value="";document.getElementById("distrito").disabled=true;
    document.getElementById("telefono_empresa").value="";document.getElementById("telefono_empresa").disabled=true;
	document.getElementById("ruc_empresa").value="";document.getElementById("ruc_empresa").disabled=true;
	document.getElementById("correo_empresa").value="";document.getElementById("correo_empresa").disabled=true;
	document.getElementById("contacto_empresa").value="";document.getElementById("contacto_empresa").disabled=true;
	document.getElementById("txt_rubro").value="";document.getElementById("txt_rubro").disabled=true;
	document.getElementById("txt_clientes").value="";document.getElementById("txt_clientes").disabled=true;
	document.getElementById('salida').innerHTML = result.substring(result.indexOf("[OKF]",0)+5,result.length);
	}
	if(result.indexOf("[OK4]",0)!=-1){
	imprime=false;
	for(j=0;j<document.f1.length;j++){if(document.f1.elements[j].type.toLowerCase()=='checkbox')
	{document.f1.elements[j].checked=false;document.f1.elements[j].disabled=true;}}
	document.getElementById('salida').innerHTML = result.substring(5,result.indexOf("[REG]",0));
	document.getElementById('salida_2').innerHTML = result.substring(result.indexOf("[REG]",0)+5,result.length);
	document.getElementById("nombre").value="";document.getElementById("nombre").disabled=true;
    document.getElementById("paterno").value="";document.getElementById("paterno").disabled=true;
	document.getElementById("materno").value="";document.getElementById("materno").disabled=true;
    document.getElementById("dni").value="";document.getElementById("dni").disabled=true;
	document.getElementById("email").value="";document.getElementById("email").disabled=true;
	document.getElementById('boton1').disabled=true;
	document.getElementById('boton2').style.visibility="visible";
	document.getElementById("operacion").value="INGRESAR";
	cant++;
	}
	if(result.indexOf("[OK3]",0)!=-1){
	imprime=false;
	document.getElementById('salida').innerHTML = result.substring(5,result.indexOf("[REG]",0));
	document.getElementById('salida_2').innerHTML = result.substring(result.indexOf("[REG]",0)+5,result.length);
	document.getElementById("nombre").value="";document.getElementById("nombre").disabled=true;
    document.getElementById("paterno").value="";document.getElementById("paterno").disabled=true;
	document.getElementById("materno").value="";document.getElementById("materno").disabled=true;
    document.getElementById("cargo").value="";document.getElementById("cargo").disabled=true;
    document.getElementById("dni").value="";document.getElementById("dni").disabled=true;
	document.getElementById("telefono").value="";document.getElementById("telefono").disabled=true;
	document.getElementById("email").value="";document.getElementById("email").disabled=true;
	document.getElementById('boton1').disabled=true;
	document.getElementById('boton2').style.visibility="visible";
	document.getElementById("operacion").value="INGRESAR";
	cant++;
	}
	if(result.indexOf("[OK2]",0)!=-1){
	imprime=false;	
	document.getElementById('txt_distrito').options[0].selected=true;document.getElementById('txt_distrito').disabled=true;
	document.getElementById('boton1').disabled=true;
	document.getElementById('boton2').style.visibility="visible";
	document.getElementById("razon_social").value="";document.getElementById("razon_social").disabled=true;
    document.getElementById("direccion_empresa").value="";document.getElementById("direccion_empresa").disabled=true;
	document.getElementById("referencia").value="";document.getElementById("referencia").disabled=true;
    document.getElementById("telefono_empresa").value="";document.getElementById("telefono_empresa").disabled=true;
	document.getElementById("ruc_empresa").value="";document.getElementById("ruc_empresa").disabled=true;
	document.getElementById("gerente_general").value="";document.getElementById("gerente_general").disabled=true;
	document.getElementById("nombre_contacto").value="";document.getElementById("nombre_contacto").disabled=true;
    document.getElementById("correo_contacto").value="";document.getElementById("correo_contacto").disabled=true;
    document.getElementById("telefono_contacto").value="";document.getElementById("telefono_contacto").disabled=true;
	document.getElementById("cargo_contacto").value="";document.getElementById("cargo_contacto").disabled=true;
	document.getElementById("txt_rubro").value="";document.getElementById("txt_rubro").disabled=true;
	document.getElementById("txt_clientes").value="";document.getElementById("txt_clientes").disabled=true;
	document.getElementById('salida').innerHTML = result.substring(result.indexOf("[OK2]",0)+5,result.length);
	}
	if(result.indexOf("[OK1]",0)!=-1){
	for(j=0;j<document.f1.length;j++){if(document.f1.elements[j].type.toLowerCase()=='checkbox')
	{document.f1.elements[j].checked=false;}}	
	imprime=false;
	document.getElementById('salida').innerHTML = result.substring(5,result.indexOf("[REG]",0));
	document.getElementById('salida_2').innerHTML = result.substring(result.indexOf("[REG]",0)+5,result.length);
	document.getElementById("nombre").value="";document.getElementById("nombre").focus();
    document.getElementById("paterno").value="";
	document.getElementById("materno").value="";
    document.getElementById("dni").value="";
	document.getElementById("email").value="";
	document.getElementById("operacion").value="INGRESAR";
	cant++;
	}
	if(result.indexOf("[OK]",0)!=-1){
	imprime=false;
	document.getElementById('salida').innerHTML = result.substring(4,result.indexOf("[REG]",0));
	document.getElementById('salida_2').innerHTML = result.substring(result.indexOf("[REG]",0)+5,result.length);
	document.getElementById("nombre").value="";document.getElementById("nombre").focus();
    document.getElementById("paterno").value="";
	document.getElementById("materno").value="";
    document.getElementById("cargo").value="";
    document.getElementById("dni").value="";
	document.getElementById("telefono").value="";
	document.getElementById("email").value="";
	document.getElementById("operacion").value="INGRESAR";
	cant++;
	}
	if(result.indexOf("[PUB]",0)!=-1){imprime=false;document.getElementById('salida2').innerHTML=result.substring(5,result.length);}
	if(result.indexOf("[URL]",0)!=-1){imprime=false;window.location=result.substring(5,result.length);}
	if(result.indexOf("[ATOMIX]",0)!=-1){imprime=false;}
	if(result.indexOf("[EXAMEN]",0)!=-1){imprime=false;document.getElementById('salida'+result.substring(8,10)).innerHTML =result.substring(10,result.length);}
	if(result.indexOf("[SELECT]",0)!=-1){imprime=false;document.getElementById('salida_select').innerHTML =result.substring(8,result.length);}
	if(imprime==true){document.getElementById('salida').innerHTML = result; }           //innerText

		 }else{alert('There is a problem with your browser.');}
      }
   }
   
   function get(obj,tipo) {
	  var poststr,archivo;

	  if(tipo==1){
      poststr = "login=" + encodeURI( document.getElementById("login").value ) +
                "&password=" + encodeURI( document.getElementById("password").value );
      archivo='examen_printop_login.php';
	  }
	  
	  if(tipo==2){poststr = "recurso=" + encodeURI("descarga_atomix") + "&item=" + encodeURI("down_xp");archivo='post_atomix.php';}
	  if(tipo==3){poststr = "recurso=" + encodeURI("descarga_atomix") + "&item=" + encodeURI("down_98");archivo='post_atomix.php';}
	  if(tipo==4){
	  if(document.getElementById("select"+obj).value != "x"){
	  poststr="caja=" + encodeURI( document.getElementById("select"+obj).value ) +	"&numero=" + encodeURI(obj);
      archivo='examen_virtual_select.php';
	  }else{return false;}		  
	  }
	  if(tipo==5){
	  var mi_array=obj.split("-");
 	  poststr = "permiso=" + encodeURI(mi_array[0]) + "&usuario=" + encodeURI(mi_array[1]);archivo='/printop/post_menu.php';}
	  if(tipo==6){
	  if(document.getElementById("categoria_general").value != "x"){ 	  
	  poststr="id=" + encodeURI( document.getElementById("categoria_general").value);
      archivo='examen_virtual_select2.php';		  
	  }else{return false;}
	  }
	  if(tipo==7){poststr = "recurso=" + encodeURI("inicio_atomix");archivo='post_atomix.php';}
	  if(tipo==8){poststr = "recurso=" + encodeURI("envio_atomix") + "&correo=" + encodeURI(document.getElementById("correo").value) + "&password=" + encodeURI(document.getElementById("password").value);archivo='post_atomix.php';}
	  if(tipo==9){
	  if(document.f1.s4.checked==true){poststr = "recurso=" + encodeURI("registro_formulario") + "&estado=" + encodeURI(0);}
	  else{poststr = "recurso=" + encodeURI("registro_formulario") + "&estado=" + encodeURI(1);}
	  archivo='post_registro.php';
	  }
	  if(tipo==10){
	  var respuesta;
	  if(document.f1.capacitacion[0] != null){
	  var i; for (i=0;i<document.f1.capacitacion.length;i++){if(document.f1.capacitacion[i].checked)break;} 
	  respuesta=document.f1.capacitacion[i].value;
	  }else{respuesta=document.f1.capacitacion.value;}

	  poststr = "login=" + encodeURI( document.getElementById("login").value ) +
                "&password=" + encodeURI( document.getElementById("password").value )+
				"&capacitacion=" + encodeURI(respuesta);
      archivo='capacitacion_printop_post.php';	  
	  }
	  if(tipo==11){
	  poststr = "nombre=" + encodeURI( document.getElementById("nombre").value ) +
                "&paterno=" + encodeURI( document.getElementById("paterno").value )+
				"&materno=" + encodeURI( document.getElementById("materno").value )+
				"&cargo=" + encodeURI( document.getElementById("cargo").value )+
				"&dni=" + encodeURI( document.getElementById("dni").value )+
				"&telefono=" + encodeURI( document.getElementById("telefono").value )+
				"&email=" + encodeURI( document.getElementById("email").value )+
				"&operacion=" + encodeURI( document.getElementById("operacion").value );
      archivo='capacitacion_printop_post.php';	  
	  }
	  if(tipo==12){
      poststr = "nombre_empresa=" + encodeURI( document.getElementById("nombre_empresa").value ) +
                "&direccion_empresa=" + encodeURI( document.getElementById("direccion_empresa").value )+
				"&ruc_empresa=" + encodeURI( document.getElementById("ruc_empresa").value )+
				"&gerente_empresa=" + encodeURI( document.getElementById("gerente_empresa").value )+
				"&nombre_contacto=" + encodeURI( document.getElementById("nombre_contacto").value )+
				"&telefono=" + encodeURI( document.getElementById("telefono").value )+
				"&email=" + encodeURI( document.getElementById("email").value );
      archivo='capacitacion_printop_post.php';	  
	  }
	  if(tipo==13){
      poststr="id_archivo=" + encodeURI(obj.toString());
      archivo="post_noticia2.php";	  
	  }
	  if(tipo==14){
      poststr = "nombre=" + encodeURI( document.getElementById("nombre").value ) +
                "&paterno=" + encodeURI( document.getElementById("paterno").value )+
				"&materno=" + encodeURI( document.getElementById("materno").value )+
				"&cargo=" + encodeURI( document.getElementById("cargo").value )+
				"&dni=" + encodeURI( document.getElementById("dni").value )+
				"&telefono=" + encodeURI( document.getElementById("telefono").value )+
				"&telefonoEmpresa=" + encodeURI( document.getElementById("telefonoEmpresa").value )+
				"&celular=" + encodeURI( document.getElementById("celular").value )+
				"&email=" + encodeURI( document.getElementById("email").value )+
				"&empresa=" + encodeURI( document.getElementById("empresa").value );
      archivo="capacitacion_printop_post.php";	  
	  }
	  if(tipo==15){
      poststr = "idp=" + obj +
			    "&nombre_producto=" + encodeURI( document.getElementById("nombre_producto").value)+
                "&cantidad=" + encodeURI( document.getElementById("cantidad").value );
      archivo="post_pedidos.php";	  
	  }
	  if(tipo==16){
      poststr = "delete=" +  encodeURI(obj.toString());
      archivo="post_pedidos.php";	  
	  }
	  if(tipo==17){
      poststr = "razon_social=" + encodeURI( document.getElementById("razon_social").value ) +
                "&direccion_empresa=" + encodeURI( document.getElementById("direccion_empresa").value )+
				"&referencia=" + encodeURI( document.getElementById("referencia").value )+
				"&ruc_empresa=" + encodeURI( document.getElementById("ruc_empresa").value )+
				"&telefono_empresa=" + encodeURI( document.getElementById("telefono_empresa").value )+
				"&nombre_contacto=" + encodeURI( document.getElementById("nombre_contacto").value )+
				"&correo_contacto=" + encodeURI( document.getElementById("correo_contacto").value )+
				"&telefono_contacto=" + encodeURI( document.getElementById("telefono_contacto").value )+
				"&gerente_general=" + encodeURI( document.getElementById("gerente_general").value )+
				"&txt_rubro=" + encodeURI( document.getElementById("txt_rubro").value )+
				"&txt_clientes=" + encodeURI( document.getElementById("txt_clientes").value )+
				"&cargo_contacto=" + encodeURI( document.getElementById("cargo_contacto").value )+
				"&txt_distrito=" + encodeURI( document.getElementById("txt_distrito").value );
      archivo="capacitacion_printop_post.php";	  
	  }
	  if(tipo==18){
      poststr = "e_fecha=" + encodeURI( document.getElementById("e_fecha").value ) +
                "&e_titulo=" + encodeURI( document.getElementById("e_titulo").value )+
				"&e_hora=" + encodeURI( document.getElementById("e_hora").value )+
				"&e_minuto=" + encodeURI( document.getElementById("e_minuto").value)+
				"&e_hora1=" + encodeURI( document.getElementById("e_hora1").value )+
				"&e_minuto1=" + encodeURI( document.getElementById("e_minuto1").value)+
				"&max_part=" + encodeURI( document.getElementById("max_part").value);
	  archivo="feria_printop_post.php";	  
	  }
	  if(tipo==19){
      poststr="index_evento=" + encodeURI(obj);
	  archivo="feria_printop_post.php";	  
	  }
      makePOSTRequest(archivo, poststr);
   }
