var to;
var pShow = {
	imgarr: [],
	fadeinterval: 1000,
	interval: 6000,
	load: function(id) {
		var images = $(id).getElementsByTagName('img');
		for (i=0;i<images.length;i++)
		{
			var imgobj = images[i];
			imgobj.style.position = 'absolute';
			imgobj.style.zIndex = 0;	
			pShow.imgarr.push(imgobj);
		}
		pShow.start(0);
	},
	
	start: function(i) {
		pShow.play(i, true);
	},
	
	next: function(i) {
		clearTimeout(to);
		to = null;
		to = setTimeout(function() {
			pShow.play(i+1, false);
		}, pShow.interval);
	},
	play: function(i, firstload) {
		if (i > pShow.imgarr.length-1) { 
			i = 0;
			var int = pShow.imgarr.length;
			while(int--) {
				pShow.imgarr[int].style.zIndex = 0;
			}
		}
		pShow.imgarr[i].style.zIndex = i+1;
		$('photos').style.display = 'block';
		if (pShow.imgarr.length > 0) 
		{
			if (!firstload) {
				pShow.imgarr[i].style.opacity = 0;
				var fd = tJS.fx.animate(pShow.imgarr[i], "opacity", pShow.fadeinterval, {start:0, end:100, easing:'easeOutQuad'}, pShow.next(i));
				delete fd;
			} else {
				pShow.next(i);
			}
		}
	}
}
