var CSB;

function cShoutBox(id,myel)
{
  this.path='/shoutbox';
  this.myel=myel;
  this.element=document.getElementById(id);
  this.listaWynikow=null;
  this.form=null;
  this.niezalogowany=null;
  this.currentSHA='';
  this.sendreq=false;
  CSB=this;
  this.init=function()
  {
    this.element.innerHTML="";
    this.iframe=document.createElement('iframe');
    this.iframe.className="shoutboxIframe";
    this.iframe.src='http://sb.release24.pl/sb'+this.getOtherParams();
    this.iframe.frameBorder="0";
    this.element.appendChild(this.iframe);
  };

  this.getOtherParams=function()
  {
    var ret='';
    var tmp=document.getElementById('SBhash');
    if(tmp)
      ret+='/'+encodeURIComponent(tmp.value);
    tmp=document.getElementById('SBislogged');
    if(tmp)
      ret+='/'+encodeURIComponent(tmp.value);
    tmp=document.getElementById('SBismod');
    if(tmp)
      ret+='/'+encodeURIComponent(tmp.value);
    tmp=document.getElementById('SBisbanned');
    if(tmp)
      ret+='/'+encodeURIComponent(tmp.value);
    tmp=document.getElementById('SBuid');
    if(tmp)
      ret+='/'+encodeURIComponent(tmp.value);
    tmp=document.getElementById('SBuname');
    if(tmp)
      ret+='/'+encodeURIComponent(tmp.value);
    return ret;
  }

  this.showhide=document.getElementById('sbopenhide');
  if(this.showhide)
  {
    this.showhide.cShoutBox=this;
    this.showhide.onclick=function(e)
    {
      var params='';
      if((m=this.innerHTML.match(/POKA/)))
      {
        params='openhide=2';
        document.getElementById('shoutbox').style.display="block";
        this.innerHTML="[UKRYJ]";
      } else
      {
        params='openhide=1';
        document.getElementById('shoutbox').style.display="none";
        this.innerHTML="[POKAŻ]";
      }
      this.cShoutBox.process(params);
    }
  }

  this.createHTTPreq=function()
  {
  	this.sendreq=false;
  	try { this.sendreq = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
  		try { this.sendreq = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { this.sendreq = false; } }
  	if (!this.sendreq && typeof XMLHttpRequest!='undefined'){
  		try { this.sendreq = new XMLHttpRequest(); } catch (e) { this.sendreq=false; } }
  	if (!this.sendreq && window.createRequest) {
      try { this.sendreq = window.createRequest(); } catch (e) { this.sendreq=false; } }
    return this.sendreq;
  };
  
  this.process=function(send)
  {
    var sr=this.createHTTPreq();
    if(sr)
    {
      sr.onreadystatechange=function()
      {
  			if(sr.readyState == 4 && sr.status == 200)
  			{
  			}
      }
    	sr.open("POST", this.path+'/'+ new Date().getTime(),true);
      sr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
    	sr.send(send);
    }
  };
  this.createHTTPreq(this);
  if(this.element)
    this.init();
  else
    return false;
}
