
   var http_request = false;

    var gwhttp_request = false;

    function ajax2(request, target) {

        if (document.getElementById(target) == null) {
           queueDelete();
           return;
        }

	fade(target);

        //document.getElementById('loading').innerHTML = "<table border=0 cellspacing=0 cellpadding=2 bgcolor=#ccff99><tr><td>&nbsp;<img src=img/wait.gif border=0> Pobieram&nbsp;</td></tr></table>";
        //document.getElementById(target).style.border=" 1px dotted #B3B2B2";
        gwhttp_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            gwhttp_request = new XMLHttpRequest();
            if (gwhttp_request.overrideMimeType) {
                gwhttp_request.overrideMimeType('text/xml');
                // Przeczytaj o tym wierszu ponizej
            }
        } else if (window.ActiveXObject) { // IE
            try {
                gwhttp_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    gwhttp_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!gwhttp_request) {
            return false;
        }

        gwhttp_request.onreadystatechange = function() {

           if (gwhttp_request.readyState == 4) {

		clearTimeout(ttt);

             appear(target);

             document.getElementById(target).innerHTML = gwhttp_request.responseText;

             queueDelete();

             if (queueEnd() != 0) {
                ajax2(ajaxQueue[0][0], ajaxQueue[0][1]);
	         }

           }

          };
        gwhttp_request.open('GET', 'ajax.php5?ajax=' + request + '&place=' + target, true);
        gwhttp_request.send(null);

    }

    var ajaxQueue = null;

    function ajax(request, target) {

       addToQueue(request, target);

    }

    function addToQueue(request, target) {

       if ((ajaxQueue == null)||(ajaxQueue[0] == null)) {

           ajaxQueue = new Array(100);
           ajaxQueue[0] = new Array(2);
           ajaxQueue[0][0] =  request;
           ajaxQueue[0][1] =  target;

           ajax2(request, target);

       }
       else {

          place = queueEnd();

          ajaxQueue[place] = new Array(2);
          ajaxQueue[place][0] = request;
          ajaxQueue[place][1] = target;

       }

    }

    function queueDelete() {
    
       count = 1;
       while (count < 101) {
       
          ajaxQueue[count - 1] = ajaxQueue[count];             
          count++;
       
       }
    
    }
    
    function queueEnd() {
    
       count = 0;
       while (count < 101) {
       
          if (ajaxQueue[count] == null)
             return count;
       
          count++;
       
       }
       
       return -1;
    
    }   
    
    function ifAjaxDone() {
   
       if (!gwhttp_request)
          return true;
    
       if (gwhttp_request.readyState == 4)
          return true;
          
       return false;   
    
    }
    
    function wait() {
    
       var date = new Date();
       var curDate = null;
       
       do {
          curDate = new Date();
       }
       while(curDate - date < 1000);     
    
    }

var ttt;

function fade(domId){
obj = document.getElementById(domId); //Get the Element

 if(obj.style.display == "none") return false; //Return false if the element is already hidden

 var alpha = 10; //Set the initial value of alpha to 10 (Opaque)
 function f(){ //Internal function

  alpha--; //Decrement the alpha value
  setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha

  if(alpha > -1){ //If alpha is still bigger than -1 then..
   setTimeout(f, 100); //..then call the function again after 100 milliseconds

  }else{ //otherwise..
   //obj.style.display = 'none'; //..otherwise now that we cant see the element anyways, hide it

  }
}
ttt = setTimeout(f, 100); //This is where we call the f() function for the first time

};


function appear(domId){
obj = document.getElementById(domId); //Get the element

 //f(obj.style.display != "none") return false; //Return if it is already being displayed

 obj.style.display = ''; //Un-hide the object before its animation
 var alpha = 0; //Set the initial value of alpha to 0 (invisible)

 function a(){ //Internal function
  alpha++; //Increment alpha

  setOpacity(domId, alpha); //Set the opacity of our element to the specified alpha
  if(alpha < 11)setTimeout(a, 100);

/*Till alpha is 10, keep calling the
a() function after 100 milliseconds */
}
setTimeout(a, 100); //This is where we call the a() function for the first time

};


function setOpacity(domId, val) {
obj = document.getElementById(domId);
obj.style.MozOpacity = val;
obj.style.opacity = val/10;
obj.style.filter = 'alpha(opacity=' + val*10 + ')';

};


var trailimage=["img/loading.gif", 32, 32] //image path, plus width and height
var offsetfrommouse=[-16,-16] //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var displayduration=0 //duration in seconds image should remain visible. 0 for always.

if (document.getElementById || document.all)
document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:0px;width:1px;height:1px"><img src="'+trailimage[0]+'" border="0" width="'+trailimage[1]+'px" height="'+trailimage[2]+'px"></div>')

function gettrailobj(){
if (document.getElementById)
return document.getElementById("trailimageid").style
else if (document.all)
return document.all.trailimagid.style
}

function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hidetrail(){
gettrailobj().visibility="hidden"
document.onmousemove=""

}

function followmouse(e){
var xcoord=offsetfrommouse[0]
var ycoord=offsetfrommouse[1]
if (typeof e != "undefined"){
xcoord+=e.pageX
ycoord+=e.pageY
}
else if (typeof window.event !="undefined"){
xcoord+=truebody().scrollLeft+event.clientX
ycoord+=truebody().scrollTop+event.clientY
}
var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
if (xcoord+trailimage[1]+3>docwidth || ycoord+trailimage[2]> docheight)
gettrailobj().display="none"
else 
gettrailobj().display=""
gettrailobj().left=xcoord+"px"
gettrailobj().top=ycoord+"px"
}

document.onmousemove=followmouse

if (displayduration>0)
setTimeout("hidetrail()", displayduration*1000)
