jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle'}, speed, easing, callback);
};

jQuery.preloadImages = function(){
  for(var i = 0; i<arguments.length; i++){
    $("<img>").attr("src", arguments[i]);
  }
}

function openShadowbox(content, player, title){
    Shadowbox.open({
        content:    content,
        player:     player,
        title:      title
    });
}

$(document).ready(function($) {

	if($('#content-body').is(":visible")){
		$('#content-body').jScrollPane({
			showArrows: false,
			scrollbarWidth: 20,
			scrollbarMargin: 10,
			wheelSpeed: 10
		});
	}
	
	if($('#content-np-body').is(":visible")){
		$('#content-np-body').jScrollPane({
			showArrows: false,
			scrollbarWidth: 20,
			scrollbarMargin: 10,
			wheelSpeed: 10
		});
	}

	if($('#image-holder').is(":visible")){
		$("#image-holder").hide();
		$(this).oneTime(800, function() {
			$("#image-holder").show().animate({
				height: "230px", 
				opacity: 1
				}, 2000, function() {
					$(this).fadeIn(1000);
				});	
		});	
	}
	//$("#left").hide();
	//$("#left").fadeIn(2000);

	
	$("#pagenavi li[@id*=node-]").each(function(){
		$(this).click( function() { 
			$("#pagenavi ul[@id*=sub-]:visible").hide();
			$("#pagenavi ul[@id*=subtwo-]:visible").hide();
			$("#pagenavi li[@id*=node-] a.hover").removeClass("hover");
			$(this).children("a").addClass("hover");
			$("#sub-" + $(this).attr("id").replace("node-","")).show();
			return false;
		});
	});
	
	$("#pagenavi li[@id*=nodetwo-]").each(function(){
		$(this).click( function() { 
			$("#pagenavi ul[@id*=subtwo-]:visible").hide();
			$("#pagenavi li[@id*=nodetwo-] a.hover").removeClass("hover");
			$(this).children("a").addClass("hover");
			$("#subtwo-" + $(this).attr("id").replace("nodetwo-","")).show();
			return false;
		});
	});
	
	$('#image-rotator').innerfade({   
		speed: 4000,   
		timeout: 7000,   
		type: 'sequence',   
		containerheight: '230px'  
	});  
	
});