/*   Fading Images Animation. Copyright  2005-2006, RomanticRoad e.K. Munich   

This code stacks photos on top of each other. It then reduces the opacity of the top photo until transparent and repeats.  After the second to last photo is transparent it starts over.  The last photo should be the same as the first photo. 
	
Note 1: Place in the head section the:   <script type="text/javascript" src="../jscode/animfade.js"></script>  

Note 2: Place in head section, for example:   adaptAbsPos("div.anim",415,125); nrfotos = 8; // animation images, nrfotos = no. of images

Note 3: Place in the body tag:     onLoad="startAnimfa();"  

Each photo is placed in a div container.  The div containers must have ids: fotofa1, fotofa2, ...... .   initAnimfade() should be placed 
just AFTER the div containers in the body tag.  For example: 
	
	document.write("<div id='fotofax'  class='anim' >"); adaptImg('../images/hotel1.jpg',560,210,'photo');document.write("</div>"); 
	document.write("<div id='fotofa8'  class='anim' >"); adaptImg('../images/hotel8.jpg',560,210,'photo');document.write("</div>");
	document.write("<div id='fotofa7'  class='anim' >"); adaptImg('../images/hotel7.jpg',560,210,'photo');document.write("</div>");
	document.write("<div id='fotofa6'  class='anim' >"); adaptImg('../images/hotel6.jpg',560,210,'photo');document.write("</div>");
	document.write("<div id='fotofa5'  class='anim' >"); adaptImg('../images/hotel5.jpg',560,210,'photo');document.write("</div>");
	document.write("<div id='fotofa4'  class='anim' >"); adaptImg('../images/hotel4.jpg',560,210,'photo');document.write("</div>");			
	document.write("<div id='fotofa3'  class='anim' >"); adaptImg('../images/hotel3.jpg',560,210,'photo');document.write("</div>");
	document.write("<div id='fotofa2'  class='anim' >"); adaptImg('../images/hotel2.jpg',560,210,'photo');document.write("</div>");
	document.write("<div id='fotofa1'  class='anim' >"); adaptImg('../images/hotel1.jpg',560,210,'photo');document.write("</div>");
	initAnimfade();

 */


// default values
var slowdtfa = 3000;
var fastdtfa = 10;
var nrfotos = 6; 
var opacff  = 1.0;
var opacie = 100*opacff;
var dopac = .05; 
var timerfa = null;
var fotoObjsxx = new Array();
var fotoctr = 1;


function showfotos()
{
	clearTimeout(timerfa);
	for ( var i = 1; i <= nrfotos; i++)
	{
		fotoObjsxx[i].style.visibility = "visible";
		if (document.all)  {fotoObjsxx[i].filters.alpha.opacity = 100;} // ie
		if (!document.all) {fotoObjsxx[i].style.opacity= .99999;}  //  firefox 
	}
	timerfa = setTimeout("animfade()",slowdtfa); 
}

function initAnimfade()
{
	clearTimeout(timerfa);
	opacff = .99999;
	for ( var i = 1; i <= nrfotos; i++)
	{
		var animtemp = "fotofa" + i;
		if (document.getElementById)  
		{
			fotoObjsxx[i]  = document.getElementById(animtemp);
		}
		else
		{
			fotoObjsxx[i] = document[animtemp];
		}
		
		if (document.all) {fotoObjsxx[i].style.filter = "alpha(opacity=100)";}  // initialize IE
		if (!document.all) {fotoObjsxx[i].style.opacity = opacff;}  // initialize FireFox 
		// obj.style.MozOpacity = opacity/100;  older firefox
		//  obj.style.KHTMLOpacity = opacity/100;  Safari<1.2, Konqueror
  		fotoObjsxx[i].style.visibility = "visible";	
	}
}

function animfade()
{
	clearTimeout(timerfa);
	opacff = opacff - dopac;
	opacie = 100*opacff;
	if (opacff > 0.0)
	{	
		if (document.all)   {fotoObjsxx[fotoctr].filters.alpha.opacity = opacie;} // ie
		if (!document.all)  {fotoObjsxx[fotoctr].style.opacity =opacff; }  //  firefox 
		// obj.style.MozOpacity = opacity/100; 
		timerfa = setTimeout("animfade()",fastdtfa);
	}
	else
	{
		fotoObjsxx[fotoctr].style.visibility = "hidden";
		opacff = .99999;
		opacie = 100;
		if (fotoctr < nrfotos)
		{
			// change photo
			fotoctr =  fotoctr + 1;
			// if ( fotoctr ==6) {pagenr(2);}     // show coresspondng text
			// if ( fotoctr ==11) {pagenr(3);}  // show  coresspondng text
			timerfa = setTimeout("animfade()",slowdtfa);
		}
		else
		{
			// start over
			fotoctr = 1;
			// pagenr(1);   //  show coresspondng text
			timerfa = setTimeout("showfotos()",slowdtfa);
		}
	}
}

function startAnimfa()
{
		clearTimeout(timerfa);
		opacff  = 1.0;
		opacie = 100;
		fotoctr = 1;
		// pagenr(1);  // insert coresspondng text
		timerfa = setTimeout("animfade()",slowdtfa); 
}