var aktives_timeOut=null;
var aktive_set_In=null;
var ani_bild; 
function aniBild( das_bild )
 {
 	if( ani_bilder.length > 0 )
 	{
   ani_bild = new Bild( das_bild );
  } 
 } 

function Bild( bild )
{
 this._bild = bild;  											// das Bild
 this._parentEle = this._bild.parentNode; // das obere objekt vom Bild
 
  // alpha wert
 this.Alpha_zahl=1.5;
 this.Alpha_Soll=1;
 this.d_alpha=1;
 this._geschwindigkeit = 3.5 ; 
 
 // id von allen divs
 this._alle_divs = Array();
 this._z_index_start= 300000;
 // ini divs erzeugen und z-index setzen
 this._divs="";
 this._zahl = ani_bilder.length;
 for(var d=0; d < ani_bilder.length ; d++)
 {
 	var _id = ani_bilder[d].split("\.");
 	_id=_id[0];
 	this._alle_divs[d] = _id; 
 	this._divs+='<div style="position:absolute; z-index:'+(this._z_index_start+this._zahl-d)+'" class="ani_bilder" id="'+_id+'"><img src="'+ani_bilder[d]+'"/></div>';
 }
 /*------------*/
 // in die tabelle td einfügen 
 this._parentEle.innerHTML=this._divs;
 
  
 this.oberstes_div = this._alle_divs[0]; 
 this.oberstes_div_zahl = 0; 
 
  
 
 this.alpha_set_null = function()
 {
  if( Math.abs( this.Alpha_Soll - this.d_alpha ) > 0.09 )
 	{
   this.d_alpha += ( Math.cos(this.Alpha_zahl)*( this.Alpha_Soll - this.d_alpha ) );
   
   this.opacity_setzen( this.d_alpha );
   this.Alpha_zahl -= 0.05*( Math.random()* this._geschwindigkeit );
  }
 else
  {	
 	 this.opacity_setzen( this.Alpha_Soll );
   this.Alpha_zahl=1.5;
   this.d_alpha=1;
   
   
   if( aktive_set_In != null )
   {
    window.clearInterval( aktive_set_In );
    aktive_set_In=null;
    this.pause();
    
    // z-index runtersetzen und alpha wieder auf 100% setzen  
    document.getElementById( this.oberstes_div ).style.zIndex = document.getElementById( this.oberstes_div ).style.zIndex - ani_bilder.length;
    this.wieder_einblenden( this.oberstes_div );
  	
  	//nächsten div-Tag setzen
    this.oberstes_div_zahl++;
    this.oberstes_div = this._alle_divs[ this.oberstes_div_zahl ]; 
    
    //wenn Array länge überschritten wieder von vorne beginnen
    if( this.oberstes_div_zahl >= (this._alle_divs.length) )
    {
     this.oberstes_div_zahl=0;
     this.oberstes_div = this._alle_divs[ this.oberstes_div_zahl ]; 
    }
      
   }
  } 
 }
 
 
 this.alpha_set_hundert = function()
 {
  if( Math.abs( this.Alpha_Soll - this.d_alpha ) > 0.09 )
 	{
   this.d_alpha += ( Math.cos(this.Alpha_zahl)*( this.Alpha_Soll - this.d_alpha ) );
   
   this.opacity_setzen( this.d_alpha );
   this.Alpha_zahl -= 0.05*( Math.random()* this._geschwindigkeit );
  }
 else
  {	
 	 this.opacity_setzen( this.Alpha_Soll );
   this.Alpha_zahl=1.5;
   this.d_alpha=1;
   
   
   if( aktive_set_In != null )
   {
    window.clearInterval( aktive_set_In );
    aktive_set_In=null;
    
    this.pause();
    
    // alpha wieder auf 100% setzen  
    this.wieder_einblenden( this.oberstes_div );
  
   }
   
  } 
 }
 
 
 this.naechstesBild = function()
 {
 	this.Alpha_Soll=0.0;
  aktive_set_In=window.setInterval( "ani_bild.alpha_set_null()" , 100 );
 }
 
 this.vorherigesBild = function()
 {
 	this.Alpha_Soll=1.0;
 	this.d_alpha=0;
 	this.oberstes_div_zahl--;
 	if( this.oberstes_div_zahl < 0 )
 	{
 	 this.oberstes_div_zahl = this._alle_divs.length-1;
  }

  this.oberstes_div = this._alle_divs[ this.oberstes_div_zahl ]; 
  this.wieder_ausblenden( this.oberstes_div );
  
  document.getElementById( this.oberstes_div ).style.zIndex = Number(document.getElementById( this.oberstes_div ).style.zIndex) + ani_bilder.length;
  aktive_set_In=window.setInterval( "ani_bild.alpha_set_hundert()" , 100 );
  
 }
 
  
 this.pause =function()
 {
  aktives_timeOut = window.setTimeout( "ani_bild.naechstesBild()" , 3000 );
 }


 this.weiter = function()
 {
  if( aktive_set_In == null )
  {
   //alert( aktives_timeOut );
   if( aktives_timeOut != null )
   {
    window.clearTimeout( aktives_timeOut );
    aktives_timeOut = null;
   }
   this.naechstesBild();
  }
 }
 
 
 this.zurueck = function()
 {
  if( aktive_set_In == null )
  {
   //hier muss z-index noch gesetzt werden und dann wieder eingeblendet werden!!
   if( aktives_timeOut != null )
   {
    window.clearTimeout( aktives_timeOut );
    aktives_timeOut = null;
   }
   this.vorherigesBild();
  }
 }
   
 
 this.opacity_setzen = function(wert)
 {
  if( navigator['appName'] == "Microsoft Internet Explorer" )
  {
   document.getElementById( this.oberstes_div ).filters.item("DXImageTransform.Microsoft.Alpha").opacity = Math.round(wert*100) ;
  }
  else
  {
   document.getElementById( this.oberstes_div ).style.opacity = wert.toString();
  }
 }
 
 this.wieder_einblenden = function(wert)
 {
  if( navigator['appName'] == "Microsoft Internet Explorer" )
  {
   document.getElementById( wert ).filters.item("DXImageTransform.Microsoft.Alpha").opacity = 100 ;
  }
  else
  {
   document.getElementById( wert ).style.opacity = "1";
  }
 }
 
this.wieder_ausblenden = function(wert)
 {
  if( navigator['appName'] == "Microsoft Internet Explorer" )
  {
   document.getElementById( wert ).filters.item("DXImageTransform.Microsoft.Alpha").opacity = 0 ;
  }
  else
  {
   document.getElementById( wert ).style.opacity = "0";
  }
 } 

//timer setzen, also alles starten
 this.pause();
}


