var arrdep="";
var i;
var j;
function rand( min, max )
{
    if( max )
    {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }
    else
    {
        return Math.floor(Math.random() * (min + 1));
    }
}
function getphp(page,sendget,resultid,openin)
{
    var myurl=page+"?"+sendget+"&trand="+rand(1,1001);
    try{xmlHttp=new XMLHttpRequest(); }
    catch (e)
    {try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
    catch (e)
    {try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
    catch (e)
    {alert("Ajax is not supported by your browser.");return false;}}}

    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState==4)
        {
            if(openin=="div")
            {
                document.getElementById(resultid).innerHTML="";
                document.getElementById(resultid).innerHTML=xmlHttp.responseText;

            }
            else if(openin=="window")
            {
                mywindow(xmlHttp.responseText);
            }
            else
            {
                return xmlHttp.responseText;
            }
        }
    }
    try
    {
    xmlHttp.open("GET", myurl, true);
    xmlHttp.send(null);
    }catch(e){};

}
function avg(lang,next)
{


   window.clearInterval(i);
   window.clearInterval(j);
   if(!lang)lang="";
    if(!next)next="0";
   getphp('xml2arr.php','xml=fids.xml&arrdep=depflight&next='+next+'&lang='+lang+'','flightList','div');
   var runfunk="getphp('xml2arr.php','xml=fids.xml&arrdep=depflight&next="+next+"&lang="+lang+"','flightList','div')";
   //i=setInterval("getphp('xml2arr.php','xml=fids.xml&arrdep=depflight&next='+next+'&lang='+lang+'','flightList','div')",10000);
   i=setInterval(runfunk,10000);
   document.getElementById('avg').className="";
   document.getElementById('ank').className="";
   document.getElementById('avg').className+="tabInactive";
   document.getElementById('avg').firstChild.className="";
   document.getElementById('ank').firstChild.className="tab";
}
function ank(lang,next)
{
    if(!lang)lang="";
    if(!next)next="0";
    window.clearInterval(j);
    window.clearInterval(i);
    getphp('xml2arr.php','xml=fids.xml&arrdep=arrflight&next='+next+'&lang='+lang+'','flightList','div');
    j=setInterval("getphp('xml2arr.php','xml=fids.xml&arrdep=arrflight&next='+next+'&lang='+lang+'','flightList','div')",10000);
    document.getElementById('avg').className="";
    document.getElementById('ank').className="";
    document.getElementById('ank').className+="tabInactive";
    document.getElementById('ank').firstChild.className="";
    document.getElementById('avg').firstChild.className="tab";
}
