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.ckis.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(message,oid,oid_date,oid_type,to_delete,nick,captcha) { 
  
  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+"&nick="+nick+"&captcha="+captcha;
  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 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='';  
 
}
*/

function ajx_calendar_offset(ver,offset,year,month,day,dzial) {   

  var myurl='http://www.ckis.pl/ajx-calendar.php?offset=' + offset + '&ver=' + ver;
  if (year) myurl = myurl + '&year=' + year;
  if (month) myurl = myurl + '&month=' + month;
  if (day) myurl = myurl + '&day=' + day;
  if (dzial) myurl = myurl + '&dzial=' + dzial;
  http_shout = getHTTPObject();
  http_shout.open("GET", myurl, true);
  http_shout.onreadystatechange = function() {    
    if (http_shout.readyState == 4) {  
      var textout = http_shout.responseText;      
      document.getElementById('ajx_calendar').innerHTML=textout;         
    }
  };
  
  http_shout.send(null);
        
}
