// we don't populate the images array because the php-script in head.php did that for us

divid_left = "ambi_left"; //the id of the div container that will hold the slideshow
divid_top = "ambi_top"; //the id of the div container that will hold the slideshow
divid_right = "ambi_right"; //the id of the div container that will hold the slideshow

picwid_left = 79; //breite des breitesten bildes in pixel
pichei_left = 966; //höhe des höchsten bildes in pixel

picwid_top = 789; //breite des breitesten bildes in pixel
pichei_top = 14; //höhe des höchsten bildes in pixel

picwid_right = 78; //breite des breitesten bildes in pixel
pichei_right = 966; //höhe des höchsten bildes in pixel

ambi_backgr="#eeeeee"; //hintergrundfarbe der slideshow, falls verschieden grosse oder transparente bilder
//verwendet werden, kann hier z.B. die hintergrundfarbe der seite gesetzt werden
ambi_sdur = 30; 		//zeit zwischen den wechseln (überblendung) in sekunden
ambi_fdur = 10; 		//dauer des übergangs (überblendung) in sekunden
ambi_steps = 50; 	//schritte in denen überblendet wird (je mehr dest sanfter)
ambi_startwhen = 1;	// "ambi_startwhen" bleibt "null" wenn das script von der seite z.B. per link gestartet wird

//(beispiel: <a href="javascript:myfade();">slide</a>)
// oder wird auf 1 gesetzt, damit das script beim laden der seite automatisch startet
//das wars auch schon, viel spass :)
//mit einem zufälligen bild starten: s
//****************************************************************

ambi_ftim = ambi_fdur * 1000 / ambi_steps;
ambi_stim = ambi_sdur * 1000;
ambi_emax = aAmbileft.length;

// write one div for each image
tp_left = "<div style='position:absolute;'>";
for (e=1; e <= ambi_emax; e++)
{
	theid = "imgLeft" + e;
	thesrc = aAmbileft[e-1];
	tp_left = tp_left +"<div id='" + theid + "'><img src='" + thesrc + "' border='0'/></div>";
}
tp_left = tp_left + "</div>";

tp_top = "<div style='position:absolute;'>";
for (e=1; e <= ambi_emax; e++)
{
	theid = "imgTop" + e;
	thesrc = aAmbitop[e-1];
	tp_top = tp_top +"<div id='" + theid + "'><img src='" + thesrc + "' border='0'/></div>";
}
tp_top = tp_top + "</div>";

tp_right = "<div style='position:absolute;'>";
for (e=1; e <= ambi_emax; e++)
{
	theid = "imgRight" + e;
	thesrc = aAmbiright[e-1];
	tp_right = tp_right +"<div id='" + theid + "'><img src='" + thesrc + "' border='0'/></div>";
}
tp_right = tp_right + "</div>";


// write all style-sheets for all style-divs
document.write("<style type='text/css'>");
for (b=1; b <= ambi_emax; b++)
{
	thestylid_left = "imgLeft" + b;
	thestylid_top = "imgTop" + b;
	thestylid_right = "imgRight" + b;
	thez = 1;
	thevis = 'hidden';
	if (b <= 1) 
	{
		thez = 2; 
		thevis = 'visible';
	}
	document.write("#" + thestylid_left + " {position:absolute;left:0;top:0;width:" + picwid_left + "px;height:" + pichei_left + "px;background-color:" + ambi_backgr + ";visibility:" + thevis + ";z-index:" + thez + ";}");
	document.write("#" + thestylid_top + " {position:absolute;left:0;top:0;width:" + picwid_top + "px;height:" + pichei_top + "px;background-color:" + ambi_backgr + ";visibility:" + thevis + ";z-index:" + thez + ";}");
	document.write("#" + thestylid_right + " {position:absolute;left:0;top:0;width:" + picwid_right + "px;height:" + pichei_right + "px;background-color:" + ambi_backgr + ";visibility:" + thevis + ";z-index:" + thez + ";}");
}
document.write("</style>");

function ambi_myfade()
{
	parr_left = new Array();
	parr_top = new Array();
	parr_right = new Array();
	
	for (a=1; a <= ambi_emax; a++)
	{
		idakt_left = "imgLeft" + a;
		idakt_top = "imgTop" + a;
		idakt_right = "imgRight" + a;

		paktidakt_left = document.getElementById(idakt_left);
		paktidakt_top = document.getElementById(idakt_top);
		paktidakt_right = document.getElementById(idakt_right);
	
		ie5exep_left = new Array(paktidakt_left);
		ie5exep_top = new Array(paktidakt_top);
		ie5exep_right = new Array(paktidakt_right);
				
		parr_left = parr_left.concat(ie5exep_left);
		parr_top = parr_top.concat(ie5exep_top);
		parr_right = parr_right.concat(ie5exep_right);
		
	}		
 	i = 1;
	u = 0;
	ambi_slide(i);
}

