jQuery(document).ready(function() 
{	
	var totalSec = 5;
	var intObj;
	var isPlaying = true;

	intObj = setInterval(countDown, 800);
	
	jQuery("#javaNav .javaLinks").each( function (i) 
	{
		jQuery(this).hover(fOn, fOff);
		function fOn() {
			jQuery('.javaLinks').removeClass("active"); 
			jQuery(this).addClass("active");
			
			jQuery('.pic').hide();
			jQuery('#pic'+i).fadeIn("slow");
			
			jQuery('.intro').hide();
			jQuery('#intro'+i).fadeIn("slow");
			
			jQuery('.linkBox').hide();
			jQuery('#linkBox'+i).fadeIn("slow");
			
			//pause
			if (isPlaying == true) {
				isPlaying = false;
				clearInterval(intObj);
				totalSec = 5;
			}
		} 
		function fOff() {
			//play
			if (isPlaying == false) {
				isPlaying = true;
				intObj = setInterval(countDown, 800);
			}
		}
	});
	
	function countDown() {
		if ( totalSec < 0 )  {
			totalSec = 5;
		   
			var currentDiv = jQuery("#javaNav .active").attr('id');
			var count = currentDiv.charAt(8);
			count++;
			if  (count > 4) {
				count = 0;
			}
			
			jQuery('.javaLinks').removeClass("active");
			jQuery('#javaLink'+count).addClass("active");
			
			jQuery('.pic').hide();
			jQuery('#pic'+count).fadeIn("slow");
			
			jQuery('.intro').hide();
			jQuery('#intro'+count).fadeIn("slow");
			
			jQuery('.linkBox').hide();
			jQuery('#linkBox'+count).fadeIn("slow");
			
		} else {
		   totalSec--;
		}
	}
});
// End jQuery Rotate News Index Page