/* 
* IMAGE FADING SLIDESHOW.
*
* Copyright (c) 2005-2007 COSMIX.ORG
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
* to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*   
*/

var timeout = 1200; // milliseconds. WARNING: 1200ms MINIMUM. 
var imagearray = 	new Array
 									(
										'blue.jpg'		,
 										'orange.jpg'	,
 										'red.jpg'
									);


// --------------------------------------


var count = 1;
var currentP = 0;
var nextP = 1;

function addImages(imgsrc) {
	var newimg = document.createElement("img");
	newimg.src = imgsrc;
	newimg.id = 'poster' + (count++);
	newimg.style.border = "none";
	newimg.style.position = "absolute";
	newimg.style.top = "0px";
	$('container').insertBefore(newimg,$('caching'));
	//console.log('added poster' + count + ': ' + imgsrc);
}

function rotate() {
	if (currentP > 0) {
			nextP = currentP - 1;
		} else {
			nextP = count - 1 ;
		}
		//console.log('current poster is ... ' + currentP);
		//console.log("next poster is ..." + nextP);
		//Effect.Appear('poster' + nextP, {queue: 'front'});

		if (currentP == 0) {
			Effect.Appear('poster' + nextP);
			/*$('poster' + currentP).style.display = "hidden";*/
		} else {
			$('poster' + nextP).style.display = "block";
			$('poster' + nextP).setOpacity(1.0);
			Effect.Fade('poster' + currentP);
		}
		currentP = nextP;
	}

	window.onload = function() {
		currentP = count - 1 ;
		Effect.Fade('caching');
	//	$('caching').style.display = "none";
		setInterval('rotate()',timeout);

	}
