// JavaScript Document
jQuery(document).ready(function() 
{	
	var totalSlide = 6;
	var totalSec = totalSlide;
	var intObj;
	var isPlaying = true;

	intObj = setInterval(countDown, 800);
	
	jQuery("#fdesclist .flist").each( function (i) 
	{
		jQuery(this).click(Off, On);
		
		jQuery("#hslide").mouseout(On);
		jQuery("#hslide").mouseover(Pause);
		
		function Off() {
			jQuery('.flist').removeClass("fon");
			jQuery(this).addClass("fon");
			jQuery('.fpic').hide();
			jQuery('#fpic'+i).fadeIn("slow");
			Pause();
		}
		function Pause() {
			//pause
			if (isPlaying == true) {
				isPlaying = false;
				clearInterval(intObj);
				totalSec = totalSlide;
			}
		}
		function On() {
			//play
			if (isPlaying == false) {
				isPlaying = true;
				intObj = setInterval(countDown, 800);
			}
		}
	});
	
	function countDown() {
		if (totalSec < 0 )  {
			totalSec = totalSlide;
		   
			var currentDiv = jQuery('#fdesclist .fon').attr('id');
			var count = currentDiv.charAt(5);
			count++;
			if  (count > totalSlide-1) {
				count = 0;
			}
			
			jQuery('.flist').removeClass("fon");
			jQuery('#flist'+count).addClass("fon");
			jQuery('.fpic').hide();
			jQuery('#fpic'+count).fadeIn("slow");
		} else {
		   totalSec--;
		}
	}
});
// End jQuery Rotate News Index Page
