//---------------------------------------

 // globale Instanz von XMLHttpRequest
  var xmlHttp = false;
  
  // XMLHttpRequest-Instanz erstellen
  // ... für Internet Explorer
  try
  {
      xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch(e)
  {
      try
      {
          xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
          xmlHttp  = false;
      }
  }
  
  // ... für Mozilla, Opera und Safari
  if (!xmlHttp  && typeof XMLHttpRequest != 'undefined') {
      xmlHttp = new XMLHttpRequest();
  }
  
  
  //--------
  
  var xmlHttp2 = false;
  
  // XMLHttpRequest-Instanz erstellen
  // ... für Internet Explorer
  try
  {
      xmlHttp2  = new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch(e)
  {
      try
      {
          xmlHttp2  = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(e)
      {
          xmlHttp2  = false;
      }
  }
  
  // ... für Mozilla, Opera und Safari
  if (!xmlHttp2  && typeof XMLHttpRequest != 'undefined') {
      xmlHttp2 = new XMLHttpRequest();
  }

  //--------

function saveData(userid, id)
{
  if (xmlHttp)
  {
    xmlHttp.open('POST', 'setdata.php');
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    
    if (document.getElementById("div_"+id).style.display == "none")
    {
      xmlHttp.send('userid='+userid+'&box='+id+'&state=block');
    }
    else
    {
      xmlHttp.send('userid='+userid+'&box='+id+'&state=none');
    }
    toggle_nav(id);   
  }  
}

//---------------------------------------




function toggle_nav (id)
{
	if (document.getElementById("div_"+id).style.display == "none")
	{
		document.getElementById("img_"+id).src = "i/toggle_minus.png";
		document.getElementById("div_"+id).style.display = "block";
	}
	else
	{
		document.getElementById("img_"+id).src = "i/toggle_plus.png";
		document.getElementById("div_"+id).style.display = "none";	
	}  
}


function toggle_comments (id)
{
	if (document.getElementById("div_"+id).style.display == "none")
	{
		document.getElementById("div_"+id).style.display = "block";
	}
	else
	{
		document.getElementById("div_"+id).style.display = "none";	
	}  
}


function switchRowColor(row, rowColor)
{
  row.style.backgroundColor = rowColor;
}

function saveComment(userid, newsid, comment)
{
  if (xmlHttp)
  {
    xmlHttp.open('POST', 'savecomment.php');
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');    
    xmlHttp.send('userid='+userid+'&newsid='+newsid+'&comment='+comment);
  }  
  if (xmlHttp2)
  {
    xmlHttp2.open('GET', 'getcomments.php?newsid='+newsid, true);
    
    
    xmlHttp2.onreadystatechange = function ()
    {
         if (xmlHttp2.readyState == 4)
         {
             document.getElementById("div_"+newsid+"_new").innerHTML = xmlHttp2.responseText;
             document.getElementById("txtmessage").value = '';
             document.getElementById("img_"+newsid).src = 'i/comments_add.png';
         }
     };
    xmlHttp2.send(null);
  }
}


function loadComments(newsid)
{
  if (xmlHttp)
  {
     
  }
}