
window.defaultStatus = "Adolf Sauter GmbH & Co.KG";
window.status = 'Adolf Sauter GmbH & Co.KG';

function BilderLadenFertig_Leer(){  }
function BilderLadenProzent_Leer(i){  }

function FotoOeffnen(nr)
{
	var quelle = "../foto/foto" + nr + ".html";
	var breite = 800;
	var hoehe = 625;
	var foto_fenster = window.open(quelle, "foto_fenster", "width=" + breite + ",height=" + hoehe + ", left=0, top=0, resizable=no toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, copyhistory=no");

	foto_fenster.focus();
}

// ----------------
//    Diashow 
// ----------------
function Diashow()
{
	if(this.durchlauf < (this.anzahlFoto-1))
	{
		document.images.diaFoto.src = this.fotoDia[this.durchlauf].src;
		this.durchlauf++;
	}
	else
	{
		document.images.diaFoto.src = this.fotoDia[this.durchlauf].src;
		this.durchlauf = 0;
	}
	window.setTimeout("preloader.DiaShowStarten()", 5000);
}

// -----------------
//    Preloader 
// -----------------
function PreloaderErstellen()
{
	this.frequenz = 100;

	this.bilderLadenFertig = BilderLadenFertig_Leer;
	this.bilderLadenProzent = BilderLadenProzent_Leer;

	this.pics = new Array(); 
	this.imgs = new Array();
	this.fotoDia = new Array();
	
	this.imgs.length = this.pics.length;
	for(i=0;i<this.imgs.length;i++)
	{
		this.imgs[i] = new Image();
	}
	this.status = false;

	this.durchlauf = 0;
	this.anzahlFoto = 5;
	
	this.fotoDia[0] 	= new Image(); 
	this.fotoDia[0].src	= "../image/dias/dia1.jpg";
	this.fotoDia[1]		= new Image(); 
	this.fotoDia[1].src	= "../image/dias/dia2.jpg";
	this.fotoDia[2]		= new Image(); 
	this.fotoDia[2].src	= "../image/dias/dia4.jpg";
	this.fotoDia[3]		= new Image(); 
	this.fotoDia[3].src	= "../image/dias/dia3.jpg";
	this.fotoDia[4]		= new Image(); 
	this.fotoDia[4].src	= "../image/dias/dia6.jpg";
	
	this.DiaShowStarten = Diashow;
	
	this.BildHinzufuegen = Preloader_BildHinzufuegen; 
	this.BildLaden = Preloader_BildLaden; 
	this.BilderLaden = Preloader_BilderLaden;
	this.ProzentStatus = Preloader_ProzentStatus;
	this.BildStatusErmitteln = Preloader_BildStatusErmitteln;
}

function Preloader_BildHinzufuegen(n)
{ 
	this.pics[this.pics.length] = n; 
	return(this.pics.length-1); 
}

function Preloader_BilderLaden()
{ 
	for(i=0;i<this.pics.length;i++)
	{ 
		this.BildLaden(i); 
	}
}

function Preloader_BildLaden(i)
{
	img = new Image(); 
	this.imgs[i] = img; 
	img.src = this.pics[i];
	if(this.status == false)
	{
		window.setTimeout('preloader.BildStatusErmitteln()',this.frequenz);
		this.status = true;
	}
	return(img);
}

function Preloader_ProzentStatus()
{
	var prozent,anzahl = 0;
	for(i=0;i<this.imgs.length;i++)
	{ 
		if(this.imgs[i].complete == true)
		{ 
			anzahl++; 
		}
	}
	prozent = Math.round((anzahl/this.imgs.length)*100);
	return(prozent)
}

function Preloader_BildStatusErmitteln()
{
	var anzahl = true;
	for(i=0;i<this.imgs.length;i++)
	{ 
		if(this.imgs[i].complete == false)
		{ 
			anzahl = false; 
		} 
	}
	if(typeof(this.bilderLadenProzent) == 'function')
	{
		this.bilderLadenProzent(this.ProzentStatus())
	}
	if(anzahl == true && typeof(this.bilderLadenFertig) == 'function')
	{ 
		this.DiaShowStarten();
		//this.bilderLadenFertig(); 
	}
	else
	{
		window.setTimeout('preloader.BildStatusErmitteln()',this.frequenz)
	}
}
