var xmlhttprequest = getHTTPObject();
var responseText = "";


function getHTTPObject()
{
  var tmp;

  try
  {
    tmp=new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch (e)
  {
    try
    {
      tmp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (E)
      {
         tmp=false;
      }
   }

  if(!tmp && typeof XMLHttpRequest!='undefined')
  {
    try
    {
        tmp=new XMLHttpRequest();
      }
      catch (E)
      {
        tmp=false;
      }
    }

    return tmp;
}

function updateBoxes()
{
  if(responseText != "")
  {
     var div_boxes = document.getElementById("flugplan_rechts");
     if(div_boxes)
     {
       div_boxes.innerHTML = responseText;
       //alert("updating");
     }  
  }
  window.setTimeout('submitRequest()', 120000);
}
function submitRequest()
{
    if(xmlhttprequest != null)
    {
    	url = "http://www.flughafen-graz.at/flightplan_local/displayboxes.php?showheaders=true";
    	if(lang)
    	  url += "&lang=" + lang;
    	
	    xmlhttprequest.open("GET", url ,true);
	    xmlhttprequest.onreadystatechange=function() { 
	      if(xmlhttprequest.readyState == 4)
	      {
		if(xmlhttprequest.status == 200)
		{
		  responseText=xmlhttprequest.responseText;
		  updateBoxes();
		  responseText.busy = false;
		}
		//else
		//{  
		//  if(responseText.status != 0)  //because of abort() when timed-out
		//    alert("There was a problem retrieving the XML data:\nError: " + thttp.status);
		//}
	      }
	      }
	    xmlhttprequest.send(null);
  }  
}



//------------------------------------------------------------------

function showWeatherDetails(details) 
{
	var load = window.open('http://www.flughafen-graz.at/showWeatherDetails.php?code=' + details,'','scrollbars=no,menubar=no,height=260,width=490,resizable=no,toolbar=no,location=no,status=no');
}