jQuery(function(){
	if (jQuery(document).pngFix)
		jQuery(document).pngFix(); 
	
	jQuery("#boxes div.rollover img, #boxes div.rollover span:not(.hidden)").hover(function() {
																							if (this.tagName == "IMG")
																							{
																								this.src = this.src.replace(".jpg", "RO.jpg");
																								this.src = this.src.replace(".png", "RO.png");
																								
																							}
																							else
																							{
																								this.style.filter = this.style.filter.replace(".jpg", "RO.jpg");
																								this.style.filter = this.style.filter.replace(".png", "RO.png");
																							}
																						},
																						function() {
																							if (this.tagName == "IMG")
																								this.src = this.src.replace("RO", "");
																							else
																								this.style.filter = this.style.filter.replace("RO", "");
																						});
	
	jQuery("#boxes a").bind("mouseenter",function(){
		jQuery(this).find(".roll").fadeIn(300)
	});
	
	jQuery("#boxes a .roll").bind("mouseleave",function(){
		jQuery(this).fadeOut(300)
	});
		
	
	jQuery("#wrapper #stories a").
			hover(function() {
				jQuery("#wrapper #stories .rollout").hide();
				jQuery("#wrapper #stories .rollover").show();
			}, function(){
				jQuery("#wrapper #stories .rollout").show();
				jQuery("#wrapper #stories .rollover").hide();
			});
			
	jQuery("#wrapper #stories .rollover").hide();
			

	jQuery("#story_list a").click(function(event){
		jQuery("#story_list li").removeClass("selected");
		li = jQuery(event.target).parents("li").get(0);
		jQuery(li).addClass("selected");
		jQuery("#content").html(jQuery(li).find("div.story").html());
		loadScrollBars();
	});
	
	// Automatically click a story if #story-title is in the url
	if (jQuery("body.stories") && jQuery.url.attr("anchor")) {
		jQuery("#story_list a[href=#"+jQuery.url.attr("anchor")+"]").click()

	}

	loadScrollBars();
	
	// Add wmode="opaque" to embed and objects so they are contained to the frame in Firefox windows
	 $("embed").attr("wmode", "transparent");
		
		$("object").css("position", "relative");
	// $("object").append("<param name='wmode' value='transparent'></param>");
})


jQuery(window).load(function() {
		loadScrollBars();
});

function loadScrollBars(){
	if (jQuery('.scrollbar').jScrollPane && jQuery('.scrollbar').length > 0)
		var scrollable = jQuery('.scrollbar').jScrollPane({animateTo:true, dragMaxHeight:73, dragMinHeight:73, scrollbarWidth:6, scrollbarDragWidth:6, scrollbarMargin:10});
}
