﻿/**
* FixxbuyVergroessernPopUp
*
* Wird für die Navigation innerhalb des VergroessernPopUp
* genutzt.
*
* Erstellt: 18.06.2008, Daniel Schwarz, *1977 Bochum
*/
function FixxbuyVergroessernPopUp() {

  this._aryBilder = Array();
  this._iAktBild = 0;
  this._divNumerischeNavigation;
  this._iInnerHeight;
  this._divVersionen;
  
  /**
  * Initialisieren
  *
  * Diese Methode ist aufzurufen nachdem die Bilder durch
  * die Methode Add() hinzugefügt worden sind und sollte
  * am Fuss der HTML Seite aufgerufen werden.
  *
  * @return void
  */
  this.Init = function() 
  {
    this._divNumerischeNavigation = document.getElementById("VergroessernPopUpNummerischeNavigation");
    this._divVersionen = document.getElementById("Versionen");
    
    
    this._imgBild = document.getElementById("VergroessernPopUpBild");
    this._iAktBild = 0;
    this._aNummerischeNavigationAlt = null;
    
    
    if (this._aryBilder.length > 1) 
    {
      
      // Aufbau der Numerischen Navigation
      strHtml = '';
      for (var i=0;i<this._aryBilder.length;++i) {
        strHtml += '<a href="#" id="VergroessernPopUpNummerischeNavigation'+i+'" class="Normal" onclick="fixxbuyVergroessernPopUp.SetzeBild('+i+');return false;">' + 
        '<img src="' + this._aryBilder[i][0] + '" height="40" width="40" alt="' + i + '">' +
        '</a>';
        if (i<this._aryBilder.length-1) strHtml += '&nbsp;&nbsp;';
      }
      this._divNumerischeNavigation.innerHTML = strHtml;
      this._aNummerischeNavigationAlt = document.getElementById("VergroessernPopUpNummerischeNavigation0");
      
    }  
    
    this.SetzeBild(this._iAktBild);
    
  }
  
  
  this.Zeigen = function() {
    
    this._divNumerischeNavigation.style.display = 'inline';
    
    this._divVersionen.style.display = 'none';
    
    document.getElementById("VergroessernPopUp").style.visibility = 'visible';
  }
  
  this.Verstecken = function() {
    document.getElementById("VergroessernPopUp").style.visibility = 'hidden';
    this._divNumerischeNavigation.style.display = 'none';
    this._divVersionen.style.display = 'block';
  }


  this.ZeigeBild = function(iBild) {
    this.SetzeBild(iBild);
    this.Zeigen();
  }


  
  
  /**
  * Setzt das Aktive Bild in der Vergrößerung
  *
  * @param int iBild Bild nummer die angezeigt werden soll
  * @return void
  */
  this.SetzeBild = function(iBild) 
  {
    if (iBild >= 0 && iBild < this._aryBilder.length) 
    {
      this._iAktBild = iBild;
      this._imgBild.setAttribute("src",this._aryBilder[iBild][1]);
      
      if (this._aryBilder.length > 1) 
      {
        if (this._aNummerischeNavigationAlt != null) {
          this._aNummerischeNavigationAlt.className = 'Normal';
        }
        this._aNummerischeNavigationAlt = document.getElementById("VergroessernPopUpNummerischeNavigation" + iBild);
        this._aNummerischeNavigationAlt.className = 'Aktiv';
        
      }
    }
  }
  
  
  /**
  * Setzt das Naechste Bild in der Vergroesserungsansicht,
  * und schaltet ggf. die Naechste Bild Schaltfläche auf unsichtbar.
  *
  * @return void
  */
  this.NaechstesBild = function() 
  {
    if (this._iAktBild < this._aryBilder.length) {
      this._iAktBild++;
    } 
    if (this._iAktBild == this._aryBilder.length) {
      this._iAktBild = 0;
    }
    this.SetzeBild(this._iAktBild);
  }
  
  /**
  * Setzt das Vorherige Bild in der Vergroesserungsansicht,
  * und schaltet ggf. die Vorheriges Bild Schaltfläche auf unsichtbar.
  *
  * @return void
  */
  this.VorherigesBild = function() 
  {
    if (this._iAktBild > 0) {
      this._iAktBild--;
    } else
    if (this._iAktBild == 0) {
      this._iAktBild = this._aryBilder.length-1;
    }
    this.SetzeBild(this._iAktBild);
  }

  /**
  * Fügt ein Bild hinzu
  *
  * @param string strBild Absolute Url zum Bild
  */
  this.Add = function(strBildKlein,strBildGross) {
    var i = this._aryBilder.length;
    this._aryBilder[i] = new Array();
    this._aryBilder[i][0] = strBildKlein;
    this._aryBilder[i][1] = strBildGross;
  }


}