var lastPort = null;
function request(params, op){ 
    document.body.style.cursor = 'wait';
    qspop.op = true;
    qspop.hideqsnodeNow();
    setStatusBusy();
    var xhr = xprox.GetXHR(function(xhr){requestReturned(xhr,op);});
    return xprox.SendXHR(xhr,params);
}
function s_plot(path){
    for(i=0;i<20;i++){
        if(document.getElementById('p1s'+i+'_title'))
            setHeaderColor('p1s'+i+'_title','');
     }   
    var rezDDL = document.getElementById('rezDDL');
    document.getElementById('rez').value = rezDDL[rezDDL.selectedIndex].value;
    request(form2url('pform'),r_plot);
}
var dobusy = false;
var mpne;
function setStatusBusy(){
    dobusy = true;
    mpne = document.getElementById('pbutton');
    mpne.style.color = 'white';
    mpne.style.background = 'blue';
    mpne.value = 'Busy';
    mpne.disabled = true;
    dissipate(1);
}
function setStatusReady(){
    dobusy = false;
    mpne = document.getElementById('pbutton');
    mpne.style.opacity = 1;
    mpne.style.filter = "alpha(opacity=100)";
    mpne.style.background = '';
    mpne.value = 'Plot';
    mpne.style.color = '';
    mpne.disabled = false;
}
function solidify(s){
    if(dobusy){
      s = parseFloat(s);
      mpne.style.opacity = s;
      mpne.style.filter = 'alpha(opacity='+(s*100)+')';
      if(s >= 1){mpne.style.color = 'white';dissipate(1); return;}
      var z = 'solidify(\''+(s+.1)+'\')';
      window.setTimeout(z, 100);
    }
}
function dissipate(s){
    if(dobusy){
      s = parseFloat(s);
      mpne.style.opacity = s;
      mpne.style.filter = 'alpha(opacity='+(s*100)+')';
      if(s <= 0){mpne.style.color = 'yellow';solidify(0); return;}
      var z = 'dissipate(\''+(s-.1)+'\')';
      window.setTimeout(z, 100);
    }
}
function form2url(formid){
    var inputs = document.getElementById(formid).getElementsByTagName("input");
    var rst = '';
    for(i=0;i<inputs.length;i++){
        if(i>0) rst+='&';
        rst+=inputs[i].name+'='+inputs[i].value;
    }
    return rst;
}