//****************************************************************************/
// Firma:        Hehner Reus Systems GmbH
// Projekt:      com.cerno.newsletter
// Datei:        ibox.js
// Erstellung:   27.11.2009
// Verwendung:   Zur Darstellung von Multimedia-Inhalten, wie Bilder, Musik, Videos und Internetseiten. Die 
//               iBox kann aber dazu verwendet werden, Fehlermeldungen anzuzeigen. 
//
// $Id: ibox.js,v 1.26 2011/10/11 17:31:57 whe Exp $
// $Author: whe $
// $Log: ibox.js,v $
// Revision 1.26  2011/10/11 17:31:57  whe
// Optimierungen für openUrlInIbox(): blackOverlay, Default- und Maximalwerte für die Größenangaben.
//
// Revision 1.25  2011/09/20 20:28:50  whe
// Erweiterte Variante die Sichtbarkeit von HTMLElementen zu aktivieren, die in einer iBox dargestellt werden sollen.
//
// Revision 1.24  2011/06/30 16:59:11  whe
// Kleine Korrektur für den IE (Schreibweise von clientHeight)
//
// Revision 1.23  2011/06/29 17:30:56  whe
// Kleine Korrektur für den IE (Schreibweise von clientHeight)
//
// Revision 1.22  2011/06/17 15:17:18  imo
// iBox Bilder sind jetzt maximal so groß wie 80% der Client-Höhe und -Breite
//
// Revision 1.21  2011/05/20 13:38:29  imo
// Wenn in der iBox Title fehlt wird das DIV auf display:none gesetzt. Ebenso mit der Description. Das heisst, wenn Bildname fehlt und Bildbeschreibung fehlt, wird die iBox um diesen Bereich verkleinert.
//
// Revision 1.20  2011/03/18 12:49:00  imo
// iBox: Bei der Positionierung wird jetzt die aktuelle Scroll-Position mit einbezogen
//
// Revision 1.19  2011/03/09 12:34:43  imo
// Höhen- und Breiten-Berechnung in der iBox angepasst.
//
// Revision 1.18  2011/02/23 14:57:14  imo
// Die Höhe des schwarzes Overlays bei der iBox wird jetzt anders berechnet
//
// Revision 1.17  2011/02/15 18:43:24  whe
// Kleinere Schönheitsänderungen an der Fehlerhinweis-Box
//
// Revision 1.16  2011/02/01 13:46:38  imo
// BlackOverlay wird gefaded. Try-Catch-Blöcke eingebaut für den Fall, dass die includes vom Draggable oder Animator vergessen wurden.
//
// Revision 1.15  2011/01/26 21:24:24  whe
// Variable close in closediv umbenannt, da es sonst im IE Probleme gab.
// Ein Klick auf das Bild in der iBox führt nun auch zur Anzeige des nächsten.
//
// Revision 1.14  2010/08/22 13:33:42  imo
// Der Close-Button beim der iBox für Bilder gilt jetzt als ein spezieller Close-Button. OpenUrlIniBox hat jetzt auch einen Close-Button bekommen und zwar den Default-Close-Button.
//
// Revision 1.13  2010/07/14 09:46:34  imo
// Die ID wird dem Draggable übergeben und nicht das HTML-Element
//
// Revision 1.12  2010/07/07 09:33:44  imo
// Zwei TODOs eingefügt
//
// Revision 1.11  2010/07/07 07:52:16  imo
// Wenn keine URL angegeben wurde wird href="#" gesetzt
//
// Revision 1.10  2010/07/06 14:17:50  imo
// Kleine Verbesserungen
//
// Revision 1.9  2010/07/06 09:11:40  imo
// html element wird immer sichtbar gemacht
//
// Revision 1.8  2010/07/06 09:05:55  imo
// Andere Webseiten können jetzt auch mittels iFrame in die iBox geöffnet werden. HTML-Elemente auf der gleichen Page können jetzt auch in die iBox verschoben werden.
//
// Revision 1.7  2010/07/06 07:57:45  imo
// falschen Funktionsaufruf korrigiert
//
// Revision 1.6  2010/07/06 07:49:14  imo
// Konsolenausgaben entfernt
//
// Revision 1.5  2010/07/06 07:48:17  imo
// Urls und Events für die Buttons werden jetzt korrekt ausgeführt
//
// Revision 1.4  2010/07/06 07:13:38  imo
// Ausrichtung korrigiert, Timeout wird jetzt gelöscht bevor er neu gesetzt wird. so gibt es nicht mehrere gleichzeitig. die iBox erscheint nur einmal wenn man mehrfach klickt.
//
// Revision 1.3  2010/07/05 15:13:21  imo
// Parameter für das align hinzugefügt
//
// Revision 1.2  2010/07/05 12:02:45  imo
// weitere schritte zur Fertigstellung der iBox
//
// Revision 1.1  2010/07/02 14:51:09  whe
// Eigene JavaScript-Library ins Verzeichnis js verschoben
//
// Revision 1.1  2010/07/02 14:33:39  imo
// Layout-Ordner erstellt und HR-Sys-Lib eingefügt
//
// Revision 1.7  2010/07/02 14:30:45  imo
// Further steps
//
// Revision 1.6  2010/06/30 14:05:04  imo
// Die Wiedergeburt der iBox
//
// Revision 1.5  2009/12/09 15:22:24  imo
// Alle IDs global gesetzt und zwei Bugs behoben.
//
// Revision 1.4  2009/12/09 11:22:38  imo
// Beim Wechsel von einem Bild zum nächsten entstehen jetzt keine Scrollbalken mehr. Bim schliessen der iBox wird auch der onresize-Handler gelöscht, damit es beim Fenstergröße verändern keine Fehler mehr gibt.
//
// Revision 1.3  2009/12/08 15:46:12  imo
// Breite des iFrames ist jetzt immer 4 Pixel kleiner als das transparente Überlagerungs-Div. Das führt dazu, dass keine Scrollbalken mehr erscheinen.
// Die Höhe des Bodys wird jetzt anders berechnet, so dass der Hintergrund großflächiger abgedunktelt wird.
//
// Revision 1.2  2009/12/08 13:44:08  imo
// Kommentare ergänzt
//
// Revision 1.1  2009/12/08 11:09:43  imo
// Neue iBox
//
//****************************************************************************/

 
// - - - - - - - - - - - - - - - - - Member - - - - - - - - - - - - - - - - - - - - - - - -
var m_iBox;                      // das HTML-Element der iBox selbst
var m_BlackOverlay;              // DIV zum Abdunkeln des Hintergrunds
var m_iFrame;                    // iFrame was unter dem DIV zum Abdunkeln des Hintergrunds liegt um alle(!) Elemente auch im IE abzudunkeln
var m_iBoxDivClose;              // Der Close Button
var m_minImageWidth = 100;       // Defaultwert für die minimale Breite des Anzeigebereichs der iBox. Diese verändert sich, wenn viel Text in der Beschreibung vorhanden ist.
var m_maxImageWidth = 1000;      // Defaultwert für die maximale Breite eines Bildes
var m_maxImageHeight = 600;      // Defaultwert für die maximale Höhe eines Bildes

