$(function() {
	$("#nav li ul").hide();
	$("#nav li").hover(function() { $(this).children("ul").slideToggle("medium").clearQueue(); });
	$(".rss-date").prepend("<br />");
	//creates the carousel
	$("div.scrollable").scrollable({ disabledClass:"disabled", size:3, circular:false }).navigator();
	
	//javascript for prev/next buttons
	var prev = '<img src="http://stanford.edu/~kieftrav/images/carousel-prev.gif">';
	var next = '<img src="http://stanford.edu/~kieftrav/images/carousel-next.gif">';
	var prevbw = '<img src="http://stanford.edu/~kieftrav/images/carousel-prev-bw.gif">';
	var nextbw = '<img src="http://stanford.edu/~kieftrav/images/carousel-next-bw.gif">';
	
	//adds the prev/next buttons to the page	
	$("a.prevPage").html(prevbw);
	$("a.nextPage").html(next);
	
	//the rest of the javascript is logic for disabling buttons
	var api = $("div.scrollable").scrollable();
	var place = "";

	api.onSeek(function() {
		if (api.getIndex() == 0) { $("a.prevPage").html(prevbw); } 
		else { $("a.prevPage").html(prev); }
		if (api.getIndex() == api.getSize()-1) { place = "end"; $("a.nextPage").html(nextbw); } 
		else { $("a.nextPage").html(next); }
	});
	$("a.prevPage").live("click", function() {
		api.prev();
	});
	$("a.nextPage").live("click", function() {
		api.next();
	});
});

$(window).load(function(){
	$("#rss-3 li a").attr("rel","#overlay").overlay({
		onBeforeLoad: function() {
			//var wrap = $(".contentWrap");
			//change the following line width and height if the overlay size is different
			$(".contentWrap").empty().append('<iframe src="'+this.getTrigger().attr("href")+'" width="550px" height="480px" scrolling="auto"></iframe>');
		},
		mask: {
			color: '#333333',
			opacity: 0.9
		}
	});
});
