var ac = null;
var count = 0;
function slideRotator(size){
	if (count <= size-1){
		$(ac.get(count+1)).fadeIn(1500);
		$(ac.get(count)).fadeOut(1500);
		count++
		if (count > size-1){
			count = 0;
			$(ac.get(count)).fadeIn(1500);
		}
	}
}

function getAnnoucements(){
	jQuery.ajax({
		cache: false,
		url: "annoucements.htm",
		dataType: "html",
		success: function (data, textStatus){
			size = $(data).filter("div").size();
			if (size > 1){
				$(data).appendTo("#announcements");
				window.setInterval('slideRotator(size)', 5000);
				ac = $("#announcements").children();
				ac.each(function(i){
					if (i != 0)
					$(this).hide();
				});
			}
			else {$("#announcements").html("<div>No announcements available at this time</div>")}
		},
		error: function (XMLObj, textT, errorT){
			var msg = "<div><span style='color: #a52f2f'>ERROR:</span><br>Error retrieving data. Verify that data source is valid.</div>";
			$("#announcements").html(msg);
		}
	});
}

$().ready(function(){
	$('#tabs').length > 0 && $('#tabsContentContainer').length > 0 ? $.jQTabs("tabs", "tabsContentContainer") : "";
	$('#subTabs').length > 0 && $('#subTabsContentContainer').length > 0 ? $.jQTabs("subTabs", "subTabsContentContainer") : "";
	$('#top_tabs').length > 0 && $('#topTabsContentContainer').length > 0 ? $.jQTabs("top_tabs", "topTabsContentContainer", {ani: "fadeIn()"}) : "";
	
	//getAnnoucements();
		
	$("#imgleft, #imgright").bind("click", function(){
		if ($(this).attr("id") == "imgleft"){
			$(this).addClass("activeBrLft").removeClass("inactiveBrLft");
			$(this).next().removeClass("activeBrRt").addClass("inactiveBrRt");
		}
		if ($(this).attr("id") == "imgright"){
			$(this).addClass("activeBrRt").removeClass("inactiveBrRt");
			$(this).prev().removeClass("activeBrLft").addClass("inactiveBrLft");
		}
	})
});