/*/////////////////////////////////////
//				     //
//  This is the engien for the chat  //
//  ChatEngine.addMessage();	     //
//  ChatEngine.drawAll();	     //
//  ChatEngine.deleteMess(objNr);    //
//  ChatEngine.readKey(event);	     //
//				     //
/////////////////////////////////////*/

// This is the ChatEngine object
function Dilbert(setNrOfPost)
{
  this.nrOfPost = setNrOfPost;
  this.ajax;
  this.contentID;
}


Dilbert.prototype.openMenu=function(theID)
{
  var id = theID-1;
  var html = "\n";
      html = html+"      <li><a href=\"#\" onclick=\"Boxs.boxs["+id+"].content.serie1\">Se dagens serie</a></li>\n";
      html = html+"      <li><a href=\"#\" onclick=\"Boxs.boxs["+id+"].content.serie5\">Se 5 serie strippar</a></li>\n";
  HtmlGen.innerHtml(document.getElementById("box"+theID+"Menu"),html);
}

Dilbert.prototype.setEvents=function(theID)
{
}
Dilbert.prototype.getDilbert=function(theBox, theID, that, height, get)
{
  that.menuBoxClose("box"+theID+"Menu");
  document.getElementById("box"+theID+"Content").innerHTML = "Laddar...";
  
  if(that.size == "normal")
  {
    theBox.style.height = height+"px";
  }
  that.height = height;
  
  that.content.contentID = "box"+theID+"Content";
  
  var url = "?app=Dilbert&get="+get;
  this.ajax = new Ajax(url, null, "box"+theID+"Status", this, "responseText", null, "get");
}
Dilbert.prototype.serie1=function()
{
  var theBox = this.parentNode.parentNode.parentNode;
  var theID = theBox.getAttribute("id").replace("box","");
  var that = Boxs.boxs[theID - 1];
  var height = 257;
  var get = 1;
  
  that.content.getDilbert(theBox, theID, that, height, get);
  
  return false;
}


Dilbert.prototype.serie5=function()
{
  var theBox = this.parentNode.parentNode.parentNode;
  var theID = theBox.getAttribute("id").replace("box","");
  var that = Boxs.boxs[theID - 1];
  var height = 1170;
  var get = 5;
  
  that.content.getDilbert(theBox, theID, that, height, get);
  
  return false;
}


Dilbert.prototype.loaded=function()
{
  if(this.ajax.content == null)
  {
    document.getElementById(this.contentID).innerHTML = "Datan kunde inte laddas";
  }
  else
  {
    document.getElementById(this.contentID).innerHTML = this.ajax.content;
  } 
  this.contentID = null;
}