var m_CurrentContentWidth;       // die aktuelle Breite des anzuzeigenden Inhalts, z.B. des Bildes 
var m_CurrentContentHeight;      // die aktuelle Höhe des anzuzeigenden Inhalts, z.B. des Bildes

var m_BilderArray;               // das der Funktion openImagesInIbox() Array mit Bildern
var m_IndexOfImagesToShow = 0;   // der aktuelle Index im Array des zu zeigenden Bildes
var m_BildNamenArray;            // Namen bzw Titel der Bilder im Array, welches auch der openImagesInIbox()-Funktion übergeben wird
var m_BildunterschriftArray;     // 
		
var m_IdDiv    = "idHrSysGipsDivBlackTransparentOverlay";   // id für das Div zum Abdunkeln des Hintergrunds
var m_IdIFrame = "idHrSysGipsIFrameOverlay";                // id für das iFrame hinter dem Div zum Abdunkeln des Hintergrunds
var m_IdIBoxDivTitle       = "idIBoxDivTitle";              // id für das Div welches den Bildtitel enthält
var m_IdIBoxDivDescription = "idIBoxDivDescription";        // id für das Div welches die Bildbeschreibung enthält
var m_IdIBoxDivCaption     = "idIBoxDivCaption";            // id für den Bereich in dem der Titel und die Beschreibung sind
var m_IdIBoxDivInnerCaption= "idIBoxDivInnerCaption";       // id für den 
var m_IdIBoxDivNext        = "idIBoxDivNext";               // id für das Div welches den Next-Button repräsentiert
var m_IdIBoxDivPrev        = "idIBoxDivPrevious";           // id für das Div welches den Previous-Button repräsentiert
var m_IdIBoxDivClose       = "idIBoxDivClose";              // id für das Div welches den Close-Button repräsentiert
var m_IdIBoxDivNumber      = "idIBoxDivNumber";             // id für das Div welches den Nummer des Bildes enthält
var m_IdIBoxContentImage   = "idIBoxContentImage";          // 
var m_IdIBoxDiv4Image      = "idIBoxDiv4Image";             // id für das Div welches das eigentliche Bild enthält
var m_IdIBoxDiv4Text       = "idIBoxDiv4Text";              // id für das Div welches Text in der iBox enthält
var m_IdIBoxDiv4Url        = "idIBoxDiv4Url";              // id für das Div welches Text in der iBox enthält
var m_IdIBoxContent        = "idIBoxContent";          // id für das Div welches das eigentliche Bild enthält
var m_IdIBox               = "idHrSysGipsDivIBox";

var m_TimeoutToDisappear = null;                            // Das Timeout-Objekt
var m_TimeToDisappear = 5000;                               // 5 Sekunden
		
// Animations-Objekte      
var m_Animator = null;


/**
 * Allgemeine Funktion zum Erstellen der iBox. Als Parameter wird eine Propertylist erwartet.
 * @param {Object} configuration ist eine property list
 */
var openInIbox = function (configuration)
{
   m_Animator = null;
   if(configuration.animation && configuration.animation == true)
	{
		try {
	      m_Animator = new Animator({
	         duration: 550
	      });
	   }
	   catch(e)
	   {
	      m_Animator = null;
	   }
	}
	
   
   if(configuration.blackOverlay && configuration.blackOverlay == true)
   {
      createBlackOverlay();
      resizeBlackOverlayWidthToDocumentBody();
   }
   
   if(configuration.closingEventsOnBlackOverlay && configuration.closingEventsOnBlackOverlay == true)
   {
      if(m_BlackOverlay)
         m_BlackOverlay.onmouseup = removeAllIBoxElements;
      
      if(m_BlackOverlay)
         m_iFrame.onmouseup = removeAllIBoxElements;   
   }
   
   createIBoxMinimalSkeleton(configuration.cssSuffix);
   
	
   if(configuration.htmlElement)
   {
	   setIBoxContentHtmlElementID(configuration.htmlElement);
   }
	
   if(configuration.iframeSrc)
   {
      if (!configuration.iframeWidth || configuration.iframeWidth <= 0 || configuration.iframeWidth > getClientWidthInPercentage(85))
         configuration.iframeWidth = getClientWidthInPercentage(85);
			
      if (!configuration.iframeHeight || configuration.iframeHeight <= 0 ||  configuration.iframeHeight > getClientHeightInPercentage(85))
         configuration.iframeHeight = getClientHeightInPercentage(85);

	   setIBoxContentURL(configuration.iframeSrc, configuration.iframeHeight, configuration.iframeWidth, configuration.cssSuffix);
   }
	
   if(configuration.meldung)
   {
      setIBoxContentText(configuration.meldung,configuration.cssSuffix);   
   }
   
   if(m_TimeoutToDisappear)
      deleteTimeout(m_TimeoutToDisappear);
   
   if(configuration.timeout)
   {
      setTimeToDisappear(configuration.timeout);
   }
     
   var length = 0;
   for(var key in configuration)
   {
      //configuration[key];
      length++;
   }
   
   if(configuration.button && configuration.url)
   {
      addButtonToIBox(configuration.button, configuration["url"], "", configuration.cssSuffix);
   }
	
   if(configuration.closeButton == true)
   {
		createIBoxCloseButton();
   }

   for(var i = 0; i < length; i++)  
   {
      if(configuration["button" + i])
      {
			var url;
			var buttonEvent;
			
			if(configuration["url" + i])
			   url = configuration["url" + i];
		   else
			   url = "#";;
			
			if(configuration["button"+i+"Event"])
			   buttonEvent = configuration["button"+i+"Event"]
		   else
			   buttonEvent = "";
			
			 
         addButtonToIBox(configuration["button" + i], url, buttonEvent);
      }
   }
   
   if(configuration.checkbox == true)
   {
      var checkBoxText = "";
      var checkBoxOnclickFunction = "";
      var checkBoxName = "";
      var checkBoxValue = "";
      
      if(configuration.checkboxText)
         checkBoxText = configuration.checkboxText;
         
      if(configuration.checkBoxOnclickFunction)
         checkBoxOnclickFunction = configuration.checkBoxOnclickFunction;
      
      if(configuration.checkBoxName)
         checkBoxName = configuration.checkBoxName;
         
      if(configuration.checkBoxValue)
         checkBoxValue = configuration.checkBoxValue;
      
      createIBoxCheckBox(checkBoxText , "idIBoxInputCheckbox" , checkBoxOnclickFunction, checkBoxName, checkBoxValue);
   }
   
   if (configuration.alignY) 
   {
      alignIBoxVerticalTo(configuration.alignY);
   }
   else
   {
      alignIBoxVerticalTo("center");
   }

   if (configuration.alignX) 
   {
      alignIBoxHorizontalTo(configuration.alignX);
   }
   else
   {
      alignIBoxHorizontalTo("center");
   }
	
	
	
}


