/*
                                                 ~~~~~
    Have a nice day ...                         ( º º )
+-------------------------------------------vvvO--(_)--Ovvv----+
|                                                              |
|        JavaScript RTJ Webseite                               |
|        Buttonfunktionen                                      |
|        (c)WF 11-2004                                         |
|                                          .oooO               |
|                                          (   )       Oooo.   |
+------------------------------------------ \ (--------(   )---+
                                             \_)        ) /
                                                       (_/
*/


// -------------------------------------------------------------------
// Globale Variable
// -------------------------------------------------------------------
var bcnt = 0;                 // Schaltflächenanzahl
var btns = new Array();       // Schaltflächenarray
var activebutton = -0;        // -1 zum aktivieren -2 zum deaktivieren
var usetitle = 1;             // Auf Schaltfläche Titel anzeigen

// -------------------------------------------------------------------
// Buttoneigenschaften initialisieren
// -------------------------------------------------------------------
function InitButton(idx, nam, pic, pich, stat)
  {
    btns[bcnt] = new Array();
    btns[bcnt]["Z"] = idx;           // Index
    btns[bcnt]["N"] = nam;           // Name
    btns[bcnt]["P"] = pic;           // Normales Bild
    btns[bcnt]["H"] = pich;          // Highlight Bild
    btns[bcnt]["S"] = stat;          // Statustext
    
    bcnt = bcnt + 1;
    
    img = new Image();   // Preload Normales Bild
    img.src = pic;

    img1 = new Image();  // Preload Highlight Bild
    img1.src = pich;

  }

// -------------------------------------------------------------------
// Buttonbild ändern
// -------------------------------------------------------------------
function SetButtonPic(nam, state)
  {
    var idx = -1;
    var img = document.getElementById(nam);

    for (var i=0; i<bcnt; i++)
      {
        if (btns[i]["N"] == nam)
          {
            idx = i;
            break;
          }
      }

    if (idx == activebutton) { state = 1; }
    
    if (state == 0)
      {
        img.src = btns[idx]["P"];
      }
    else
      {
        img.src = btns[idx]["H"];
      }
      
    if (usetitle == 1)
      {
        img.title = btns[idx]["S"];
      }
  }

// -------------------------------------------------------------------
// Button anklicken
// -------------------------------------------------------------------
function ClickIt(idx)
  {

    if (activebutton == -2)
      {
        return;
      }
    
    activebutton = idx - 1;

    for (var i=0; i<bcnt; i++)
      {
        if (btns[i]["Z"] != idx)
          {
            SetButtonPic(btns[i]["N"], 0);
          }
      }    
    
  }

// -------------------------------------------------------------------
// Statustext zurückgeben
// -------------------------------------------------------------------
function GetStatus(idx)
  {
    return btns[(idx - 1)]["S"];
  }

// -------------------------------------------------------------------
// Bild Transparent schalten
// -------------------------------------------------------------------
function BlendThis(cur, which)
{
  if (which == 0)
    {
      cur.filters.alpha.opacity = 100;
    }
  else
    {
      cur.filters.alpha.opacity = 50;
    }
}

// -------------------------------------------------------------------
// EOF
// -------------------------------------------------------------------

