var interval = 7000;
var timerID = 0;

function linkcolor(obj,col) {
	obj.style.backgroundColor=col;
}

function autorotate() {
	if ($(".newsflash_bg").length ==  $(".newsflash_bg:visible").length) {
		$(".newsflash_bg:visible").not(":last").fadeOut(50, function (){
			$(".newsflash_bg:visible").fadeOut("normal");
		});
	} else {
		$(".newsflash_bg:hidden:first").fadeIn("normal");
	}
}

$(document).ready(function() {
	timerID = setInterval("autorotate()", interval);

	//animation for next newsflash
	$(".newsflash_arrow_right").click(function(){
		clearInterval(timerID);
		if ($(".newsflash_bg").length ==  $(".newsflash_bg:visible").length) {
			$(".newsflash_bg:visible").not(":last").fadeOut(50, function (){
				$(".newsflash_bg:visible").fadeOut("normal");
			});
		} else {
			$(".newsflash_bg:hidden:first").fadeIn("normal");
		}
		timerID = setInterval("autorotate()", interval);
	});

	//animation for prev newsflash
	$(".newsflash_arrow_left").click(function(){
		clearInterval(timerID);
		if ($(".newsflash_bg").length ==  $(".newsflash_bg:hidden").length) {
			$(".newsflash_bg:hidden:last").fadeIn("normal", function (){
				$(".newsflash_bg:hidden").fadeIn(50);
			});
		} else {
			$(".newsflash_bg:visible:last").fadeOut("normal");
		}
		timerID = setInterval("autorotate()", interval);
	});

	//animation for upcoming courses only button
	$("#up_a1").click(function(){
		$(".event").slideUp("fast");
		$(".course:hidden").slideDown("fast");
	});

	//animation for upcoming events only button
	$("#up_a2").click(function(){
		$(".course").slideUp("fast");
		$(".event:hidden").slideDown("fast");
	});

	//animation for upcoming both button
	$("#up_a3").click(function(){
		$("div.upcoming > *:hidden").slideDown("fast");
	});

	//nav link arrow hover
	$(".nav_link").hover(function(){
		$(this).find("img").attr("style","top: 0;");
	},function(){
		$(this).find("img").attr("style","top: -50px;");
	});
});