// - - - - - - - - - - - - - - - - - Dialog-Fenster - - - - - - - - - - - - - - - - - - - - - - - -
var iboxEntscheidung = function (fragetext, urlA, textButtonA, urlB, textButtonB)
{
			
	openInIbox({ alignX   : "center",
	             alignY   : "center",
	             meldung : fragetext,
	             /*timeout : "5",*/
	             cssSuffix : "-DialogBox",
	             button1 : textButtonA,
	             url1    : urlA,
	             button2 : textButtonB,
	             url2    : urlB,
	             blackOverlay : true,
	             closingEventsOnBlackOverlay : false
	             });
}


var iboxWollenSieWirklich = function (fragetext, url, textOk, textCancel, auswahlDesUsersAlsCookieSpeichern)
{	
   if(!textOk)
	   textOk = "Ja"
	if(!textCancel)
	   textCancel = "Nein";
	if(!auswahlDesUsersAlsCookieSpeichern)
      auswahlDesUsersAlsCookieSpeichern = false;
	  
   openInIbox({ alignX   : "center",
                alignY   : "center",
                meldung   : fragetext,
                /*timeout : "5",*/
                cssSuffix : "-DialogBox",
                button1   : textOk,
                url1      : url,
                button2   : textCancel,
                button2Event  : "onclick='removeAllIBoxElements();'",
					 checkbox  : auswahlDesUsersAlsCookieSpeichern,
					 checkboxText : "Nicht nochmal fragen!",
					 /*checkBoxOnclickFunction : "keine",*/
					 checkBoxName : "CheckBoxDontAskAgain",
					 checkBoxValue : "true",
                blackOverlay : true,
                closingEventsOnBlackOverlay : false
                });
}


var iboxHinweis = function (hinweisText, textOk, obenunten, linksrechts, timeToDisapear)
{	
   if(!obenunten)
	   obenunten = "";
   if(!linksrechts)
	   linksrechts = "";
   if(!textOk)
	   textOk = "ok";
	
   openInIbox({ alignX  : linksrechts,
	             alignY  : obenunten,
                meldung : hinweisText,
                timeout : timeToDisapear,
                cssSuffix : "-DialogBox",
                button1 : textOk,
                button1Event  : "onclick='removeAllIBoxElements();'",
                checkbox : false,
                checkboxText : "Nicht nochmal fragen!",
                /*checkBoxOnclickFunction : "keine",*/
                checkBoxName : "CheckBoxDontAskAgain",
                checkBoxValue : "true",
                blackOverlay : true,
                closingEventsOnBlackOverlay : false
                });
}



// - - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - - - -



var openUrlInIbox = function (url,width,height)
{
	   openInIbox({ alignX  : "center",
                   alignY  : "center",
                   iframeSrc    : url,
                   iframeHeight : height,
                   iframeWidth  : width,
						 closeButton  : true,
                   cssSuffix : "-DialogBox",
	                blackOverlay : true,
	                closingEventsOnBlackOverlay : true
                });
}
// - - - - - - - - - - - - - - - - - - - HTML - - - - - - - - - - - - - - - - - - - - - -
var openHtmlElementInIbox = function (idVomElement)
{   
	// beim div sollte display immer auf visible gestellt werden
	   openInIbox({ alignX  : "center",
                   alignY  : "center",
                   htmlElement  : idVomElement
                });
}


// - - - - - - - - - - - - - - - - - - - MultiMedia - - - - - - - - - - - - - - - - - - - - - -
var openMultiMediaInIbox = function (param)
{
}

var openMultiMediasInIbox = function (array)
{
}

// - - - - - - - - - - - - - - - - - - - Bilder - - - - - - - - - - - - - - - - - - - - - -

/**
 * Funktion öffnet die iBox, welche das übergebene Bild anzeigt. Bildname, bzw. Titel und Beschreibung sind optionale Parameter.
 * Die maximale Höhe und Breite muss auch nicht mit angegeben werden. 
 * Überschreitet das anzuzeigende Bild die zulässige Maximalgröße, werden die height- und width-Parameter verkleinert. Das geschieht
 * proportional zu einander.
 * @param {Object} bild Im moment relative(!) und absolute url. Später möglicherweise auch img-Tag oder a-Tag und dessen href oder id
 * @param {Object} bildUnterschrift die Bildbeschreibung
 * @param {Object} bildName der Name bzw der Titel des Bildes 
 * @param {Object} maxImageHeight die maximale Höhe des Bildes
 * @param {Object} maxImageWidth die maximale Breite des Bildes
 */
var openImageInIbox = function (bild, bildUnterschrift, bildName, maxImageHeight, maxImageWidth)
{
   try {
   	m_Animator = new Animator({
   		duration: 550
   	});
   }
	catch(e)
	{
		m_Animator = null;
	}

   m_maxImageHeight = getClientHeightInPercentage(80);
   m_maxImageWidth  = getClientWidthInPercentage(80);
   
   if (maxImageHeight)
     m_maxImageHeight = maxImageHeight; 
   if (maxImageWidth)
     m_maxImageWidth = maxImageWidth;
	  
   // if (param.toLowerCase().indexOf("http") > -1)   // absolute URL zum Bild
   // else if (param.tagName == img)                  // das Bild als HTML-img-Tag  
   // else if (param.tagName == a)                    // HTML-Link zum Bild
   // else if (document.getElementById(param))        // param == id
   // else if param == relative url, z.b. "images/img001.jpg" oder nur "img001.jpg"
   //
	
	createBlackOverlay();
   resizeBlackOverlayWidthToDocumentBody();
	
	createIBoxMinimalSkeleton();
   createIBoxPrevAndNextButtons();
	
	// Bildernamen
   if(m_BildNamenArray && m_BildNamenArray.length > 0 )
   {
     createIBoxTitleWithNumberAndDescription();
     // Namen des Bildes setzen
     setTitle(bildName);
   }
   else
   {
     createIBoxDescriptionWithNumber();
   }
	
	createIBoxImageCloseButton();
	
	// Beschreibung des Bildes setzen
   setDescription(bildUnterschrift);
   
   // 
   setIBoxContentImage(bild);
   
   // prev und next-Button verstecken
   hidePrevAndNextButtons();
   
   m_BlackOverlay.onmouseup = removeAllIBoxElements;
   m_iFrame.onmouseup       = removeAllIBoxElements;
   //m_iBox.onmouseup         = removeAllIBoxElements;
	
	//
   // Animierten Fade
	//
   animateFadeIn();
}


	
/**
 * Funktion öffnet die iBox, welche das übergebene Bild anzeigt. Bildname, bzw. Titel und Beschreibung sind optionale Parameter.
 * Die maximale Höhe und Breite muss auch nicht mit angegeben werden. 
 * Überschreitet das anzuzeigende Bild die zulässige Maximalgröße, werden die height- und width-Parameter verkleinert. Das geschieht
 * proportional zu einander.
 * @param {Object} array Array mit relativen oder absoluten URLs zu Bildern.
 * @param {Object} showFirst relative oder absolute URL zu dem Bild aus dem Array, welches zu erst angezeigt werden soll
 * @param {Object} bildNamenArray die Namen bzw die Titel der Bilder
 * @param {Object} bildunterschriftArray die Bildunterschriften
 * @param {Object} maxImageHeight die maximale Höhe aller Bilder
 * @param {Object} maxImageWidth die maximale Breite aller Bilder
 */