/*
function schau()
{
	document.getElementById('laden').src="/image/blau_menue.gif";
	B_width =bild.width;
	B_height=bild.height;
	//alert(B_width+"  "+B_height);
	B_width_ist =30;
	B_height_ist=30;
	zahl=1.5;
	document.getElementById('schwarz_blende').style.minWidth=""+(B_width+80)+"px";
	document.getElementById('schwarz_blende').style.minHeight=""+(B_height+90)+"px";
	
  inter=setInterval( "skalieren()" , 10 );
} 

function skalieren()
{
 if ( Math.abs( B_width_ist-B_width ) > 0.5 )
  {
 	 B_width_ist  += Math.cos(zahl)*(B_width-B_width_ist);
 	 B_height_ist += Math.cos(zahl)*(B_height-B_height_ist);
 	 document.getElementById('laden').style.width =""+B_width_ist+"px";//B_width_ist;
	 document.getElementById('laden').style.height=""+B_height_ist+"px";//B_height_ist;
	}
else
	{
	 clearInterval(inter);
	 document.getElementById('laden').src=bild.src;
	 //document.getElementById('laden').className="laden_border";
	}
zahl-=0.1;
}


function schliessen()
{
 document.getElementById('spacer1').className="layer_aus";
 document.getElementById('schwarz_blende').className="layer_aus";
 delete bild;
}
*/
