var petition = null;
var url = "http://"+location.host+"/inversiones/include/";

function inicializar_XML(){
    if(window.XMLHttpRequest){
        return new XMLHttpRequest();
    }else if(window.ActiveXObject){
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
}
function enviarPost(iduser,valora){
    var retornar = null;
    var doc = document.getElementById(iduser);
    retornar = valora+"=" + encodeURIComponent('true') +
               "&monto=" + encodeURIComponent( doc.value );
    return retornar;
}
function generBoton(iduser,usphp){
    petition = inicializar_XML();
    petition.open('POST', url+usphp+'_boton.php', true);
    petition.onreadystatechange = function(){
        if(petition.readyState == 4){
            if(petition.status == 200){
                var botonpara = iduser.split('-');
                var botonPon = document.getElementById('inver'+usphp+botonpara[1]);
                botonPon.innerHTML = petition.responseText;
                if(usphp == 'paypal')
                    var sacare = 'alertpay';
                else
                    var sacare = 'paypal';
                var sacar = document.getElementById('cuadro'+sacare+botonpara[1]);
                sacar.innerHTML = '&nbsp;';
            }
        }
    }
    petition.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    var inver = enviarPost(iduser,usphp);
    petition.send(inver);
}