// init
function initNewsTabs() {
	// bind click listener to tabs
	$("#tab-cwn a").click(function(){
		// switch tabs
		$("#tab-cna").removeClass("active");
		$("#tab-zenit").removeClass("active");
		$("#tab-bistro").removeClass("active");
		$(this).parent().addClass("active");
		switchNewsDiv("syndicated-cwn");
	});	
	$("#tab-cna a").click(function(){
		// switch tabs
		$("#tab-cwn").removeClass("active");
		$("#tab-zenit").removeClass("active");
		$("#tab-bistro").removeClass("active");
		$(this).parent().addClass("active");
		switchNewsDiv("syndicated-cna");
	});	
	$("#tab-zenit a").click(function(){
		// switch tabs
		$("#tab-cwn").removeClass("active");
		$("#tab-cna").removeClass("active");
		$("#tab-bistro").removeClass("active");
		$(this).parent().addClass("active");
		switchNewsDiv("syndicated-zenit");
	});	
	$("#tab-bistro a").click(function(){
		// switch tabs
		$("#tab-cwn").removeClass("active");
		$("#tab-cna").removeClass("active");
		$("#tab-zenit").removeClass("active");
		$(this).parent().addClass("active");
		switchNewsDiv("syndicated-bistro");
	});	
	
	// bind click listener to tabs
	$("#tab-events a").click(function(){
		// switch tabs
		$("#tab-announcements").removeClass("active");
		$("#tab-prayer").removeClass("active");
		$(this).parent().addClass("active");
		switchEventsDiv("target-events");
	});	
	$("#tab-announcements a").click(function(){
		// switch tabs
		$("#tab-events").removeClass("active");
		$("#tab-prayer").removeClass("active");
		$(this).parent().addClass("active");
		switchEventsDiv("target-announcements");
	});	
	$("#tab-prayer a").click(function(){
		// switch tabs
		$("#tab-announcements").removeClass("active");
		$("#tab-events").removeClass("active");
		$(this).parent().addClass("active");
		switchEventsDiv("target-prayer");
	});	
}

// switch News Div
function switchNewsDiv(div) {	
	// hide all listing divs
	$("#syndicated-cwn").hide().css("left","0");
	$("#syndicated-cna").hide().css("left","0");
	$("#syndicated-zenit").hide().css("left","0");
	$("#syndicated-bistro").hide().css("left","0");
	
	// show the selected div
	$("#" + div).fadeIn();
}

// switch Events Div
function switchEventsDiv(div) {	
	// hide all listing divs
	$("#target-events").hide().css("left","0");
	$("#target-announcements").hide().css("left","0");
	$("#target-prayer").hide().css("left","0");
	
	// show the selected div
	$("#" + div).fadeIn();
}

$(document).ready(function(){
	// init
	initNewsTabs();
	
	$('li[id^="tab"] a').click(function() {
		return false;
	});
});