jQuery.noConflict();

jQuery(document).ready(function($){
    // Do jQuery stuff using $
   $('.weather.animate div.view').each(function() {
	    var $container = $(this);
		var $views = $container.children();
		var currentView = 0, oldView = 0;
		var hiddenPosition = $container.height() + 10;
		$views.eq(currentView).css('top', 0);
		var viewCount = $views.length;
		var pause;
		var rotateInProgress = false;
		var weatherRotate = function() {
			if (!rotateInProgress) {
				rotateInProgress = true;
				pause = false;
				currentView = (oldView + 1) % viewCount;
				$views.eq(oldView).animate(
					{top: -hiddenPosition }, 'slow', function(){
						$(this).css('top', hiddenPosition);
					});
				$views.eq(currentView).animate(
					{top: 0}, 'slow', function(){
						rotateInProgress = false;
						if (!pause) {
							pause = setTimeout(weatherRotate, 5000);
						}
					});
				oldView = currentView;
			}	
		};

		if (!pause) {
			pause = setTimeout(weatherRotate, 5000);
		}
			
		$container.hover(function() {
			clearTimeout(pause);
			pause = false;
		}, function() {
			if (!pause) {
				pause = setTimeout(weatherRotate, 250);
			}
		});
	});
});

