jQuery(function() {
	$("div.tabs").children("span").click(function(event){
		var _class = $(this).attr("name");
		$(this).siblings("span.selected").attr("class", "");
		$(this).attr("class", "selected");
		$("div.featured_list:visible").fadeOut("fast", function(e){
			$("div#" + _class).fadeIn("fast");
		});
		event.preventDefault();
	});
    
	$("div.tabs").children("span#recent_comments").click(function(event){
		var _class = $(this).attr("name");
		$.post("/home/recent_comments", {}, function(value) {
			$("div#" + _class).html(value);
		});
	})
	
	$("div.tabs").children("span#new_scenarios").click(function(event){
		var _class = $(this).attr("name");
		$.post("/home/new_scenarios", {}, function(value) {
			$("div#" + _class).html(value);
		});
	})
	
	$('#spotlight .main')
	.cycle({ 
		fx:     'scrollRight', 
		speed:  'slow',
		pager:  '#spotlight .options',
		timeout: 10000,
		pause: 1,
		pagerAnchorBuilder: function(idx, slide) { 
			// return selector string for existing anchor
			return '#spotlight .options a:eq(' + idx + ')'; 
		}
	});
	
	$("div#spotlight").children("div.options").children("a").click(function(event){
		var _class = $(this).attr("href");
		$(this).siblings("a.activeSlide").attr("class", "");
		$(this).attr("class", "activeSlide");
		event.preventDefault();
	});
	
});
