/**
* @author Marko Walther
* @date 10.01.2007
*
*	@desc javascript-code des CMS
*/

  g_aCMSInfos = new Object();
  g_aCMSInfos.m_aTitles = new Object();
  g_aCMSInfos.m_aDescs = new Object();
  
  g_aCMSInfos.m_aTitles["uebersicht"] = "Seitenübersicht:";
  g_aCMSInfos.m_aDescs["uebersicht"] = "In dieser Tabelle sind alle Seiten "+
  "aufgelistet, die bearbeitet werden können.<br><br>" +
  "Um eine Seite zu bearbeiten,<br>klicken Sie rechts " +
  "neben dem jeweiligen Seitennamen in der Spalte 'Werkzeuge'<br>" +
  "auf das Stift-Symbol.";

  g_aCMSInfos.m_aTitles["edit_part_header"] = "Blockwerkzeuge:";
  g_aCMSInfos.m_aDescs["edit_part_header"] = "Mit den links stehenden Werkzeugen "+
  "können Sie das Aussehen des Blockes verändern.<br><br>"+
  "Der Button &quot;<b>Text+Bild übernehmen</b>&quot; muss gedrückt "+
  "werden, um Änderungen des HTML-Inhaltes bzw. des Bildes zu übernehmen.";

  g_aCMSInfos.m_aTitles["edit_part_edit_tools"] = "Textwerkzeuge:";
  g_aCMSInfos.m_aDescs["edit_part_edit_tools"] = "Mit den links stehenden Werkzeugen "+
  "können Sie den Text im Eingabefeld unten formatieren.<br>"+
  "<br>" +
  "Um z.B. einen Textteil als <b>fett</b> zu markieren, selektieren Sie zuerst "+
  "die entsprechende Textpassage mit der Maus oder der Tastatur und klicken "+
  "Sie anschliessend auf den Button &quot<b>Text</b>&quot;.";
  
  g_aCMSInfos.m_aTitles["uebersicht_willk_bild"] = "Startseitenbild hochladen:";
  g_aCMSInfos.m_aDescs["uebersicht_willk_bild"] = "Um ein Bild für die &quot;Willkommen&quot;-Seite "+
  "hochzuladen, gehen Sie wie folgt vor:<br>"+
  "<br>"+
  "<b>1. Klicken Sie auf &quot;Durchsuchen...&quot; und wählen Sie die gewünschte " +
  "Bilddatei aus.<br>"+
  "<br>"+
  "2. Klicken Sie jetzt auf &quot;Hochladen&quot;.<br>"+
  "<br>"+
  "3. Möchten Sie eine Vorschau auf die neue Willkommen-Seite haben, klicken Sie "+
  "jetzt auf &quot;Vorschau&quot;. Es öffnet sich dann die Vorschau-Seite, die Sie "+
  "durch Klicken auf &quot;zur Übersicht&quot; wieder verlassen können.<br>"+
  "<br>"+
  "4. Klicken Sie jetzt auf &quot;Veröffentlichen&quot; und as Bild erscheint auf "+
  "der Willkommen-Seite.<br><br></b>";
  
  /**
  * @desc Gibt den Titel der Erläuterung mit der geg. ID zurück
  * @param string sID ID der Erläuterung
  * @return string Titelstring oder null
  */ 
  function cmsGetInfoTitle( sID ) {
    
    if( typeof( g_aCMSInfos.m_aTitles[ sID ] ) != "undefined" ) {
      
      return g_aCMSInfos.m_aTitles[ sID ];
      
    } else {
      
      return null;
      
    } // if
    
  } // function cmsGetInfoTitle
  
  /**
  * @desc Gibt den Inhalt der Erläuterung mit der geg. ID zurück
  * @param string sID ID der Erläuterung
  * @return string Inhaltsstring oder null
  */ 
  function cmsGetInfoContents( sID ) {
    
    if( typeof( g_aCMSInfos.m_aDescs[ sID ] ) != "undefined" ) {
      
      return g_aCMSInfos.m_aDescs[ sID ];
      
    } else {
      
      return null;
      
    } // if
    
  } // function cmsGetInfoContents
    
  /**
  *
  * @class CCMSInfoBox
  *
  */
  /**
  * @desc Konstruktor. Erstellt die Info-Box
  */
  function CCMSInfoBox() {
    
    this.m_pDiv = null; // der Boxknoten
      
    this.m_pDiv = document.createElement( "DIV" );
    this.m_pDiv.className = 'cms_infobox';
    this.m_pDiv.style.visibility = 'hidden';
    
    document.getElementsByTagName( "BODY" )[0].appendChild( this.m_pDiv );
    
    /**
    * @desc setzt Inhalt und Titel der Info-Box
    * @param string sTitel Titel der Box 
    * @param string sInhalt Inhalt der Box 
    */
    this.setContents = function( sTitel, sInhalt ) {
      
      var sCont;
      sCont = '<table cellpadding="0" cellspacing="0" width="100%">';
        sCont += '<tr>';
          sCont += '<td class="title">'+sTitel+'</td>';
        sCont += '</tr>';
        sCont += '<tr><td height="1" class="spacer"></td></tr>';
        sCont += '<tr>';
          sCont += '<td class="contents">'+sInhalt+'</td>';
        sCont += '</tr>';
      sCont += '</table>';
      this.m_pDiv.innerHTML = sCont;
      
    } // function this.setContents
     
  } // function CCMSInfoBox
  
  /**
  * @global pointer g_pInfoBox es kann nur einen geben...
  */
  var g_pCMSInfoBox = null;
  
  /**
  * @desc erstellt die InfoBox
  */
  function cmsInfoBoxCreate() {
    
    g_pCMSInfoBox = new CCMSInfoBox();
    
  } // function cmsInfoBoxCreate
  
  /**
  * @desc zeigt oder versteckt die InfoBox
  * @param boolean bShow true zeigen, false verstecken 
  * @param integer nWidth Breite der Info-Box in px 
  * @param integer nHeight Höhe der Info-Box in px 
  * @param string sID ID des Box-Inhaltes 
  */
  function cmsInfoBoxShow( bShow, sID ) {
    
    if( g_pCMSInfoBox == null ) {
      
      return;
    
    } // if
    
    if( bShow == true ) {
      
      if( g_pCMSInfoBox.m_pDiv.style.visibility == 'hidden' ) {
      
        g_pCMSInfoBox.setContents( cmsGetInfoTitle( sID ), cmsGetInfoContents( sID ) );
        g_pCMSInfoBox.m_pDiv.style.visibility = 'visible';
      
      } // if
          
    } else {
  
      g_pCMSInfoBox.m_pDiv.style.visibility = 'hidden';
          
    } // if
    
  } // function cmsInfoBoxShow
  
  /**
  * @desc Funktion positioniert die Infobox ca an die Mausposition
  */
  function cmsInfoBoxPosToMouse() {
    
    var nPosX = g_MousePos.x;
    var nPosY = g_MousePos.y+20;
    
    if( document.all ) { // IE (angenommen im Standardkonformen Modus)
       
      nPosX += document.documentElement.scrollLeft;
      nPosY += document.documentElement.scrollTop;
      
    } // if
    
    g_pCMSInfoBox.m_pDiv.style.left = nPosX+'px';
    g_pCMSInfoBox.m_pDiv.style.top = nPosY+'px';

  } // function cmsInfoBoxPosToMouse
  
  var g_pStyleSel = null;
  
  /**
      * Funktion behandelt das MouseOver-Ereignis über einem Style-Vorschau-Element im CMS
      * @param Node pStyleDiv Style-Vorschau-Box unter Maus
      */
  function cmsPrevBlock_MouseOver( pStyleDiv ) {
    
    if( pStyleDiv != g_pStyleSel ) {
      
      pStyleDiv.className = 'block_style_preview_over';
    
    } // if
    
  } // function cmsPrevBlock_MouseOver
  
  
  /**
      * Funktion behandelt das MouseOut-Ereignis über einem Style-Vorschau-Element im CMS
      * @param Node pStyleDiv Style-Vorschau-Box unter Maus
      */
  function cmsPrevBlock_MouseOut( pStyleDiv ) {
    
    if( pStyleDiv != g_pStyleSel ) {
    
      pStyleDiv.className = 'block_style_preview';
    
    } // if
    
  } // function cmsPrevBlock_MouseOut
  
  
  /**
      * Funktion behandelt das MouseDown-Ereignis über einem Style-Vorschau-Element im CMS
      * @param Node pStyleDiv Style-Vorschau-Box unter Maus
      * @param string sStyle Style-Name
      */
  function cmsPrevBlock_MouseDown( pStyleDiv, sStyle ) {
    
    if( pStyleDiv != g_pStyleSel ) {
    
      if( g_pStyleSel != null ) g_pStyleSel.className = 'block_style_preview';
      g_pStyleSel = pStyleDiv;
      g_pStyleSel.className = 'block_style_preview_selected';
      document.form_cms_blockedit.blockstyle.value = sStyle;
      
    } // if
  
  } // function cmsPrevBlock_MouseDown