



function getHTTPObject() {
  if (typeof XMLHttpRequest != 'undefined') {
    return new XMLHttpRequest();
  } try {
    return new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      return new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {}
  } return false;
}


function ajx_switch(htmlid,script,id) {

var myurl="http://www.mamaija.org/" + script + '.php?ajxid=' + id;
var innercontent = htmlid + "_innerhtml";

   document.getElementById(innercontent).innerHTML='ładuje się';

  http = getHTTPObject();
  http.open("GET", myurl, true);
  http.onreadystatechange = function() {
    if (http.readyState == 4) {
      var textout = http.responseText;
      document.getElementById(htmlid).innerHTML=textout;      
    }
  };

  http.send(null);

}

function ajx_comment_add(message,oid,oid_date,oid_type,to_delete) { 
  
  http_shout = getHTTPObject();  
  http_shout.onreadystatechange = function() {    
    if (http_shout.readyState == 4) {  
      var textout = http_shout.responseText;      
      document.getElementById('ajx_comments').innerHTML=textout;         
    }
  };
    
  message=encodeURIComponent(message);
  
  var parameters="message="+message+"&oid="+oid+"&oid_date="+oid_date+"&oid_type="+oid_type;
  if (to_delete) parameters = parameters + '&to_delete=' + to_delete;  
  
  http_shout.open("POST", "ajx-comments.php", true);
  http_shout.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_shout.send(parameters);              

}    

function ajx_comments_all(oid,oid_date,oid_type,hide) {    
 
  http_shout = getHTTPObject();  
  http_shout.onreadystatechange = function() {    
    if (http_shout.readyState == 4) {  
      var textout = http_shout.responseText;      
      document.getElementById('ajx_comments').innerHTML=textout;         
    }
  };
  
  var parameters="oid="+oid+"&oid_date="+oid_date+"&oid_type="+oid_type;
  if (!hide) parameters += "&all=1";    
  
  http_shout.open("POST", "ajx-comments.php", true);
  http_shout.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_shout.send(parameters);              

}   

function show_layer(layer) {
  var myLayer = document.getElementById(layer).style.display;
  if(myLayer=="none"){
    document.getElementById(layer).style.display="block";
  } else {
    document.getElementById(layer).style.display="none";
  }
}

function show_comment(comment_id) {
  show_layer('comment_' + comment_id);
  show_layer('comment_desc_' + comment_id);  
}

