var XMLHttpRequestObject = false;

if (window.XMLHttpRequest)
{
	XMLHttpRequestObject = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
	XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}

function getXMLHttpRequestObject()
{
  try{
    return new XMLHttpRequest();
  }
  catch(e){
    try{
      return new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch(e){
      return false;
    }
  }
}

function startGETRequest(url, onComplete, onEnd)
{
  var XMLHttpRequestObject = getXMLHttpRequestObject();
  if(XMLHttpRequestObject){
    XMLHttpRequestObject.open("GET", url);
    XMLHttpRequestObject.onreadystatechange = function()
    {
      if (XMLHttpRequestObject.readyState == 4){
        if(XMLHttpRequestObject.status == 200){
          var responseXML = XMLHttpRequestObject.responseXML;
          var responseText = XMLHttpRequestObject.responseText;
          onComplete(responseText, responseXML);
        }
        delete XMLHttpRequestObject;
        onEnd();
      }
    }
    XMLHttpRequestObject.send(null);
  }
}



var timeOutId=0;
function wylacz_warstwy ()
{
 timeOutId = setTimeout (function (){wylacz_wszystkie_warstwy();},3000);
}
function czysc_time (){ clearTimeout (timeOutId); }

function wylacz_wszystkie_warstwy()
{
 $$('.ImgsPopUp').each(function(el) { el.style.display='none'; }); 
}

function wlacz_warstwe (id,obj)
{
 var d=document.getElementById(id);
 d.style.display='';
}

	function ApplicationPopup(id, obj)
	{
		czysc_time();
		xOff = obj.offsetWidth/1;
		yOff = obj.offsetHeight/1;
	
			while (obj.offsetParent)
			{
				xOff += obj.offsetLeft-60;
				yOff += obj.offsetTop-5;
				obj = obj.offsetParent;
			}
			
			var DialogDiv = document.getElementById("DialogDiv");
			DialogDiv.onmouseover=function() { czysc_time(); };
			DialogDiv.onmouseout=function() { ClosePopup();  };
			
			DialogDiv.innerHTML = '<div style="padding-top:10px; text-align:center; font-size:10px;">Czekaj... trwa pobieranie danych</div><div class="ArrowWidnow">&nbsp;</div>';
			DialogDiv.style.top = yOff + "px";
			DialogDiv.style.left = xOff + "px";
			DialogDiv.style.display = "block";
			
			url = "http://"+window.location.host+"/modules/news.php?id=" + id;
			startGETRequest(url, onComplete, onEnd);
	}
	
	function ClosePopup()
	{
		timeOutId = setTimeout (function ()
	    {
		   var DialogDiv = document.getElementById("DialogDiv");
		   DialogDiv.style.display = "none";
		},1000);
	}
	
	function onComplete(text, xml)
	{
		var DialogDiv = document.getElementById("DialogDiv");
		DialogDiv.innerHTML = text;
	}
	
	function onEnd(text, xml)
	{
		onprogress = false;
	}
