/* 
 ___    __    ____    __    _    _  ____  ____ 
/ __)  /__\  (  _ \  /__\  ( \/\/ )( ___)(  _ \
\__ \ /(__)\  )(_) )/(__)\  )    (  )__)  ) _ <
(___/(__)(__)(____/(__)(__)(__/\__)(____)(____/

Is This Real Life Newsticker
Developed by SADA Systems Inc.
*/

$(document).ready(function (){
	
	//Setup
	var newsItems = $("#newsticker li").length; // how many items
	var prevItem = "";

	$("#newsticker li").each(function (i) {
		$(this).attr('id', 'nt' + i); // give the slides a unique name for targeting
		$(this).css("display", "none");
		$(this).css("position", "absolute");
		$(this).css("top", "0");
	});
	
	$("#nt0").css("display", "block");
	var currItem = "nt0";
	
	//Rotation and Timing Event
	itrlSwitch = function(){
		playnews = setInterval(function(){

			currPos = parseInt(currItem.substring(2)) + 1;

			if (newsItems == (currPos)){
				prevItem = currItem;
				currItem = $("#newsticker li:first-child").attr('id');
				//alert (currItem);
			} else {
				prevItem = currItem;
				currItem = $("#" + prevItem).next().attr('id');
			}
			$("#" + prevItem).fadeOut("slow");
			$("#" + currItem).fadeIn("slow");
		}, 4000); //Timer speed in milliseconds (10 seconds)
	};
	
	itrlSwitch();
	
}); // onload