var openImagesInIbox = function(array, showFirst, bildNamenArray, bildunterschriftArray, maxImageHeight, maxImageWidth)
{
	try {
      m_Animator = new Animator({
         duration: 550
      });
   }
   catch(e)
   {
      m_Animator = null;
   }
	
	m_BilderArray = array;
   m_IndexOfImagesToShow = 0;
   m_BildNamenArray = bildNamenArray;
   m_BildunterschriftArray = bildunterschriftArray;
   
   m_maxImageHeight = getClientHeightInPercentage(80);
   m_maxImageWidth  = getClientWidthInPercentage(80);
   
   if (maxImageHeight)
     m_maxImageHeight = maxImageHeight; 
   if (maxImageWidth)
     m_maxImageWidth = maxImageWidth;
	  
	// if (param.toLowerCase().indexOf("http") > -1)   // absolute URL zum Gruppierungselement/Container also <div oder xml><img><img><img><img>...</div>
   // else if (param.length && param.length > 0)      // JavaScript-Array mit Bildern als IDs/URLs 
   // else if (param.tagName == div)                  // div als Gruppierungselement/Container  
   // else if (param.tagName == a)                    // HTML-Link zum Bild
   // else if (document.getElementById(param))        // param == id
   // else if param == relative url, z.b. "images/img001.jpg" oder nur "img001.jpg"
   //
   
   // wenn showFirst eine (positive) ganze Zahl ist
   if (isUnsignedInteger(showFirst)) 
   {
      m_IndexOfImagesToShow = showFirst;
   }
   else 
   {
      for (var i = 0; i < m_BilderArray.length; i++) 
      {
         if (m_BilderArray[i] == showFirst) 
         {
            m_IndexOfImagesToShow = i;
            break;
         }
      }
   }
   
   // Hintergrund abdunklen
   createBlackOverlay();
   resizeBlackOverlayWidthToDocumentBody();
	
	createIBoxMinimalSkeleton();
	createIBoxPrevAndNextButtons();
 	
	  // Bildernamen
   if(m_BildNamenArray && m_BildNamenArray.length > 0 )
   {
	  createIBoxTitleWithNumberAndDescription();
     // Namen des Bildes setzen
     setTitle(bildNamenArray[m_IndexOfImagesToShow]);
   }
   else
   {
	  createIBoxDescriptionWithNumber();
   }
	
	createIBoxImageCloseButton();
   
   // Beschreibung des Bildes setzen
   if(m_BildNamenArray && m_BildNamenArray.length > 0 )
      setDescription(bildunterschriftArray[m_IndexOfImagesToShow]);
      
   // Anzahl
   setNumber(m_IndexOfImagesToShow);
   //document.getElementById(m_IdIBoxDivNumber).innerHTML = ""+  m_IndexOfImagesToShow + " von " + m_BilderArray.length;
   //document.getElementById(m_IdIBoxDivNumber).innerHTML = "test";
   
   // 
   setIBoxContentImage(m_BilderArray[m_IndexOfImagesToShow]);
   
   reinitializePrevNextButtons();
   
   m_BlackOverlay.onmouseup = removeAllIBoxElements;
   m_iFrame.onmouseup       = removeAllIBoxElements;
   //m_iBox.onmouseup         = removeAllIBoxElements;
	
//
   // Animierten Fade
   //
   animateFadeIn();
}







// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - iBox erstellen  - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/**
 * Erstellt einen schwarz-transparenten Hintergrund
 */
var createBlackOverlay = function ()
{
   var idDiv    = m_IdDiv;
   var idIFrame = m_IdIFrame;
   m_BlackOverlay = document.getElementById(idDiv);
   m_iFrame  = document.getElementById(idIFrame);
	
   if (m_BlackOverlay) 
	{
		remove(m_BlackOverlay);
   }
   if (m_iFrame) 
   {
		remove(m_iFrame);
   }
		
   var width = getBodyWidth();
	var height = getBodyHeight();
	
	// div-overlay erstellen
	m_BlackOverlay = createFloatingElement("div",width + "px",height,0,0,idDiv);
	m_BlackOverlay.className = "HrSys-Gips-iBoxIFrameOverlay";
	
   // iframe erstellen
	m_iFrame = createFloatingIFrame((width-4) + "px",(height-4) +"px",0,0,idIFrame);
	m_iFrame.className = "HrSys-Gips-iBoxDivOverlay";
	
	window.onresize = resizeBlackOverlayWidthToDocumentBody;
	
	if(window.getComputedStyle)                             // W3C-style
   {
		if(m_Animator == null)
         m_BlackOverlay.style.opacity = "0.6";
		else
         m_BlackOverlay.style.opacity = "0";
			
      m_iFrame.style.opacity = "0";
   }
   else if(m_BlackOverlay.currentStyle )                         // IE-style
   { 
		if(m_Animator == null)
         m_BlackOverlay.style.filter = "alpha(opacity=60)";
      else
         m_BlackOverlay.style.filter = "alpha(opacity=0)";

      m_iFrame.style.filter = "alpha(opacity=0)";
   }
	
	document.getElementsByTagName("BODY")[0].appendChild(m_BlackOverlay);      // und an den BODY hängen
   m_BlackOverlay.style.backgroundColor = "#000000";
   m_BlackOverlay.style.visibility = 'visible';                            //
   
	
	// Animierten Fade
	if(m_Animator)
      m_Animator.addSubject(new NumericalStyleSubject(m_BlackOverlay, 'opacity', 0, 0.6));
   
}



// ------- neu -------------------------------------------------------

