﻿function fadeIt(direction) {
	var imageObj = new fx.Opacity('image'+count, {duration:1000});
	var headerObj = new fx.Opacity('header'+count, {duration:1000});
	var textObj = new fx.Opacity('text'+count, {duration:1000});
	
	textObj.setOpacity(1);
	textObj.custom(1,0);	
	
	headerObj.setOpacity(1);
	headerObj.custom(1,0);	
	
	imageObj.setOpacity(1);
	imageObj.custom(1,0);	
	
	if(direction=='forwards') {
		if(count < total) {
			count=count+1;
		} else {
			count=1;
		}
	} else {
		if(count > 1) {
			count=count-1;
		} else {
			count=total;
		}
	}
	
	if(document.getElementById('text'+count).style.display!='block') {
		document.getElementById('text'+count).style.display='block';
	}
	
	if(document.getElementById('image'+count).style.display!='block') {
		document.getElementById('image'+count).style.display='block';
	}
	
	if(document.getElementById('header'+count).style.display!='block') {
		document.getElementById('header'+count).style.display='block';
	}
			
	var imageObj = new fx.Opacity('image'+count, {duration:1000});
	var headerObj = new fx.Opacity('header'+count, {duration:1000});
	var textObj = new fx.Opacity('text'+count, {duration:1000});
	
	textObj.setOpacity(0);
	textObj.custom(0,1);	
	
	headerObj.setOpacity(0);
	headerObj.custom(0,1);	
	
	imageObj.setOpacity(0);
	imageObj.custom(0,1);
	
	showCount();
	scrollTimer();
}

function hideThem() {
	document.getElementById('text1').style.display='block';
	document.getElementById('image1').style.display='block';
	document.getElementById('header1').style.display='block';
	
	for(var loopCount = 2; loopCount <= total; loopCount++) {
		var textObj = new fx.Opacity('text'+loopCount);
		textObj.setOpacity(0);
		var headerObj = new fx.Opacity('header'+loopCount);
		headerObj.setOpacity(0);
		var imageObj = new fx.Opacity('text'+loopCount);
		imageObj.setOpacity(0);
	}
}

function showCount() {
	document.getElementById('counterBox').innerHTML=count+'/'+total;
}

scrollTime = 10000;

function scrollTimer() {

	window.clearTimeout(tOut);
	tOut = setTimeout("fadeIt('forwards');",scrollTime); 
}
