// POST JSON
$(document).ready(function(){

// FLASHEMBED
	flashembed("flash", { src: "/flashes/index.swf", wmode: 'opaque', version: [9, 0], expressInstall: "/flashes/expressinstall.swf" });
	
// ROTATION
	function changeNews() {
		var s = $("div[id^='newsrotate']").length;
		var p = 1, i = 1;
		
		$("div[id^='newsrotate']").each(function(){
			if ($(this).is(':visible')) p = i;
			i += 1;
		});
		if (p>=s) var n = 1;
		else var n = p+1;
		$('#newsrotate'+p).fadeOut("slow",function(){
			$('#newsrotate'+n).fadeIn("slow",function(){
				setTimeout(changeNews,7000);
			});
		});
	}

	function changeQuotes() {
		var s = $("div[id^='quotesrotate']").length;
		var p = 1, i = 1;
		
		$("div[id^='quotesrotate']").each(function(){
			if ($(this).is(':visible')) p = i;
			i += 1;
		});
		if (p>=s) var n = 1;
		else var n = p+1;
		$('#quotesrotate'+p).fadeOut("slow",function(){
			$('#quotesrotate'+n).fadeIn("slow",function(){
				setTimeout(changeQuotes,7000);
			});
		});
	}

	setTimeout(changeNews,8000);
	setTimeout(changeQuotes,7000);
	
// SCROLLABLE
//	$("#infinite").scrollable().circular().autoscroll({autoplay: true, autopause: true, interval: 5000, clickable: true});

// NAVIGATION
	$("#topnav ul").superfish(); 
	
});