var createIBoxMinimalSkeleton = function (cssSuffix)
{
	if(!cssSuffix)
	   cssSuffix = "";
		
   m_iBox = document.getElementById(m_IdIBox);
	if(m_iBox)
	  remove(m_iBox);
	
   m_iBox = document.createElement("div");                            // DIV für die iBox erstellen
   document.getElementsByTagName("BODY")[0].appendChild(m_iBox);      // und an den BODY hängen
   m_iBox.className = "HrSys-Gips-DivIBox" + cssSuffix;
   m_iBox.id        = m_IdIBox;
   
	var content = document.createElement("div");
	content.id = m_IdIBoxContent;
	content.className = "HrSys-Gips-iBoxDivContent" + cssSuffix;
   m_iBox.appendChild(content);
   
	try
	{
	  new Draggable(content.id);
	}
	catch(e)
	{
	}
	
	var caption = document.createElement("div");
	caption.id = m_IdIBoxDivCaption;
	caption.className = "HrSys-Gips-iBoxDivCaption" + cssSuffix;
   m_iBox.appendChild(caption);
}


var createIBoxImageCloseButton = function (cssSuffix)
{
	if(!cssSuffix)
      cssSuffix = "";
		
   // close button erstellen
	m_iBox             = document.getElementById(m_IdIBox);
   closediv           = document.createElement("div");
   closediv.id        = m_IdIBoxDivClose;
   closediv.className = "HrSys-Gips-iBoxDivCloseImage" + cssSuffix;
   closediv.innerHTML = '<a href="#" onmouseup="removeAllIBoxElements();"></a>'; 
   m_iBox.appendChild(closediv);
}

var createIBoxCloseButton = function (cssSuffix)
{
	if(!cssSuffix)
      cssSuffix = "";
		
   // close button erstellen
	m_iBox             = document.getElementById(m_IdIBox);
   closediv           = document.createElement("div");
   closediv.id        = m_IdIBoxDivClose;
   closediv.className = "HrSys-Gips-iBoxDivClose" + cssSuffix;
   closediv.innerHTML = '<a href="#" onmouseup="removeAllIBoxElements();"></a>'; 
   m_iBox.appendChild(closediv);
}

var createIBoxDescription = function ()
{
}


var createIBoxCheckBox = function (text,id,onlickFunction,name, value)
{
	if(onlickFunction)
	  onlickFunction += "();";
	  
	var textKnoten = document.createElement("DIV");
	textKnoten.innerHTML = '<input id="'+id+'" onclick="'+onlickFunction+'" type="checkbox" name="'+name+'" value="'+value+'">'+text+'</input>'; 
	var content = document.getElementById(m_IdIBoxContent);
	content.appendChild(textKnoten);
}




var createIBoxDescriptionWithNumber = function ()
{
      // wenn der Bildtitel nicht vorhanden ist, kommt die Zahl in die Beschreibung.
      // ein Div für den Bildtitel gibt es dann nicht
   var innerCaption = document.getElementById(m_IdIBoxDivInnerCaption);
   innerCaption.innerHTML = '      <div id="idIBoxDivDescription" class="HrSys-Gips-iBoxDivDescription">'
	                       + '          <div id="idIBoxDivNumber"  class="HrSys-Gips-iBoxDivNumber"></div>'
	                       + '      </div>'; 
}

var createIBoxTitleWithNumberAndDescription = function ()
{
	var innerCaption = document.getElementById(m_IdIBoxDivInnerCaption);
	innerCaption.innerHTML = '      <div id="idIBoxDivTitle"       class="HrSys-Gips-iBoxDivTitle">' 
		                    + '          <div id="idIBoxDivNumber"  class="HrSys-Gips-iBoxDivNumber"></div>' 
		                    + '      </div>' 
		                    + '      <div id="idIBoxDivDescription" class="HrSys-Gips-iBoxDivDescription"></div>';
        
}

var createIBoxPrevAndNextButtons = function ()
{
	var caption = document.getElementById(m_IdIBoxDivCaption);
	
	var previous = document.createElement("div");                            
   previous.id = m_IdIBoxDivPrev;
   previous.className = "HrSys-Gips-iBoxDivPrev";
   previous.onclick   = showPrevImageInIBox;
	
	var next = document.createElement("div");                            
   next.id = m_IdIBoxDivNext;
   next.className = "HrSys-Gips-iBoxDivNext";
   next.onclick   = showNextImageInIBox;
	
	var innerCaption = document.createElement("div");                            
   innerCaption.id = m_IdIBoxDivInnerCaption;
   innerCaption.className = "HrSys-Gips-iBoxDivInnerCaption";
	
	caption.appendChild(previous);
	caption.appendChild(next);
	caption.appendChild(innerCaption);
}

/**
 * Nimmt eine beliebige Anzahl von Parametern an und erstellt damit Buttons als DIV in dem Caption-Feld der iBox.
 * @param {Object} cssSuffix
 * @param {Object} urlA
 * @param {Object} textButtonA
 * @param {Object} urlB
 * @param {Object} textButtonB
 * @param {Object} urlC
 * @param {Object} textButtonC
 * @param {Object} ....
 * @param {Object} urlN
 * @param {Object} textButtonN
 */
var createIBoxClickButtons = function (cssSuffix, urlA, textButtonA, urlB, textButtonB, urlC, textButtonC)
{
   if(!cssSuffix)
      cssSuffix = "";
		
	var html = '';
	
	for(var i = 0; i < createIBoxClickButtons.arguments.length; i+=2)
	{
		if(createIBoxClickButtons.arguments[i])
		{
	      html += '<a href="#" class="HrSys-Gips-AHrefButton'+cssSuffix+'" onclick="openURL('+createIBoxClickButtons.arguments[i]+');"><div class="HrSys-Gips-iBoxDivButton'+cssSuffix+'">';
			if(createIBoxClickButtons.arguments[i+1])
			{
			   html += createIBoxClickButtons.arguments[i+1];
			}
			html += '</div></a>';  
		}
	}
	
	var caption = document.getElementById(m_IdIBoxDivCaption);
   caption.innerHTML = html; 
}

/**
 * Fügt der iBox einen Button hinzu
 * @param {Object} textButton
 * @param {Object} url
 */
var addButtonToIBox = function(textButton, url, buttonEvent, cssSuffix)
{
	if(!cssSuffix)
      cssSuffix = '';
		
	if(!buttonEvent)
      buttonEvent = '';
      //buttonEvent = 'onclick="removeAllIBoxElements();"';
		
	if(!url)
      url = '';
		
	var caption = document.getElementById(m_IdIBoxDivCaption);
	var html    = caption.innerHTML;
	
	html += '<a href="'+url+'" '+ buttonEvent +' class="HrSys-Gips-AHrefButton'+cssSuffix+'"><div class="HrSys-Gips-iBoxDivButton'+cssSuffix+'">';
   html += textButton;  
   html += '</div></a>';

   caption.innerHTML = html; 
}