function ambi_slide(numa)
{
	ptofade_left = parr_left[numa-1];
	ptofade_top = parr_top[numa-1];
	ptofade_right = parr_right[numa-1];
	if (numa <= ambi_emax)
	{
		pnext_left = parr_left[numa];
		pnext_top = parr_top[numa];
		pnext_right = parr_right[numa];
	}
	if (numa == ambi_emax)
	{
		pnext_left = parr_left[0];
		pnext_top = parr_top[0];
		pnext_right = parr_right[0];
	}
		
	pnext_left.style.visibility = "visible";
	//pnext_left.style.filter = "Alpha(Opacity=100)";
	pnext_left.style.MozOpacity = 1;
	pnext_left.style.opacity = 1;
	//ptofade_left.style.filter = "Alpha(Opacity=100)";
	ptofade_left.style.MozOpacity = 1;
	ptofade_left.style.opacity = 1;
	
	
	pnext_top.style.visibility = "visible";
	//pnext_top.style.filter = "Alpha(Opacity=100)";
	pnext_top.style.MozOpacity = 1;
	pnext_top.style.opacity = 1;
	//ptofade_top.style.filter = "Alpha(Opacity=100)";
	ptofade_top.style.MozOpacity = 1;
	ptofade_top.style.opacity = 1;
	
	pnext_right.style.visibility = "visible";
	//pnext_right.style.filter = "Alpha(Opacity=100)";
	pnext_right.style.MozOpacity = 1;
	pnext_right.style.opacity = 1;
	//ptofade_right.style.filter = "Alpha(Opacity=100)";
	ptofade_right.style.MozOpacity = 1;
	ptofade_right.style.opacity = 1;

	factor = 100 / ambi_steps;
	ambi_slidenow();	
}

function ambi_slidenow()
{	
	check1_left = ptofade_left.style.MozOpacity;
	check1_top = ptofade_top.style.MozOpacity;
	check1_right = ptofade_right.style.MozOpacity;

	maxalpha = (100 - factor * u) / 100 * 105;
	if (check1_left <= maxalpha / 100)
	{
		u++;
	}
	curralpha = 100 - factor * u;
	
	//ptofade_left.style.filter = "Alpha(Opacity=" + curralpha + ")";
	ptofade_left.style.MozOpacity = curralpha / 100;
	ptofade_left.style.opacity = curralpha / 100;
	
	//ptofade_top.style.filter = "Alpha(Opacity=" + curralpha + ")";
	ptofade_top.style.MozOpacity = curralpha / 100;
	ptofade_top.style.opacity = curralpha / 100;

	//ptofade_right.style.filter = "Alpha(Opacity=" + curralpha + ")";
	ptofade_right.style.MozOpacity = curralpha / 100;
	ptofade_right.style.opacity = curralpha / 100;

	if (u < ambi_steps)
	{
		window.setTimeout("ambi_slidenow()", ambi_ftim);
	}
	if (u >= ambi_steps && i < ambi_emax)
	{
		ptofade_left.style.visibility = "hidden";		
		ptofade_left.style.zIndex = 2;
		pnext_left.style.zIndex = 3;		

		ptofade_top.style.visibility = "hidden";
		ptofade_top.style.zIndex = 2;
		pnext_top.style.zIndex = 3;		

		ptofade_right.style.visibility = "hidden";
		ptofade_right.style.zIndex = 2;
		pnext_right.style.zIndex = 3;		

		i++;
		u = 0;
		window.setTimeout("ambi_slide(i)", ambi_stim);
	}
	if (u >= ambi_steps && i >= ambi_emax)
	{
		ptofade_left.style.visibility = "hidden";
		ptofade_left.style.zIndex = 2;
		pnext_left.style.zIndex = 3;				
		
		ptofade_top.style.visibility = "hidden";
		ptofade_top.style.zIndex = 2;
		pnext_top.style.zIndex = 3;						
		
		ptofade_right.style.visibility = "hidden";
		ptofade_right.style.zIndex = 2;
		pnext_right.style.zIndex = 3;				
		
		i = 1;
		u = 0;
		window.setTimeout("ambi_slide(i)", ambi_stim);
	}		
}

function ambi_shownow()
{
	document.getElementById(divid_left).innerHTML = tp_left;
	document.getElementById(divid_right).innerHTML = tp_right;
	document.getElementById(divid_top).innerHTML = tp_top;
	if(ambi_startwhen)
	{		
		window.setTimeout("ambi_myfade()", ambi_stim);
	}
}
