
function DivWindow(id,itop,ileft,iwidth,iheight,clickfunc,imgurl,zindex)
{
  this.id = id;
  this.itop = itop;
  this.ileft = ileft;
  this.iwidth = parseInt(iwidth) + 40;
  this.iheight = parseInt(iheight) + 65;
  this.onclosewin = clickfunc;
  this.zindex = zindex;
  this.imgpath = imgurl;
  this.valid = false;
  this.createWindow();

}

DivWindow.prototype.changeMeldungButton = function(n)
{
  var sImg = 'imgMeldungX' + this.id;
  if (n == 1)
  {
    document.images[sImg].src = this.imgpath + "meldung_X_norm.gif";
  }
  else
  {
    document.images[sImg].src = this.imgpath + "meldung_X_over.gif";
  }
}

DivWindow.prototype.createWindow = function()
{
  var html;
  //alert(this.imgpath);
  var xnodes = document.getElementsByTagName("body")[0];
  html = '<table id="idmeldungtbl'+this.id+'" class="divwindowcontent" border="0" width="100%" height="100%" cellspacing="0" cellpadding="0">';
  html = html + '<tr>';
  html = html + '<td width="50" height="50"><img border="0" src="'+this.imgpath+'meldung_1.gif" width="50" height="50"></td>';
  html = html + '<td background="'+this.imgpath+'meldung_2.gif" height="50">&nbsp;</td>';
  html = html + '<td width="50" id="tdmeldungbuttoncell'+this.id+'">';
  html = html + '<img border="0" src="'+this.imgpath+'meldung_3.gif" width="50" height="50"></td>';
  html = html + '</tr><tr><td width="50" background="'+this.imgpath+'meldung_8.gif"></td><td></td>';
  html = html + '<td width="50" background="'+this.imgpath+'meldung_4.gif"></td></tr><tr><td width="50">';
  html = html + '<img border="0" src="'+this.imgpath+'meldung_7.gif" width="50" height="50"></td>';
  html = html + '<td background="'+this.imgpath+'meldung_6.gif" height="50">&nbsp;</td>';
  html = html + '<td width="50"><img border="0" src="'+this.imgpath+'meldung_5.gif" width="50" height="50"></td></tr></table>';
  html = html + '<div id="idivmeldungbuttoncell'+this.id+'" style="position:absolute;left:0"><a href="javascript:'+this.id+'.closeclick()" onmouseover="'+this.id+'.changeMeldungButton(2)" style="outline:none" onmousedown="'+this.id+'.changeMeldungButton(1)" onmouseout="'+this.id+'.changeMeldungButton(1)" onmouseup="'+this.id+'.changeMeldungButton(2)"><img src="'+this.imgpath+'meldung_X_norm.gif" border="0" name="imgMeldungX'+this.id+'"></a>';
  html = html + '</div>';
  //alert(html)
  var idivbg = document.createElement("div");
  idivbg.id = "idivmeldung_bg_" + this.id;
  idivbg.style.position = "absolute";
  idivbg.style.top = this.itop;
  idivbg.style.width = this.iwidth;
  idivbg.style.height = this.iheight
  idivbg.style.left = this.ileft;
  idivbg.style.zIndex = this.zindex;
  idivbg.style.visibility  = "hidden";
  idivbg.style.className = 'divwindowcontent';
  idivbg.style.backgroundColor = '#FFFFFF';
  xnodes.appendChild(idivbg);
  var idiv = document.createElement("div");
  idiv.id = "idivmeldung" + this.id;
  idiv.style.position = "absolute";
  idiv.style.top = this.itop;
  idiv.style.width = this.iwidth;
  idiv.style.height = this.iheight
  idiv.style.left = this.ileft;
  idiv.style.zIndex = this.zindex+1;
  idiv.style.visibility  = "hidden";
  idiv.style.className = 'divwindowcontent';
  idiv.innerHTML = html;

  xnodes.appendChild(idiv);

  var idivcontent = document.createElement("div");
  idivcontent.id = "idivmeldungcontent" + this.id;
  idivcontent.style.position = "absolute";
  idivcontent.style.visibility = "hidden";
  idivcontent.style.overflow = "auto";
  idivcontent.style.zIndex = this.zindex + 2;
  idivcontent.className = 'divwindowcontent';
  xnodes.appendChild(idivcontent);

  var idivcontenttitle = document.createElement("div");
  idivcontenttitle.id = "idivmeldungcontenttitle" + this.id;
  idivcontenttitle.style.position = "absolute";
  idivcontenttitle.style.visibility = "hidden";
  idivcontenttitle.style.overflow = "auto";
  idivcontenttitle.style.zIndex = this.zindex + 2;
  idivcontenttitle.className = 'divwindowtitle';
  xnodes.appendChild(idivcontenttitle);
  this.valid = true;
}

DivWindow.prototype.show = function(stitle,content)
{
  if (!this.valid)
    this.createWindow();
  var bg = document.getElementById("idivmeldung_bg_"+this.id);
  bg.style.visibility = "visible";

  var m = document.getElementById("idivmeldung"+this.id)
  m.style.top = this.itop;
  m.style.left = this.ileft;
  m.style.width = this.iwidth;
  m.style.height = this.iheight;

  var itbl = document.getElementById("idmeldungtbl"+this.id)
  itbl.width = this.iwidth;
  itbl.height = this.iheight;
  document.getElementById("idivmeldungbuttoncell"+this.id).style.left= this.iwidth - 35;
  document.getElementById("idivmeldungbuttoncell"+this.id).style.top = 0;
  var idmct = document.getElementById("idivmeldungcontenttitle"+this.id);
  idmct.style.top = this.itop+8;
  idmct.style.left = this.ileft+14;
  idmct.innerHTML = stitle;
  idmct.style.visibility = "visible";

  var idmc = document.getElementById("idivmeldungcontent"+this.id);
  var nwidth = this.iwidth - 20;
  var nheight = this.iheight - 45;
  idmc.style.left= this.ileft +10;
  idmc.style.width= nwidth;
  idmc.style.top = this.itop + 35;
  idmc.style.height = nheight;
  var html = '<table width="'+nwidth+'" height="'+nheight+'" class="divwindowcontent" cellpadding="4"><tr><td valign="top" class="divwindowcontent">'+content+'</td></tr></table>';
  //alert(html)
  idmc.innerHTML = html;
  idmc.style.visibility = "visible";
   m.style.visibility = "visible";
}

DivWindow.prototype.close =  function()
{
  this.removeWindow();
}

DivWindow.prototype.removeWindow = function()
{
  if (!this.valid)
    return;
  try
  {
    var xnodes = document.getElementsByTagName("body")[0];
    var idiv = document.getElementById('idivmeldungcontenttitle'+this.id);
    if (idiv)
      xnodes.removeChild(idiv);
    var idiv2 =  document.getElementById("idivmeldungcontent"+this.id);
    if (idiv2)
    {
      idiv2.style.visibility = "hidden";
      xnodes.removeChild(idiv2);
    }
    var idivbg = document.getElementById("idivmeldung_bg_"+this.id)
    if (idivbg)
    {
      idivbg.style.visibility = "hidden";
      xnodes.removeChild(idivbg);
    }
    var idiv3 = document.getElementById("idivmeldung"+this.id)
    if (idiv3)
    {
      idiv3.style.visibility = "hidden";
      xnodes.removeChild(idiv3);
    }
  }
  catch(e)
  {

  }
  this.valid = false;
}

DivWindow.prototype.closeclick = function()
{

  this.removeWindow();
  if (this.onclosewin)
  {
    window.setTimeout(this.onclosewin,100);
  }

}