// ------- ende neu -------------------------------------------------------


// - - - - - - - - - - - - - Hilfsmethoden - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


var animateFadeIn = function() 
{
	//
   // Animierten Fade
   //
	if(m_Animator)
	{
	   if(window.getComputedStyle)                             // W3C-style
	   {
	      m_iBox.style.opacity = "0";
	      m_iFrame.style.opacity = "0";
	   }
	   else if(m_iBox.currentStyle )                         // IE-style
	   { 
	      m_iBox.style.filter = "alpha(opacity=0)";
	      m_iFrame.style.filter = "alpha(opacity=0)";
	   }
	}
   
   if(m_Animator)
      m_Animator.addSubject(new NumericalStyleSubject(m_iBox, 'opacity', 0, 1));
   
   if(m_Animator)
     m_Animator.play();
}



/**
 * Setzt die Vorwärts und Rückwärstbuttons auf hidden
 */
var hidePrevAndNextButtons = function()
{
	hideElement(m_IdIBoxDivPrev);
	hideElement(m_IdIBoxDivNext);
}

var hideElement = function(id)
{
	document.getElementById(id).style.display = "none";
}

/**
 * Setzt den Bildnamen, bzw. Titel.
 * @param {Object} name
 */
var setTitle = function(name)
{
	var titleElement = document.getElementById(m_IdIBoxDivTitle);
	if(name && name.length > 0)
	{
		titleElement.innerHTML = name;
		titleElement.style.display = "block";
	}
	else
	{
		titleElement.innerHTML = "";
		titleElement.style.display = "none";
	}
		
}

/**
 * Setzt die aktuelle Zahl, bzw. den Index, von dem Bild welches angezeigt werden soll.
 * @param {Object} numberOfNumber
 */
var setNumber = function(numberOfNumber)
{
	var numberDiv = document.getElementById(m_IdIBoxDivNumber);
	var titleDiv = document.getElementById(m_IdIBoxDivTitle);
	var descriptionDiv = document.getElementById(m_IdIBoxDivDescription);
	
	if (!numberDiv) 
	{
   	numberDiv           = document.createElement("div");
		numberDiv.id        = m_IdIBoxDivNumber;
		numberDiv.className = "HrSys-Gips-iBoxDivNumber";
		if(titleDiv)
		  titleDiv.appendChild(numberDiv);
		else if(descriptionDiv)
		  descriptionDiv.appendChild(numberDiv);
   }
	numberDiv.innerHTML = numberOfNumber+1 + " von " + m_BilderArray.length;
}

/**
 * Setzt die Beschreibung des Bildes in der iBox.
 * @param {Object} description
 */
var setDescription = function(description)
{
	var descriptionElement = document.getElementById(m_IdIBoxDivDescription); 
	if(description && description.length > 0)
	{
		if(description.length > 60)
		  m_minImageWidth = 450;
		else 
		  m_minImageWidth = 300;
		  
		descriptionElement.innerHTML = description;
		descriptionElement.style.display = "block";
			
	}
	else
	{
		descriptionElement.innerHTML = "";
		descriptionElement.style.display = "none";
	}
}




var setIBoxContentText = function(text,cssSuffix)
{
	var contentBereich = document.getElementById(m_IdIBoxContent);
	
	var div4Text = document.getElementById(m_IdIBoxDiv4Text);
   if (div4Text) 
      remove(div4Text);
   div4Text = document.createElement("DIV");
   div4Text.id = m_IdIBoxDiv4Text;
   div4Text.className = "HrSys-Gips-iBoxDiv4Text"+cssSuffix;
	div4Text.innerHTML = '<span class="HrSys-Gips-iBoxContentText'+cssSuffix+'">'+text+'</span>';

   contentBereich.appendChild(div4Text);
}


var setIBoxContentURL = function(url, height, width, cssSuffix)
{
  if(!cssSuffix)
   cssSuffix = "";
      
	var contentBereich = document.getElementById(m_IdIBoxContent);
	
	var div4IFrame = document.getElementById(m_IdIBoxDiv4Url);
   if (div4IFrame) 
      remove(div4IFrame);
   div4IFrame           = document.createElement("DIV");
   div4IFrame.id        = m_IdIBoxDiv4Url;
   div4IFrame.className = "HrSys-Gips-iBoxDiv4Url"+cssSuffix;
	div4IFrame.innerHTML = '<iframe src="'+url+'" height="'+height+'" width="'+width+'">';

   contentBereich.appendChild(div4IFrame);
}

var setIBoxContentHtmlElementID = function(htmlElementID)
{
	var contentBereich = document.getElementById(m_IdIBoxContent);

	var element = document.getElementById(htmlElementID);
	element.style.visibility = 'visible';                            //
	//
	// Da häufig auch mit display: none; zum Verstecken von
	// Divs gearbeitet wird, setzen wir ggfs auch diesen Schalter um.
	//
	if (element.style.display == 'none')
		element.style.display = 'block';
		
   contentBereich.appendChild(element);
}

/**
 * Setzt den darzustellenden Inhalt der iBox
 * @param {Object} bild
 */
var setIBoxContentImage = function(bild)
{
	m_iBox.style.visibility = 'hidden';
	var content = document.getElementById(m_IdIBoxContent);
	
	var div4Image = document.getElementById(m_IdIBoxDiv4Image);
	if (div4Image) 
   	remove(div4Image);
	div4Image = document.createElement("DIV");
	div4Image.id = m_IdIBoxDiv4Image;
	div4Image.className = "HrSys-Gips-iBoxDiv4Image";
	content.appendChild(div4Image);
	
	var img = document.getElementById(m_IdIBoxContentImage);
	if (img) 
   	remove(img);
	img = document.createElement("img");
	img.id = m_IdIBoxContentImage;
	img.className = "HrSys-Gips-iBoxImage";
	div4Image.appendChild(img);
	
//	img.onclick = function(){
//   	alert('test');
//   };
	
	// Bildgröße ermitteln. Wichtig für den IE ist dabei, dass der onload-event vor dem Setzen des src-Attribut gesetzt wird!!!!
	img.onload = function()
	{
		m_CurrentContentWidth  = img.width; 
      m_CurrentContentHeight = img.height;
		 
		m_maxImageHeight = getClientHeightInPercentage(80);
   		m_maxImageWidth  = getClientWidthInPercentage(80);
   
		// Bild zu hoch?
		if(m_CurrentContentHeight > m_maxImageHeight) //     
		{
		   // verkleinern und seitenverhältnis beibehalten
         m_CurrentContentHeight = m_maxImageHeight;                            // maximale Höhe setzen
		   m_CurrentContentWidth  = img.width / (img.height / m_maxImageHeight); // Breite berechnen, damit Seitenverhältnis erhalten bleibt 
		}
		// Bild zu breit
	   if (m_CurrentContentWidth > m_maxImageWidth)  // wenn die Bildbreite höher ist als die maximal zulässige 
		{
		   // verkleinern
         m_CurrentContentHeight = img.height / (img.width / m_maxImageWidth);
		   m_CurrentContentWidth  = m_maxImageWidth; 
		}
		// Bild skalieren
	   img.height = m_CurrentContentHeight; 
	   img.width  = m_CurrentContentWidth; 
         
		// Breite zu klein?
		var divWidth = m_CurrentContentWidth;
      if (m_CurrentContentWidth < m_minImageWidth)        // wenn die Breite des Bildes kleiner ist als die minimal zulässige Breite 
      {
         divWidth = m_minImageWidth;                      // wird die Größe der inneren Divs auf die minimal zulässige Breite gestellt
      }
      
		// die Breite der Divs für das Bild und Titel/Beschreibung unter dem Bild
		document.getElementById(m_IdIBoxContent).style.width   = divWidth +"px";
		document.getElementById(m_IdIBoxDivCaption).style.width = divWidth +"px";
		
		// Bild dran hängen   
      document.getElementById(m_IdIBoxDiv4Image).appendChild(img);
		
		alignIBoxVerticalTo("center");
      alignIBoxHorizontalTo("center");
	   m_iBox.style.visibility = 'visible';
	};
   img.src = bild;
}


