function addComment(id,cat)
{
  if((id != "") && (cat != ""))
  {
  	var httpRequest = false;
  	var noResult = "Kein Ergebnis";
  	var add_comm_url = "http://"+ window.location.hostname +"/includes/comments.php";
  	var fehler = "";
  	var formName = 'kommentar' + id;
  	var name = document.getElementById('name' + id).value;
  	var email = document.getElementById('email' + id).value;
  	var text = document.getElementById('text' + id).value;
  	var txtCode = document.getElementById('txtCode' + id).value;
  	var codeVergleich = document.getElementById('codeVergleich' + id).value;	
  		
  	if(name == "")
  	{
          fehler += "Bitte einen <strong>Namen</strong> eingeben.<br />";
  		document.getElementById('name' + id).className = 'fehler';
  	}
  	
  	if(txtCode == "")
  	{
          fehler += "Bitte den <strong>Sicherheitscode</strong> eingeben.<br />";
  		document.getElementById('txtCode' + id).className = 'fehler';
  	}	
  
  	if(text == "")
  	{
          fehler += "Bitte einen <strong>Kommentar</strong> eingeben.<br />";
  		document.getElementById('text' + id).className = 'fehler';
  	}
  
      if(fehler)
      {
  		document.getElementById('comFehler' + id).style.display = 'block';
  		document.getElementById('comFehler' + id).innerHTML = fehler;
  		return false;
      }
      else
      {
  		httpRequest = false;
  		if(window.XMLHttpRequest)  // Mozilla, Safari,...
         		httpRequest = new XMLHttpRequest();
  		else if(window.ActiveXObject) { // IE
         		try
  			{
             		httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
  			}
         		catch (e)
  			{
             		try
  				{
                 		httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
       			}
             		catch (e) {}
         		}
     		}
     		if(!httpRequest)
        		return false;
     		
  		httpRequest.onreadystatechange = function() 
  		{
        		if(httpRequest.readyState == 4)
  			{
           		if(httpRequest.status == 200)
              		handleHttpResponse_C(httpRequest.responseText, id);
         			else
            			return false;
           	}
      		else
         			return false;
     		}
  		document.getElementById('neuerKommentar' + id).innerHTML = "<img src='http://"+ window.location.hostname +"/images/loading.gif' alt='wird geladen' />";
  		httpRequest.open('post', add_comm_url, true);
  		httpRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');
  		httpRequest.send('name='+name+'&email='+email+'&text='+text+'&id='+id+'&cat='+cat+'&txtCode='+txtCode+'&codeVergleich='+codeVergleich);
  	}
  }
}


function handleHttpResponse_C(content, id)
{
	if(!document.getElementById)
    	return false;
	if(!document.getElementById('neuerKommentar' + id))
   		return false;
	if(content == "FALSE")
	{
    	document.getElementById('neuerKommentar' + id).innerHTML = noResult;
	}
	else
	{
    	document.getElementById('neuerKommentar' + id).innerHTML = content;
	}
}

