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,obj) {

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

   document.getElementById(innercontent).innerHTML=document.getElementById(innercontent).innerHTML + '<div class="loading"><span>LOADING CONTENT...</span></div>';

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

  http.send(null);

}

function slider(obj) {
featuredcontentslider.init({ id: obj, contentsource: ["inline", ""],	toc: "markup", 	nextprev: ["", ""],	revealtype: "click",	enablefade: [true, 0.2],	autorotate: [true, 3000],	onChange: function(previndex, curindex){} }) 
}



function ajx_comment_expand(id,parent,responses) {
 var myurl="http://nightnews.evl.pl/ajx-comments-expand.php";
  
  document.getElementById('g'+parent).innerHTML='<img src="images/loading_icon.gif">';  
  
  http = getHTTPObject();
  http.open("GET", myurl + "?id=" + escape(id) + "&parent=" + escape(parent)  + "&responses=" + escape(responses), true);
  http.onreadystatechange = function() {
    if (http.readyState == 4) {     
      document.getElementById('g'+parent).innerHTML=http.responseText;
      document.getElementById('goc'+parent).innerHTML='<a href="javascript:ajx_comment_collapse(' + id + ',' + parent + ',' + responses + ');">ukryj</a> | ';
    }
  };
  http.send(null);
 
}
 
function ajx_comment_add(id,parent) {
       document.getElementById('godp'+parent).innerHTML='<div class="kom_odpowiedz"><form method="post" action="form-comments.php"><input type="hidden" name="kom_parent" value="' + parent + '"/><input type="hidden" name="kom_article_id" value="' + id + '"/><textarea name="kom_content"></textarea><input type="image" src="/images/button_dodaj.gif" value="dodaj"/></form></div>';
 }
 
function ajx_comment_collapse(id,parent,responses) {
 
  document.getElementById('goc'+parent).innerHTML='<a href="javascript:ajx_comment_expand(' + id + ',' + parent + ',' + responses + ' );">pokaż odpowiedzi (' + responses + ')</a> | ';  
  document.getElementById('g'+parent).innerHTML='';  
 
}
