var startDelay 	= 5000;

/*time it takes to fade*/
var timeFade	= 500;
/*time image stays active before fading*/
var timeActive	= 5000;

var activeImg	= 0;
var imageCount	= 6;
var timerStart;
var transition 	= 'off';

$(document).ready(function() {
	$('#rotate_nav').css({'visibility':'visible'});

	timerStart = setTimeout('imageRotator(1)', startDelay);
});

	var photoGallery	= new Object();


/***** GET THE FUNCTIONS STARTED *****/

	function imageRotator(id) {
		if(transition == 'off') {
			transition = 'on';
			
			clearTimeout(timerStart);

			var imageList = $('#image_rotate').find('img');
			
			if((id) == imageCount) {
				var nextStep = 0;
			} else {
				var nextStep = id;
			}
			
			var linkList 	= $('#rotate_nav').find('a');
			for(var i=0; i<linkList.length; i++) {
				$(linkList[i]).attr({'class':''});
			}
			var link = $('.image' + nextStep).find('a');
			$(link).attr({'class':'active'});

			var imageActive	= $(imageList[activeImg]);
			var imageNext	= $(imageList[nextStep]);
			
			$(imageActive).css({'zIndex':'100'});
			$(imageNext).css({'zIndex':'1'});
			
			$(imageActive).fadeOut(timeFade).add(
				$(imageNext).fadeIn(timeFade, function() {
					var nextStep2 = nextStep + 1;
					activeImg = nextStep;
					transition = 'off';
					timerStart = setTimeout('imageRotator(' + nextStep2 + ')', timeActive);
				})
			);
		}
	}

	function irisNews(id) {
		var imageList 	= $('#iris_news_thumbs').find('img');
		var linkList	= $('#news-list').find('a');
		
		for(var i=0; i<imageList.length; i++) {
			$(imageList[i]).stop();
			var parent = $(linkList[i]).parent();
			
			if(i != id) {
				$(parent).attr({'class':''});
				$(imageList[i]).animate({'opacity':'0.2'}, 300);
			} else {
				$(parent).attr({'class':'current'});
				$(imageList[i]).animate({'opacity':'0.999'}, 300);
			}
		}
	}