/**
 * Re-initialisiert die Button zum Weiter und Zurück-klicken
 */
var reinitializePrevNextButtons = function()
{
	var nextDiv = document.getElementById(m_IdIBoxDivNext);
   var prevDiv = document.getElementById(m_IdIBoxDivPrev);
	var theImage = document.getElementById(m_IdIBoxContentImage);
	
	// anzuzeigende Bild ist das erste 
	if (m_IndexOfImagesToShow == 0)
	{
		nextDiv.className = "HrSys-Gips-iBoxDivNext";
		prevDiv.className = "HrSys-Gips-iBoxDivPreviousInactive";
		nextDiv.onclick   = showNextImageInIBox; 
		prevDiv.onclick   = "";
		theImage.onclick  = showNextImageInIBox;
	} 
	// anzuzeigende Bild ist das letzte
	else if (m_IndexOfImagesToShow == m_BilderArray.length - 1)
	{
		nextDiv.className = "HrSys-Gips-iBoxDivNextInactive";
		prevDiv.className = "HrSys-Gips-iBoxDivPrevious";
		nextDiv.onclick   = ""; 
		prevDiv.onclick   = showPrevImageInIBox;
		theImage.onclick  = "";
	} 
	// ansonsten 
   else
	{
		nextDiv.className = "HrSys-Gips-iBoxDivNext";
		prevDiv.className = "HrSys-Gips-iBoxDivPrevious";
		nextDiv.onclick   = showNextImageInIBox; 
		prevDiv.onclick   = showPrevImageInIBox; 
		theImage.onclick  = showNextImageInIBox;
	}
}


/**
 * Zeigt das nächste Bild in der iBox an. 
 */
var showNextImageInIBox = function()
{
	var nextDiv = document.getElementById(m_IdIBoxDivNext);
	var index = ++m_IndexOfImagesToShow;
	
	if(m_BilderArray           && m_BilderArray.length           > m_IndexOfImagesToShow) setIBoxContentImage( m_BilderArray          [index] );		
	if(m_BildNamenArray        && m_BildNamenArray.length        > m_IndexOfImagesToShow) setTitle(            m_BildNamenArray       [index] );		
	if(m_BildunterschriftArray && m_BildunterschriftArray.length > m_IndexOfImagesToShow) setDescription(      m_BildunterschriftArray[index] );
	setNumber(m_IndexOfImagesToShow);
	
	reinitializePrevNextButtons();
}

/**
 * Zeigt das vorgänger Bild in der iBox an
 */
var showPrevImageInIBox = function()
{
   var prevDiv = document.getElementById(m_IdIBoxDivPrev);
	var index = --m_IndexOfImagesToShow;
   
   if(m_BilderArray           && m_BilderArray.length           > m_IndexOfImagesToShow) setIBoxContentImage( m_BilderArray          [index] );    
   if(m_BildNamenArray        && m_BildNamenArray.length        > m_IndexOfImagesToShow) setTitle(            m_BildNamenArray       [index] );    
   if(m_BildunterschriftArray && m_BildunterschriftArray.length > m_IndexOfImagesToShow) setDescription(      m_BildunterschriftArray[index] );
	setNumber(m_IndexOfImagesToShow);
	
	reinitializePrevNextButtons();
}

/**
 * Erstellt ein HTML-Element vom übergebenen Typ mit absoluter Positionierung und hier übergebener Größe.
 * @param {Object} tagName
 * @param {Object} xwidth
 * @param {Object} yheight
 * @param {Object} xpos
 * @param {Object} ypos
 * @param {Object} id
 */
function createFloatingElement(tagName, xwidth, yheight, xpos, ypos, id)
{
   var element    = createFloatingElementAtPosition(tagName, xpos, ypos, id)
   element.style.width  = xwidth;                                  // 
   element.style.height = yheight;                                 //
   return element;
}

/**
 * Erstellt ein iFrame mit absoluter Positionierung und hier übergebener Größe.
 * @param {Object} xwidth
 * @param {Object} yheight
 * @param {Object} xpos
 * @param {Object} ypos
 * @param {Object} id
 */
function createFloatingIFrame(xwidth, yheight, xpos, ypos, id)
{
   var element    = createFloatingElementAtPosition("iframe", xpos, ypos, id)
   element.width  = xwidth;                                  // 
   element.height = yheight;                                 //
   return element;
} 

/**
 * Erstellt ein HTML-Element vom übergebenen Typ mit absoluter Positionierung.
 * @param {Object} tagName Name des Tags
 * @param {Object} xpos x-Position
 * @param {Object} ypos y-Position
 * @param {Object} id die ID des Elements
 */
function createFloatingElementAtPosition(tagName, xpos, ypos, id) 
{
   var element = document.createElement(tagName);
   element.id             = id;                                      //
   element.style.position = 'absolute';                              // die Positionierung vom element auf absolut stellen
   element.style.left     = xpos + "px";                             //
   element.style.top      = ypos + "px";                             //
   //element.scrolling      = "auto"                                   // 
   document.getElementsByTagName("BODY")[0].appendChild(element);    // 
   
   return element;   
}


// ----------------- remove -------------------------------
/**
 * Entfernt das übergebene HTML-Element und löscht es aus dem Dombaum.
 * @param {Object} element
 */
function remove(element)
{
	if(element && element.parentNode)
	{
		element.parentNode.removeChild(element);
	}
}

