function update_comment(id) {

    if (id!=0) {
     
    if (window.ActiveXObject) {
        
    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
          
    } else {
    
    httpRequest = new XMLHttpRequest();
    }
        
    httpRequest.open("GET", "/components/pages_index/ajax.php?action=update_comment&id=" + id, true);
    httpRequest.onreadystatechange=function () { provest(id); };
    httpRequest.send(null);
    
    }
    
}

function save_comment(id, text) {

    if (id!=0) {
     
    if (window.ActiveXObject) {
        
    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
          
    } else {
    
    httpRequest = new XMLHttpRequest();
    }
        
    httpRequest.onreadystatechange=function () { provest(id); };
    httpRequest.open("POST", "/components/pages_index/ajax.php", true);
    httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    httpRequest.send("action=save_comment&id=" + id + "&text=" + text);
    
    }
    
}

function delete_comment(id) {

    if (id!=0) {
     
    if (window.ActiveXObject) {
        
    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
          
    } else {
    
    httpRequest = new XMLHttpRequest();
    }
        
    httpRequest.open("GET", "/components/pages_index/ajax.php?action=delete_comment&id=" + id, true);
    httpRequest.onreadystatechange=function () { document.getElementById("div" + id).style.display="none"; };
    httpRequest.send(null);
    
    }
    
}

function provest(id) {

    if (httpRequest.readyState == 4) {
  
    if (httpRequest.status == 200) {
    
    var kam_vypsat = document.getElementById(id);
    kam_vypsat.innerHTML = httpRequest.responseText;
      
    }
    
    }
  
}
