//<![CDATA[	
jQuery.noConflict();
(function($, window, document, undefined){
	function nextSlide(objectStr, speed){
		var $active = $(objectStr+ ' img.active');
	    var $next = $active.next();
		if($next.length == 0){
			$next = $active.parent().children('img.slide:first');
		}
   		$next.addClass('active').fadeIn(speed);
   		$active.removeClass('active').fadeOut(speed);
	}
	
	function checkImages(objectStr, iw, ih, imgSize, speed, duration){
		var s = 0;
		$(objectStr + ' img.slide').each(function(){
			if($(this).width() == iw && $(this).height() == ih){
				++s;
			}
		});
		if(s == imgSize){
			$(objectStr).children('img.slide:first').addClass('active');
			$(objectStr + ' img.loading').fadeOut(speed);
			$(objectStr + ' img.active').fadeIn(speed);
			
			setInterval(function(){nextSlide(objectStr, speed)}, duration);
		}
		else{
			setTimeout(function(){checkImages(objectStr, iw, ih, imgSize, speed, duration);}, 250);
		}
	}

	$(document).ready(function(){
		var speed = 2000;
		var duration = 5000;
		var objectStr = '#threecolumns ul li.middle div.images';
		var imgWidth = 440;
		var imgHeight = 375;
		var imgSize = $(objectStr + ' img.slide').length;
		
		checkImages(objectStr, imgWidth, imgHeight, imgSize, speed, duration);
	});
})(jQuery, window, document);
//]]>
