
var xmlDoc = null;
var holder_id = null;
var fun_after = null;
function getAbsPosition(e){x=0; y=0; do with(e){x+=offsetLeft;y+=offsetTop} while(e=e.offsetParent); return{x:x,y:y}}

function load(url,txt,hid,dopisz) {
  fun_after = false;
  holder_id = hid;
  dopisac = dopisz;
  if(document.getElementById("ind")) {
    var pozycja=getAbsPosition(document.getElementById(hid));
    document.getElementById("ind").style.left = pozycja.x+'px';
    document.getElementById("ind").style.top = pozycja.y+'px';
    document.getElementById("ind").style.width = document.getElementById(hid).offsetWidth+'px';
    document.getElementById("ind").style.height = document.getElementById(hid).offsetHeight+'px';
    document.getElementById("ind").style.display = "block";
    document.getElementById("ind").innerHTML="<table width=\"100%\" height=\"100%\"><tr><td align=\"center\" valign=\"middle\"><img src=http://z.nf.pl/i2/indicator.gif></td></tr></table>";
  }

  if (typeof window.ActiveXObject != 'undefined' ) {
  xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
  xmlDoc.onreadystatechange = process;
} else {
  xmlDoc = new XMLHttpRequest();
  xmlDoc.onload = process;
}
  xmlDoc.open( "POST", url, true );
  xmlDoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  //xmlDoc.setRequestHeader('Content-Type', 'charset=iso-8859-2');
  //xmlDoc.overrideMimeType('text/html; charset=ISO-8859-2');
  xmlDoc.send( txt );
}

function load2(url,txt,hid,dopisz,fun_name) {
  fun_after = fun_name;
  holder_id = hid;
  dopisac = dopisz;
  if(document.getElementById("ind")) {
    var pozycja=getAbsPosition(document.getElementById(hid));
    document.getElementById("ind").style.left = pozycja.x+'px';
    document.getElementById("ind").style.top = pozycja.y+'px';
    document.getElementById("ind").style.width = document.getElementById(hid).offsetWidth+'px';
    document.getElementById("ind").style.height = document.getElementById(hid).offsetHeight+'px';
    document.getElementById("ind").style.display = "block";
    document.getElementById("ind").innerHTML="<table width=\"100%\" height=\"100%\"><tr><td align=\"center\" valign=\"middle\"><img src=http://z.nf.pl/i2/indicator.gif></td></tr></table>";
  }

  if (typeof window.ActiveXObject != 'undefined' ) {
    xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
    xmlDoc.onreadystatechange = process;
  } else {
    xmlDoc = new XMLHttpRequest();
    xmlDoc.onload = process;
  }
    xmlDoc.open( "POST", url, true );
    xmlDoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    //xmlDoc.setRequestHeader('Content-Type', 'charset=iso-8859-2');
    //xmlDoc.overrideMimeType('text/html; charset=ISO-8859-2');
    xmlDoc.send( txt );
}

function process() {
  if (xmlDoc.readyState == 4) {
    if (xmlDoc.status == 200) {
      if(document.getElementById("ind")) {
        document.getElementById("ind").innerHTML="";
        document.getElementById("ind").style.display="none";
      }
      if (dopisac) {
        if (holder_id) document.getElementById(holder_id).innerHTML+=xmlDoc.responseText;
        if (holder_id) document.getElementById(holder_id).value+=xmlDoc.responseText;
      } else {
        if (holder_id) document.getElementById(holder_id).innerHTML=xmlDoc.responseText;
        if (holder_id) document.getElementById(holder_id).value=xmlDoc.responseText;
      }
      if (fun_after)
        eval(fun_after+'()');
    }
  }
}


