
// books.js

var currentbook = 0;
var previousIndex = 0;

var bookurl = [
	"books/pinkparty.html",
	"books/twelvedays.html",
	"books/summerwonders.html",
	"books/blowywinter.html",
	"books/wholovesfall.html",
	"books/springthings.html",
	"books/isabel.html",
	"books/bestfriend.html",
	"books/halloween.html",
	"books/makemeaprincess.html",
	"books/princessbestfriend.html",
	"books/mistersun.html"
];

$(document).ready(function() {

    $("body").css("display", "none");
	$("body").fadeIn(1000);

	$("#booknav a").click(showbook);
	$("#bookinfo").html("").load(bookurl[0]);
	$("#i0").html("<img src='images/asterisk.png'></img>");
});
 
 
function showbook() {
	var index = parseInt(this.id.substring(1));
	
	if ( index != currentbook ) {
		var prevID = "#i" + previousIndex;
		var currentID = "#i" + index;
		previousIndex = index;
		
		$(prevID).html("");
		$(currentID).html("<img src='images/asterisk.png'></img>");
	
		$("#bookinfo").html("images/activity.gif").load(bookurl[index]);
		currentbook = index;
	}
}
