function imgSlide(onTimeout) {
	$(parEl + ' img').eq(imgNum).addClass('loading').removeClass('inactive').animate({'left':0}, 1000, 'easeInOutSine', function() {
		$(this).addClass('active').removeClass('loading').removeAttr('style');
		$(this).siblings('img').addClass('inactive').removeClass('active');
		imgNum++;
		if (imgNum >= totalImages) { imgNum=0; }
		if (onTimeout) {
			imgSlideTimeout=setTimeout("imgSlide(true)", imgSlideDelay);
		}
	});
}
function showText(imgEl) {
	$('.imageViewer .loading').stop(true, false).animate({'left':'608px'}, 1200, function() {
		$(this).addClass('inactive').removeClass('loading');
	});
	var index = imgEl.index();
	var txtTest = $(imgEl).siblings('.imageText').children('p').eq(index).text();
	if (txtTest.length > 5) {
		$(imgEl).siblings('.imageText').children('p').eq(index).stop().animate({'bottom':0}, 800);
	}
}
function hideText() {
	$('.imageViewer p').stop().animate({'bottom':'-120px'}, 1200);
	clearTimeout(imgSlideTimeout);
	if (!clickFlag) {
		imgSlideTimeout=setTimeout("imgSlide(true)", imgSlideDelay);
	}
}
$('.imageViewer img').mouseenter(function() {
	if (!$(this).hasClass('loading')) {
		clearTimeout(imgSlideTimeout);
		var imgEl = $(this);
		showText(imgEl);
	}
});
$('.imageViewer').mouseleave(function(){ hideText(); });
$('.imageViewer a.slider').click(function() {
	clickFlag = true;
	hideText();
	imgSlide(false);
	return false;
});
/* init variables and slide */
var clickFlag = false;
var imgSlideDelay = 6000;
var parEl = '.imageViewer';
var imgNum = 1;
var totalImages = $(parEl + ' img').length;
var imgSlideTimeout;
$(window).load(function() { 
	var imgCount = $('.imageViewer img').length;
	if (imgCount > 1) {
		if (oldIE) {
			$('a.slider').show();		
		} else {
			$('a.slider').fadeIn();
		}
		imgSlideTimeout=setTimeout("imgSlide(true)", 3600);
	} 
});