/**
 * Löscht und entfernt die iBox.
 */
function removeAllIBoxElements()
{
	remove(m_BlackOverlay);
	remove(m_iFrame);
	remove(m_iBox);
	window.onresize = "";
}

// ----------------- align -------------------------------

/**
 * Richtet die iBox vertikal aus
 * @param {Object} positionAlsWort 
 */
var alignIBoxVerticalTo = function(positionAlsWort)
{
	var iBoxHeight = m_iBox.offsetHeight;
	var innerHeight;
	
	
	// Fensterhöhe browserabhängig bestimmen
   if(window.innerHeight)                          // nicht IE6
	{
	  innerHeight = window.innerHeight;
	}
	else if(document.documentElement)            // IE6
	{
		if (document.documentElement.clientHeight) 
		{
			innerHeight = document.documentElement.clientHeight;
		}
		else
		{
			innerHeight = document.documentElement.clientheight;
		}
	}
	
	// ScrollPosition mit einberechnen
	var scrollPos = getScrollPosition();
	
	// Positionierung
	if ( positionAlsWort.toUpperCase() == "TOP" || positionAlsWort.toUpperCase() == "OBEN")
	{
	  	m_iBox.style.top = 0 + scrollPos.y + "px";
	}
	else if ( positionAlsWort.toUpperCase() == "CENTER" || positionAlsWort.toUpperCase() == "MITTE")
	{
		m_iBox.style.top  = ((innerHeight - iBoxHeight) / 2) + scrollPos.y + "px";
	}
	else if ( positionAlsWort.toUpperCase() == "BOTTOM" || positionAlsWort.toUpperCase() == "UNTEN")
	{
		m_iBox.style.top  = (innerHeight - iBoxHeight) + scrollPos.y + "px";
	}
}

/**
 * Richtet die iBox horizontal aus
 * @param {Object} positionAlsWort
 */
var alignIBoxHorizontalTo = function(positionAlsWort)
{
	var iBoxWidth = m_iBox.offsetWidth;
	var innerWidth;
   
   // ((window.width - ibox.width) / 2) = Abstand nach links und rechts!
   if(window.innerWidth)                         // nicht IE6
   {
     innerWidth = window.innerWidth;
   }
   else if(document.body.clientWidth)            // IE6
   {
     innerWidth = document.body.clientWidth;
   }
	
	// TODO: ScrollPosition mit einberechnen
	// Positionierung
	if ( positionAlsWort.toUpperCase() == "LEFT" || positionAlsWort.toUpperCase() == "LINKS")
	{
	  	m_iBox.style.left = 0 + "px";
	}
	else if ( positionAlsWort.toUpperCase() == "CENTER" || positionAlsWort.toUpperCase() == "MITTE")
	{
		m_iBox.style.left  = ((innerWidth - iBoxWidth) / 2) + "px";
	}
	else if ( positionAlsWort.toUpperCase() == "RIGHT" || positionAlsWort.toUpperCase() == "RECHTS")
	{
		m_iBox.style.left  = (innerWidth - iBoxWidth) + "px";
	}
}


// ----------------- resize -------------------------------

/**
 * Setzt die Größe des tranzparenten Hintergrund-Divs auf die Größe des Browserfensters
 */
var resizeBlackOverlayWidthToDocumentBody = function()
{
	var width = getBodyWidth();
	var height = getBodyHeight(); 
	  
	document.getElementById(m_IdDiv).style.width  = width + "px"; 
	document.getElementById(m_IdDiv).style.height = height + "px";
	document.getElementById(m_IdIFrame).width     = (width-4) + "px";
	document.getElementById(m_IdIFrame).height    = (height-4) + "px";
}

// ----------------- getter - width / height / size -------------------------------

/**
 * Gibt die Breite des Document-Bodys zurück
 */
var getBodyWidth = function()
{
   if (document.documentElement.scrollWidth) 
   {
      return document.documentElement.scrollWidth;
   }
   else if (document.documentElement.scrollWidth)
   {
      return document.documentElement.scrollWidth;
   }
   
   var theBody = document.getElementsByTagName("BODY")[0];
   return getElementWidthValue(theBody);
}



/**
 * Gibt die Höhe des Document-Bodys zurück. Wenn jedoch die Fensterhöhe größer ist als 
 * der gerenderte Body, wird die Fenstergröße zurück gegeben.
 */
var getBodyHeight = function()
{
	if (document.documentElement.scrollHeight) 
	{
		return document.documentElement.scrollHeight;
	}
	else if (document.documentElement.offsetHeight)
	{
		return document.documentElement.offsetHeight;
	}
   
	var theBody = document.getElementsByTagName("BODY")[0];
	return getElementHeightValue(theBody);
}


/**
 * Gibt die (prozentuale) Breite des Client-Windows zurück. 
 */
var getClientWidthInPercentage = function(percentage)
{
	var innerWidth = 0;
	percentage = percentage / 100;
	
	// Fensterbreite browserabhängig bestimmen
   	if(window.innerWidth)                         // nicht IE6
   	{
     	innerWidth = window.innerWidth;
   	}
   	else if(document.body.clientWidth)            // IE6
   	{
     	innerWidth = document.body.clientWidth;
   	}
	
	return (percentage * innerWidth);
}

/**
 * Gibt die (prozentuale) Höhe des Client-Windows zurück. 
 */
var getClientHeightInPercentage = function(percentage)
{
	var innerHeight = 0;
	percentage = percentage / 100;
	
	// Fensterhöhe browserabhängig bestimmen
   	if(window.innerHeight)                          // nicht IE6
	{
	  innerHeight = window.innerHeight;
	}
	else if(document.documentElement)            // IE6
	{
  	  if (document.documentElement.clientHeight) 
	  {
	    innerHeight = document.documentElement.clientHeight;
     }
	  else
	  {
		 innerHeight = document.documentElement.clientheight;
	  }
	}
	
	return (percentage * innerHeight);
}

// ----------------- isInteger-Funktionen -------------------------------
/**
 * Prüft ob die übergebene Zahl eine positive ganze Zahl ist
 * @param {Object} s
 */
function isUnsignedInteger(s) 
{
  return (s.toString().search(/^[0-9]+$/) == 0);
}

/**
 * Prüft ob die übergebene Zahl eine Ganzzahl ist
 * @param {Object} s
 */
function isInteger(s) 
{
  return (s.toString().search(/^-?[0-9]+$/) == 0);
}

// ----------------- Timer-Funktionen -------------------------------
/**
 * 
 * @param {Object} timeToDisappear
 */
var setTimeToDisappear = function (timeToDisappear)
{
   m_TimeoutToDisappear = setTimeout("removeAllIBoxElements();",timeToDisappear*1000);
}

var deleteTimeout = function (timeout)
{
	window.clearTimeout(timeout);
}


