// *******************************************************************************
// idgbox: Fügt Elementen der Klasse "idgbox" einen Schatten-Effekt hinzu
// *******************************************************************************


// ********************************************************************************************************************************************* Programm-Einstellungen ***

var constIDGBoxPath ='/tools/idgBox'; 


// ************************************************************************************************************************************************ OnLoad-EventHandler ***

function fnInitIdgBox () {
  arrBoxElements=getElementsByClassName ('idgbox');
  addStyle (constIDGBoxPath+'/idgbox.css');
  for (var dummy=arrBoxElements.length-1, arrBoxObjects=new Array (); dummy>=0; dummy--) arrBoxObjects[dummy] = new idgBox (arrBoxElements[dummy]);
}


// ***************************************************************************************************************************************************** Klasse: idgBox ***

function idgBox (paramBoxElement) {

  strIdgBoxColor=paramBoxElement.getAttribute('idgboxcolor').substr (1);
  strIdgBoxShadow=paramBoxElement.getAttribute('idgboxshadow');
  blnIdgBoxShadow=(strIdgBoxShadow=='true') ? 1 : 0;

  strIdgBoxCloseButton=paramBoxElement.getAttribute('closebutton');
  blnIdgBoxCloseButton=(strIdgBoxCloseButton=='true') ? 1 : 0;
  
  this.ID=document.createElement ("div");

  if (blnIdgBoxShadow) {
    intVersatz=9;
  } else {
    intVersatz=2;
  }
  
  if (IE) {
    intKorrektur=1;
  } else {
    intKorrektur=0;
  }
    
  this.ID.style.height=paramBoxElement.offsetHeight+intVersatz;
  this.ID.style.width=paramBoxElement.offsetWidth+intVersatz;
  this.ID.style.left=paramBoxElement.offsetLeft;
  this.ID.style.zIndex=1;
  if (paramBoxElement.style.position) this.ID.style.position=paramBoxElement.style.position; else this.ID.style.position='absolute';
  switch (this.ID.style.position) {
    case 'absolute'	: this.ID.style.top=paramBoxElement.offsetTop;
    			  break;
    case 'relative'	: this.ID.style.top='0px';
    			  break;
  }
  paramBoxElement.style.left='1px';
  paramBoxElement.style.top='1px';
  paramBoxElement.style.zIndex=this.ID.style.zIndex;
  this.Parent=paramBoxElement.parentNode;
  this.Parent.insertBefore (this.ID, paramBoxElement);
  paramBoxElement.style.visibility='visible';
  this.Content=moveChild (this.ID, paramBoxElement);
  

  if (blnIdgBoxShadow) {

    objDummy=document.createElement ("div");
    objDummy.className="border_top_left";
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_top_left.php?color='+strIdgBoxColor+'&shadow=1)';
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_bottom_left_shadow";
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_bottom_left.php?color='+strIdgBoxColor+'&shadow=1)';
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_top_right_shadow";
    if (IE) objDummy.style.right='0px';
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_top_right.php?color='+strIdgBoxColor+'&shadow=1)';
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_left";
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_left.php?color='+strIdgBoxColor+'&shadow=1)';
    objDummy.style.height=parseInt(this.ID.style.height)-intVersatz-2;
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_bottom_right_shadow";
    if (IE) objDummy.style.right='0px';
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_bottom_right.php?color='+strIdgBoxColor+'&shadow=1)';
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_top";
    objDummy.style.width=parseInt(this.ID.style.width)-intVersatz-2;
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_top.php?color='+strIdgBoxColor+'&shadow=1)';
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_bottom_shadow";
    if (IE) objDummy.style.bottom='2px';
    objDummy.style.width=parseInt(this.ID.style.width)-intVersatz-2;
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_bottom.php?color='+strIdgBoxColor+'&shadow=1)';
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_right_shadow";
    if (IE) objDummy.style.right='-1px';
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_right.php?color='+strIdgBoxColor+'&shadow=1)';
    objDummy.style.height=parseInt(this.ID.style.height)-intVersatz-6;
    this.ID.appendChild (objDummy);
  } else {

    objDummy=document.createElement ("div");
    objDummy.className="border_top_left";
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_top_left.php?color='+strIdgBoxColor+'&shadow=0)';
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_bottom_left";
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_bottom_left.php?color='+strIdgBoxColor+'&shadow=0)';
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_top_right";
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_top_right.php?color='+strIdgBoxColor+'&shadow=0)';
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_right";
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_right.php?color='+strIdgBoxColor+'&shadow=0)';
    objDummy.style.height=parseInt(this.ID.style.height)-intVersatz-2;
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_left";
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_left.php?color='+strIdgBoxColor+'&shadow=0)';
    objDummy.style.height=parseInt(this.ID.style.height)-intVersatz-2;
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_bottom_right";
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_bottom_right.php?color='+strIdgBoxColor+'&shadow=0)';
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_top";
    objDummy.style.width=parseInt(this.ID.style.width)-intVersatz-2;
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_top.php?color='+strIdgBoxColor+'&shadow=0)';
    this.ID.appendChild (objDummy);

    objDummy=document.createElement ("div");
    objDummy.className="border_bottom";
    objDummy.style.width=parseInt(this.ID.style.width)-intVersatz-2;
    objDummy.style.backgroundImage='url('+constIDGBoxPath+'/border_bottom.php?color='+strIdgBoxColor+'&shadow=0)';
    this.ID.appendChild (objDummy);
  }
  
  if (blnIdgBoxCloseButton) {
    this.ID.CloseButton=document.createElement ("div");
    this.ID.CloseButton.className="idgbox_closebutton";
    this.ID.CloseButton.innerHTML='schliessen';
    this.ID.CloseButton.onclick=this.Hide.bindAsEventListener (this);

    this.ID.appendChild (this.ID.CloseButton);
  }
}


idgBox.prototype.Hide = function () {
  this.ID.style.visibility='hidden';
  this.Content.style.visibility='hidden';
}

