	var currentArticle = 0;
	var maxArticle = 4;
	var inAnimation = true;
	var caption = new Array;
	var title = new Array;	
	var currentArticleElement;
	var nextArticleElement;
	var rotation;
	
	function switchTo(articleNumber,switchtype) {

		// Set everything to 100 and the next article to display
		var nextArticleElement = $("div[id='feature'][name='" + articleNumber + "']");
		currentArticleElement.css("z-index","105");
		nextArticleElement.css("z-index","104");
		
		$("img[id='featurethumb']").css('opacity', 0.35);
		$("img[id='featurethumb'][name=" + articleNumber + "]").css('opacity', 1);
		//$("img[id='featurethumb'][name=" + articleNumber + "]").css("border", "1px solid black");
		
		$(".caption .content").html(caption[articleNumber]);
		//$(".title .inside").html(title[articleNumber]);		
		
		if (switchtype == 1) {
			currentArticleElement.fadeOut("fast", function() {		
			currentArticleElement.css("z-index","100");
			currentArticleElement.show();
			currentArticleElement = nextArticleElement;
			currentArticleElement.css("z-index","105");
			});
		} else {
			currentArticleElement.hide();
			currentArticleElement.css("z-index","100");
			currentArticleElement.show();
			currentArticleElement = nextArticleElement;
			currentArticleElement.css("z-index","105");
		}
	}
	
	function doRotation() {
		// Just to make sure, clear any other timeouts
		clearTimeout(rotation);
		if (inAnimation) {
			// Do Rotation
			currentArticle++;		
			if (currentArticle > maxArticle) {currentArticle = 0;}		
			// Do the switch		
			switchTo(currentArticle,1);				
			rotation = setTimeout(function() {
				doRotation();
			}, 5000);
		}
	}
	

	$(document).ready(function() {		
		
		$("#featurerotator").mouseover(function() {
			inAnimation = false;
			clearTimeout(rotation);
		});
		
		$("#featurerotator").mouseout(function() {
			inAnimation = true;
			rotation = setTimeout(function() {					
				doRotation();
			}, 3000);
		});
		
		$("img[id='featurethumb']").mouseover(function() {
			//alert($(this).attr("name"));
			currentArticle = $(this).attr("name");
			switchTo($(this).attr("name"),2);
			
			
		});
	
		// Choosing the first feature				
		currentArticleElement = $("div[id=feature][name=" + currentArticle + "]");			
		// Start the rotation
		rotation = setTimeout(function() {					
			doRotation();
		}, 2000);
	});
