var xmlHttp = createXmlHttpRequestObject();

function createXmlHttpRequestObject()
{

var xmlHttp;

try
{

xmlHttp = new XMLHttpRequest();
}
catch(e)
{

var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
"MSXML2.XMLHTTP.5.0",
"MSXML2.XMLHTTP.4.0",
"MSXML2.XMLHTTP.3.0",
"MSXML2.XMLHTTP",
"Microsoft.XMLHTTP");

for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
{
try
{

xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
}
catch (e) {}
}
}

if (!xmlHttp)
alert("Error creating the XMLHttpRequest object.");
else
return xmlHttp;
}


function process(tid)
{

if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
{

xmlHttp.open("GET", "/index.php?act=celeb&mode=ajax&x=1&tid=" + tid, true);

xmlHttp.onreadystatechange = handleServerResponse;

xmlHttp.send(null);
}
else

setTimeout('process(tid)', 1000);

function handleServerResponse()
{
 actualdiv = document.getElementById(tid);
 actualdiv.align = "center";

 if (xmlHttp.readyState == 1)
  {
  //  actualdiv.innerHTML = "Betöltés... (kis türelemet)";
  }
else if (xmlHttp.readyState == 4)
{
  if (xmlHttp.status == 200)
  {
    document.getElementById("href_" +tid).href='javascript:close('+tid+')';
    document.getElementById("href_" +tid).innerHTML='Bezárás';

    xmlResponse = xmlHttp.responseXML;
    xmlRoot = xmlResponse.documentElement;

    locArray = xmlRoot.getElementsByTagName("location");
    memArray = xmlRoot.getElementsByTagName("member");
    idArray = xmlRoot.getElementsByTagName("id");

    var html = "";

    for (var i=0; i<memArray.length; i++)
    {
    html += "<a href='http://www.hqparadise.hu/index.php?act=Attach&amp;type=post&amp;id=" + idArray.item(i).firstChild.data + "' target='_blank'><img src='/uploads/" + locArray.item(i).firstChild.data + "' class='attach' style='padding: 5px;align: center;' alt='image' /></a> ";
    }
    if (i==0)
    {
      html = "Nincsnek csatolt képek a topikban!";
    }
    actualdiv.innerHTML = html;


  }
  else
  {
    alert("There was a problem accessing the server: " + xmlHttp.statusText);
  }
}
}

}

function close(tid)
{
   var actualdiv = document.getElementById(tid);

   actualdiv.innerHTML = "";
   document.getElementById("href_" +tid).href='javascript:process('+tid+')';
   document.getElementById("href_" +tid).innerHTML='Képek megtekintése';
}


function appr(cid)
{

if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
{

xmlHttp.open("GET", "/index.php?act=celeb&mode=ajax&x=2&cid=" + cid, true);

xmlHttp.onreadystatechange = handleServerResponse;

xmlHttp.send(null);
}
else

setTimeout('appr(cid)', 1000);

function handleServerResponse()
{
 if (xmlHttp.readyState == 1)
  {
  //  actualdiv.innerHTML = "Betöltés... (kis türelemet)";
  }
else if (xmlHttp.readyState == 4)
{
  if (xmlHttp.status == 200)
  {
    document.getElementById("apprlinks").innerHTML="";

  }
  else
  {
    alert("There was a problem accessing the server: " + xmlHttp.statusText);
  }
}
}
}

function del(cid)
{

if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
{

xmlHttp.open("GET", "/index.php?act=celeb&mode=ajax&x=3&cid=" + cid, true);

xmlHttp.onreadystatechange = handleServerResponse;

xmlHttp.send(null);
}
else

setTimeout('del(cid)', 1000);

function handleServerResponse()
{
 if (xmlHttp.readyState == 1)
  {
  //  actualdiv.innerHTML = "Betöltés... (kis türelemet)";
  }
else if (xmlHttp.readyState == 4)
{
  if (xmlHttp.status == 200)
  {
    document.getElementById("adatlap").innerHTML="<span style='color:red;font-weight:bold;'>ADATLAP TÖRÖLVE!</span>";
    document.getElementById("adatlap").align="center";

  }
  else
  {
    alert("There was a problem accessing the server: " + xmlHttp.statusText);
  }
}
}
}

