// JavaScript Document
function send_coment_item(f){                         
  //if (!send_xmlhttprequest(send_forum_item_obsluha, 'POST', 'forum.php')) { return false; }         
  //return false;
  if (f.komentar_zprava.value != '' & (httpSendKomentar.readyState == 4 || httpSendKomentar.readyState == 0)) {
		//currentName = document.forms['chatForm'].elements['name'].value;
		f.button_send.value = 'odesílám ...';
	  f.button_send.disabled = true;	
		param = 'd='+f.d.value+'&n='+ f.komentar_nick.value+'&e='+ f.komentar_email.value+'&c='+ f.komentar_zprava.value+'&s='+ f.komentar_predmet.value;
		httpSendKomentar.open("POST", 'komentar.php', true);
		httpSendKomentar.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  	httpSendKomentar.onreadystatechange = handlehHttpSendKomentar;
  	httpSendKomentar.send(param);
  	//f.msg.value = '';
	}
    
}
function handlehHttpSendKomentar() {

  if (httpSendKomentar.readyState == 4) {
    //alert(httpSendKomentar.responseText);
    //var forum_item = httpSendKomentar.responseXML.getElementsByTagName('item');
    var ret = "";
    data = new String(httpSendKomentar.responseText);
    forum_item = data.split('\n');
    for (var i=0; i < forum_item.length; i++) {
      d = new String(forum_item[i]);      
      polozka = d.split("~~");  
      if (polozka[3]){
        ret = ret + "<li>"+polozka[3]
                  +" - <b>"+polozka[4]+'</b> - '
                  +polozka[1]+"<br /><span>"
                  +polozka[5]+"</span></li>";
      }      
      /*
      ret = ret + "<li>"+forum_polozka[i].getAttribute('vlozeno')
                +" - <b>"+forum_polozka[i].getAttribute('subjekt')+'</b> - '
                +forum_polozka[i].getAttribute('nick')+"<br /><span>"
                +forum_polozka[i].firstChild.data+"</span></li>";
      */
    }
    if (ret){
      document.getElementById('komentar').innerHTML = ret;
      document.getElementById('komentar_zprava').value = '';
      document.getElementById('komentar_predmet').value = '';
    }
 		document.getElementById('button_send').value = 'odeslat';
	  document.getElementById('button_send').disabled = false;	

  }
}

//initiates the XMLHttpRequest object
//as found here: http://www.webpasties.com/xmlHttpRequest
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

var httpSendKomentar = getHTTPObject();
