                                                                                                                                                                                                                                                               
var bookanimation =
{
	/** queue with images while loading */
	image_queue: [],
 	/** id of the interval timer */
 	interval_id: null,
  	/** max. x position */
  	max_x: 0,
   	/**	scroll direction and speed */
	direction: 0,
 	/** current mouse position ({x:, y:}) */
 	current_mouse: null,
  	/** current zooming center (x-offset, null: automatic)*/
  	current_center: null,
  	/** resize scale function */
 	size_fn: function(s) { return s; },
  	/** true: scrolling is running, false: scrolling is stopped */
  	animation_running: true,
   	/** containe element (HTML element) */
 	container: null,
  	/** current container size */
  	container_size: { x: 0, y: 0 },
  	/** array with the book objects ({element: HTML element, x: current x position }) */
  	books: [],
   	/** current visible hint text (HTML element) */
   	hint_text: null,
	/** index of the book of the current visible hint text */
	hint_text_book: -1,
	/** start time of last timer call */
	start_time: null,
 	/** counter for failed timer intervals */
 	animation_fail_count: 0,
  	/** start y-offset of the middle (scroll speed interpolation) area */
	middle_area: 0,
 	/** start y-offset of the bottom (scroll only) area */
	bottom_area: 0,

  	/**
  	 * 	Clones a object.
  	 * 	@param	obj		object to be duplicated
  	 * 	@return			cloned object
  	 */
  	clone: function(obj)
	{
    	if(obj==null || typeof(obj)!='object')
        	return obj;
    	var cloned = new obj.constructor();
    	for(var key in obj)
		{
			if (key=='image')
				cloned[key] = obj[key];
        	else cloned[key] = this.clone(obj[key]);
		}
		return cloned;
	},

 	/**
 	 *	Computes the position of an html element relative to the document.
 	 * 	@param	obj		element to find position
 	 *	@return			object {x, y} with the x and y coordinate
 	 */
 	element_position: function(obj)
	{
		var left = 0;
		var top = 0;

		while (obj.offsetParent)
		{
			left += obj.offsetLeft;
			top += obj.offsetTop;
			obj = obj.offsetParent;
		}
		return { x: left, y: top };
	},

 	/**
 	 *	Computes the position of a mouse event relative to the document.
 	 * 	@param	ev		mouse event
 	 *	@return			object {x, y} with the x and y coordinate
 	 */
 	mouse_position: function(ev)
	{
		var left = 0;
		var top = 0;

		if (ev.pageX || ev.pageY)
		{
			left = ev.pageX;
			top = ev.pageY;
		}
		else if (ev.clientX || ev.clientY)
		{
			left = ev.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			top = ev.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		}
		return { x: left, y: top };
	},


 	/**
 	 *	Computes the position of a mouse event relative to the given element.
 	 * 	@param	obj		element to find mouse position in
 	 * 	@param	ev		mouse event
 	 *	@return			object {x, y} with the x and y coordinate
 	 */
	relative_position: function(obj, ev)
	{
		var self = bookanimation;
		var objpos = self.element_position(obj);
		var mousepos = self.mouse_position(ev);
		return { x: mousepos.x - objpos.x, y: mousepos.y - objpos.y };
	},

	/**
 	 *	Starts loading of a single image.
     *  The image is added to the loading queue.
	 *	@param	obj			object to add the image property to (must contain a "graphic" property with the name)
	 *	@param	basepath	base path to find the image (optional)
 	 */
	load_image: function(obj, basepath)
	{
		var self = this;
		obj.image = new Image();
		obj.image.src = "http://www.legios.de/jportal/cms/legios/media/bookani/images/" + (basepath ? basepath : "") + obj.graphic;
		self.image_queue.push(obj.image);
	},

	/**
 	 *	Starts asynchronous loading of all graphic elements.
 	 */
 	load: function()
	{
		var self = bookanimation;
		// load images
		self.load_image(booklist.background);
		self.load_image(booklist.arrow_left);
		self.load_image(booklist.arrow_right);
		// load book images
		for (var i=0; i<booklist.books.length; i++)
            self.load_image(booklist.books[i], "books/");
        self.interval_id = window.setInterval(self.check_load, 200);

	},

	/**
	 * Checks periodically if all images of the loading queue are completed.
 	 * If all images are loaded completely, the function init() is called.
	 */
 	check_load: function()
	{
		var self = bookanimation;
		for (var i=0; i<self.image_queue.length; i++)
		{
			if (!self.image_queue[i].complete)
				return;
		}
		window.clearInterval(self.interval_id);
		self.interval_id = null;
		self.init();
		return true;
	},

 	/**
 	 *	Initializes the animation.
 	 */
 	init: function()
	{
		var self = bookanimation;

		// check if canvas is supported
		if (booklist.use_canvas)
		{
			var has_canvas = false;
			try
			{
				has_canvas = !!(document.createElement("canvas").getContext("2d"));
			}
			catch(e)
			{
				has_canvas = !!(document.createElement("canvas").getContext);
			}
			booklist.use_canvas = has_canvas;
		}
		// if the browser is Firefox2, turn off canvas (canvas in FF2 is really slow)
		if (booklist.use_canvas)
		{
			var agent = new String(navigator.userAgent);
			if (agent.indexOf("Firefox/2.")>=0 && agent.indexOf("Opera 9.5")<0)
				booklist.use_canvas = false;
		}
		// get scaling function
		if (booklist.resize_type=="quadratic" || booklist.resize_type=="x2")
			self.size_fn = function(s) { return s * s; };
		else if (booklist.resize_type=="cubic" || booklist.resize_type=="x3")
			self.size_fn = function(s) { return s * s * s; };
		else if (booklist.resize_type=="x4")
			self.size_fn = function(s) { return s * s * s * s; };
		else if (booklist.resize_type=="x5")
			self.size_fn = function(s) { return s * s * s * s * s; };
		else if (booklist.resize_type=="x6")
			self.size_fn = function(s) { return s * s * s * s * s * s; };
		else if (booklist.resize_type=="x7")
			self.size_fn = function(s) { return s * s * s * s * s * s * s; };
		else if (booklist.resize_type=="logarithmic")
			self.size_fn = function(s) { return Math.log(1 + s); };
		else  self.size_fn = function(s) { return s; };
		// compute the max. book count (the max. possible width is the width of the containers' background image)
		var max_book_count = Math.ceil(booklist.background.image.width / (booklist.book_width + booklist.book_space * 2));
		// duplicate entries in booklist.books until the max. book count is reached
		var original_len = booklist.books.length;
		var i = 0;
		while (booklist.books.length<max_book_count)
		{
			booklist.books.push(self.clone(booklist.books[i]));
			if (++i>=original_len)
				i = 0;
		}
		// reset animation if already started
		if (self.interval_id)
		{
			window.clearInterval(self.interval_id);
			self.interval_id = null;
		}
  		self.books = [];
   		self.hint_text = null;
 		self.animation_fail_count = 0;
		// set the background image and the styling of the container
		var anim = $("#bookanim");
		anim.empty();
		self.container = anim.get(0);
		anim.css("background-image", "url(" + booklist.background.image.src + ")")
			.css("background-repeat", "no-repeat")
			.css("background-position", "center top")
			.css("width", "100%")
			.css("overflow", "hidden")
			.css("position", "relative")
			.height(booklist.background.image.height);
		// create the left arrow
		anim.append("<img id='arrow_left' src ='" + booklist.arrow_left.image.src + "' />");
		var arrow_left = $("#arrow_left");
		arrow_left	.css("background-image", "url(" + booklist.background.image.src + ")")
					.css("background-repeat", "no-repeat")
					.css("float", "left")
					.css("padding-left", booklist.arrow_left.offset.x + "px")
					.css("padding-top", booklist.arrow_left.offset.y + "px")
					.css("padding-bottom", (booklist.background.image.height - booklist.arrow_left.offset.y - booklist.arrow_left.image.height) + "px")
					.css("z-index", "1")
					.css("position", "relative")
					.width(booklist.arrow_left.image.width)
					.height(booklist.arrow_left.image.height);
		arrow_left.get(0).onmouseout = self.mouse_out
		// create the right arrow
		anim.append("<img id='arrow_right' src ='" + booklist.arrow_right.image.src + "' />");
		var arrow_right = $("#arrow_right");
		arrow_right	.css("background-image", "url(" + booklist.background.image.src + ")")
					.css("background-repeat", "no-repeat")
					.css("float", "right")
					.css("padding-right", booklist.arrow_right.offset.x + "px")
					.css("padding-top", booklist.arrow_right.offset.y + "px")
					.css("padding-bottom", (booklist.background.image.height - booklist.arrow_right.offset.y - booklist.arrow_right.image.height) + "px")
					.css("z-index", "1")
					.css("position", "relative")
					.width(booklist.arrow_right.image.width)
					.height(booklist.arrow_right.image.height);
		arrow_right.get(0).onmouseout = self.mouse_out
		// create the fade out areas
		if (booklist.use_blending)
		{
			self.fade_area(anim, booklist.blending_element_count, booklist.blending_element_width, true);
			self.fade_area(anim, booklist.blending_element_count, booklist.blending_element_width, false);
		}
		// create the book objects
		self.max_x = booklist.book_space;
		for (i=0; i<booklist.books.length; i++)
		{
			if (booklist.use_canvas)
				anim.append("<canvas id='book" + i + "' width='" + booklist.book_width + "' height='" + booklist.books[i].image.height + "'></canvas>");
			else anim.append("<div id='book" + i + "' />");
			var book = $("#book" + i);
			self.books.push({ element: book.get(0), x: self.max_x });
			book.css("float", "left")
				.css("position", "absolute")
				.css("z-index", "0")
				.css("left", self.max_x + "px");
			if (booklist.use_canvas)
			{
				var ctx = book.get(0).getContext("2d");
				ctx.drawImage(booklist.books[i].image, 0, 0, booklist.book_width, booklist.books[i].image.height);
			}
			else
			{
				book.width(booklist.book_width)
					.height(booklist.books[i].image.height);
				book.append("<img id='bookimg" + i + "' src='" + booklist.books[i].image.src + "' />");
				$("#bookimg" + i)	.css("padding", "0px")
									.width(booklist.book_width)
									.height(booklist.books[i].image.height);
			}
			book.get(0).onmouseout = self.mouse_out;
			book.get(0).onclick = self.mouse_click;
			self.max_x += booklist.book_width + booklist.book_space;
		}
 		self.resize_books();
		// compute action areas (y)
		self.bottom_area = self.container.offsetHeight - booklist.scroll_only_area;
		self.middle_area = self.bottom_area - booklist.scroll_interpolation_area;
		// start editor
		self.start_editor();
		// start animation
  		self.animation_running = true;
		self.direction = booklist.default_scrolling;
		anim.get(0).onmousemove = self.mouse_move;
 		anim.get(0).onmouseout = self.mouse_out;
		self.interval_id = window.setInterval(self.animate, booklist.interval_time);
		self.start_time = (new Date()).getTime();
	},

 	/**
 	 *	Stops all animations and effects.
 	 *	This function should be called at document unload to avoid memory leaks in IE.
 	 */
 	stop: function()
	{
		var self = bookanimation;
		window.clearInterval(self.interval_id);
		for (var i=0; i<self.books.length; i++)
		{
			self.books[i].element.onmouseout = null;
			self.books[i].element.onmouseover = null;
			self.books[i].element.onclick = null;
		}
		self.container.onmousemove = null;
 		self.container.onmouseout = null;
	},

 	/**
	 *	Create fade out area
 	 *	@param	container		container div (jQuery object)
 	 * 	@param	count			count of fade out elements
 	 *	@param	width			width of a single fade out element
 	 *	@param	isleft			true: left area, false: right area
 	 */
 	fade_area: function(container, count, width, isleft)
	{
		var self = bookanimation;
		if (booklist.use_canvas)
		{
			// create a single canvas object with a opacity gradient
			var w = width * count;
			var h = booklist.background.image.height;
			var name = "fade_" + (isleft ? "left" : "right") + "0";
			container.append("<canvas id='" + name + "' width='" + w + "' height='" + h + "'></canvas>");
			var element = $("#" + name).get(0);
			$(element)	.css("float", (isleft ? "left" : "right"))
						.css("position", "relative")
						.css("z-index", "1")
						.width(w)
						.height(h);
			// draw the gradient
			var surface = element.getContext("2d");
			surface.drawImage(booklist.background.image,0,0,w,h,0,0,w,h);
			surface.globalCompositeOperation = "destination-out";
			var gradient = surface.createLinearGradient(0, 0, w - 1, 0);
			var color = "rgba(" + booklist.background.color[0] + "," + booklist.background.color[1] + "," + booklist.background.color[2] + ",";
			if (isleft)
			{
				gradient.addColorStop(0,color + "0)");
				gradient.addColorStop(1,color + "1)");
			}
			else
			{
				gradient.addColorStop(0,color + "1)");
				gradient.addColorStop(1,color + "0)");
			}

			surface.fillStyle = gradient;
			surface.fillRect(0, 0, w, h);
			element.onmouseout = self.mouse_out;
		}
		else
		{
			// create multiple divs with different opacity value
			for (var x=0; x<count; x++)
			{
				var name = "fade_" + (isleft ? "left" : "right") + x;
				container.append("<div id='" + name + "' />");
				var element = $("#" + name)	;
				element	.css("background-image", "url(" + booklist.background.image.src + ")")
						.css("background-repeat", "no-repeat")
						.css("background-position", "0px 0px")
						.css("float", (isleft ? "left" : "right"))
						.css("position", "relative")
						.css("z-index", "1")
						.css("opacity", 1.0 - (x / count))
						.width(width)
						.height(booklist.background.image.height);
				element.get(0).onmouseout = self.mouse_out;
			}
		}
	},

 	/**
 	 * 	Animation main loop. This function is called by the timer periodically.
     */
 	animate: function()
	{
		var self = bookanimation;
		self.container_size.x = self.container.offsetWidth;
		self.container_size.y = self.container.offsetHeight;
		if (self.animation_running)
		{
			if ((booklist.use_canvas || booklist.use_blending) && booklist.auto_speed_factor>0)
			{
				// compute real time difference
				var now = (new Date()).getTime();
				if (Math.abs(now - self.start_time)>booklist.interval_time * booklist.auto_speed_factor)
				{
					self.animation_fail_count++;
					if (self.animation_fail_count>5)
					{
						if (booklist.use_canvas)
							booklist.use_canvas = false;
						else booklist.use_blending = false;
						self.init();
						return true;
					}
				}
				else if (self.animation_fail_count>0)
					self.animation_fail_count--;
				self.start_time = now;
			}
			// animate the books
			for (var b=0; b<self.books.length; b++)
			{
				// move book
				self.books[b].x = self.books[b].x + self.direction;
				if (self.books[b].x<-(booklist.book_width + booklist.book_space))
					self.books[b].x = self.max_x + self.books[b].x - booklist.book_space;
				else if (self.books[b].x>=self.max_x-(booklist.book_width + booklist.book_space))
					self.books[b].x -= self.max_x - booklist.book_space;
				// the element position is not written back here, beacause this is done in resize_books() anyway
			}
		}
		// resize according to the current position relative to the current center
		self.resize_books(self.current_center);
		// find current book and show label
		self.show_label();
		return true;
	},

 	/**
 	 * 	Resizes the books.
 	 *  The book sizes and displacements are computed according to the positions relative to the
 	 *  horizontal center. All visible books are redrawn.
 	 *	@param	center		horizontal center in the container (optional, center of the container if not applied)
 	 */
 	resize_books: function(center)
	{
		var self = bookanimation;
		// compute center
		var w = self.container_size.x;
		var w2 = w / 2;
		if (!center)
			var center = w2;
		var min_width = booklist.book_min_width;
		var min_height = Math.max(1, booklist.books[0].image.height - (booklist.book_width - booklist.book_min_width));
		var delta_width = booklist.book_width - min_width;
		var delta_height = booklist.books[0].image.height - min_height;
		var max_width2 = booklist.book_width / 2;

		for (var b=0; b<self.books.length; b++)
		{
			var book = self.books[b];
			// compute scale factor based on the horizontal position of the book relative to the center
			var scale = 0;
			var x = book.x + max_width2;
			if (self.current_center)
			{
				scale = 1 - Math.abs(center - x) / w2;
				if (scale<0)
					scale = 0;
				scale = self.size_fn(scale);
			}
			// interpolate scaling between center and mouse-x (mouse cursor is in middle area)
			if (!self.current_center && self.current_mouse && self.current_mouse.y>=self.middle_area && self.current_mouse.y<self.bottom_area)
			{
				var scale_m = 1 - Math.abs(self.current_mouse.x - x) / w2;
				if (scale_m<0)
					scale_m = 0;
				var factor = (self.current_mouse.y - self.middle_area) / booklist.scroll_interpolation_area;
				scale = self.size_fn(scale_m) * (1 - factor) + (scale * factor);
			}
			// compute new width and height
			var new_width = delta_width * scale + min_width;
			var new_height = delta_height * scale + min_height;
			var displacement_x = 0;
			var displacement_y = booklist.book_max_yoffset * (1 - scale);
			// is the book visible?
			if (book.x + booklist.book_width>0 && book.x<w)
			{
				// compute border size
				var border_size = booklist.book_width - new_width;
				// resize book images
				if (booklist.use_canvas)
				{
					var ctx = book.element.getContext("2d");
					book.element.width = new_width;
					book.element.height = new_height;
					displacement_x = border_size / 2;
					ctx.drawImage(booklist.books[b].image, 0, 0, new_width, new_height);
				}
				else
				{
					book.element.firstChild.style.paddingLeft = border_size / 2 + "px";
					book.element.firstChild.style.width = new_width + "px";
					book.element.firstChild.style.height = new_height + "px";
				}
				// set the books position
				self.books[b].element.style.left = (self.books[b].x + displacement_x) + "px";
				self.books[b].element.style.top = displacement_y + "px";
				if (self.books[b].element.style.display!="block")
					self.books[b].element.style.display = "block";
			}
			else self.books[b].element.style.display = "none";
		}
	},

 	/**
 	 *	Shows or hides the label of the book at the mouse cursor.
 	 */
 	show_label: function()
	{
		var self = bookanimation;
		if (self.current_mouse && self.current_mouse.y<self.bottom_area)
		{
			// find the book at the cursor
			var x = self.current_mouse.x;
			var b, book;
			for (b=0; b<self.books.length; b++)
			{
				book = self.books[b];
				if (book.x<=x && x<book.x + booklist.book_width)
					break;
			}
			if (b<self.books.length)
			{
				if (!self.hint_text || self.hint_text_book!=b)
				{
					if (self.hint_text)
						$(self.hint_text).remove();
					var left = (book.element.offsetLeft + book.element.offsetWidth / 2);
					var top = (self.container_size.y / 2);
					$(self.container).append("<div id='book_hint' style='position: absolute; z-index: 2; left: " + left + "px;" + " top: " + top + "px'>" + booklist.books[b].text + "</div>");
					self.hint_text = $("#book_hint").get(0);
					self.hint_text.onmouseout = self.mouse_out;
					self.hint_text_book = b;
				}
			}
			else if (self.hint_text)
			{
				$(self.hint_text).remove();
				self.hint_text = null;
			}
		}
		else if (self.hint_text)
		{
			// hide hint text
			$(self.hint_text).remove();
			self.hint_text = null;
		}
	},

	/**
	 *	Handles mouse movements.
	 *	@param	ev		event object
	 */
	mouse_move: function(ev)
	{
		var self = bookanimation;
		if (!ev)
			var ev = window.event;
		ev.cancelBubble = true;
		if (ev.stopPropagation)
			ev.stopPropagation();
		// compute mouse position relative to the element
		var mousepos = self.relative_position(self.container, ev);
		self.current_mouse = mousepos;
		if (mousepos.y<self.middle_area)
		{
			// mouse in top area: no scrolling, mouse-based zooming
			self.current_center = mousepos.x;
			self.animation_running = false;
		}
		else
		{
			// mouse in middle or bottom area: scrolling
			self.animation_running = true;
			self.current_center = null;
			var w = self.container_size.x / 2;
			// mouse in middle area: scrolling (y-interpolated speed), mouse-center zooming (y-interpolated)
			if (mousepos.y<self.bottom_area)
				self.direction = Math.round((w - mousepos.x) * booklist.max_scrolling / w * (mousepos.y - self.middle_area) / booklist.scroll_interpolation_area);
			// mouse in middle or bottom area: scrolling, center-based zooming
			else self.direction = Math.round((w - mousepos.x) * booklist.max_scrolling / w);
		}
		return true;
	},

	/**
	 *	Handles mouse-out event.
 	 * 	The animation speed is set to the default speed if the container is left.
 	 *  The hint text element is removed.
	 *	@param	ev		event object
	 */
	mouse_out: function(ev)
	{
		var self = bookanimation;
		if (!ev)
			var ev = window.event;
		ev.cancelBubble = true;
		if (ev.stopPropagation)
			ev.stopPropagation();
		// get the mouse position
		var pos = self.relative_position(self.container, ev);
		// is the mouse inside the container?
		if (pos.x<0 || pos.y<0 || pos.x>=self.container_size.x || pos.y>=self.container_size.y)
		{
			self.direction = (self.direction<0 ? -booklist.default_scrolling : booklist.default_scrolling);
			self.animation_running = true;
			self.current_mouse = null;
			self.current_center = null;
			// is a hint text visible?
			if (self.hint_text!=null)
			{
				// yes, remove the hint text
				$(self.hint_text).remove();
				self.hint_text = null;
			}
		}
		return true;
	},

 	/**
 	 *	Handles mouse-click event.
 	 *  This event is called for the books. The window location is set.
	 *	@param	ev		event object
	 */
  	mouse_click: function(ev)
	{
		var self = bookanimation;
		var b = parseInt(this.id.substr(4));
		bookanimation.stop();
		window.location.href = booklist.books[b].href;
		return true;
	},

 	/**
 	 *	Starts the editor.
 	 */
 	start_editor: function()
	{
		var self = bookanimation;
		if ($("#editor").length>0)
		{
			$("#space").val(booklist.book_space);
			$("#maxwidth").val(booklist.book_width);
			$("#minwidth").val(booklist.book_min_width);
			$("#maxyoffset").val(booklist.book_max_yoffset);
			if (booklist.use_canvas)
				$("#usecanvas").attr("checked", "checked");
			else $("#usecanvas").removeAttr("checked");
			if (booklist.use_blending)
				$("#blending").attr("checked", "checked");
			else $("#blending").removeAttr("checked");
			$("#autofactor").val(booklist.auto_speed_factor);
			$("#interval").val(booklist.interval_time);
			$("#defscrolling").val(booklist.default_scrolling);
			$("#maxscrolling").val(booklist.max_scrolling);
			$("#scrollonly").val(booklist.scroll_only_area);
			$("#scrollinter").val(booklist.scroll_interpolation_area);
			$("#zoomonly").val(self.container.offsetHeight - (booklist.scroll_only_area + booklist.scroll_interpolation_area));
			$("#blendingcount").val(booklist.blending_element_count);
			$("#blendingwidth").val(booklist.blending_element_width);
			$("#x2").removeAttr("checked");
			$("#x3").removeAttr("checked");
			$("#x4").removeAttr("checked");
			$("#x5").removeAttr("checked");
			$("#x6").removeAttr("checked");
			$("#x7").removeAttr("checked");
			$("#log").removeAttr("checked");
			$("#linear").removeAttr("checked");
			if (booklist.resize_type=="quadratic" || booklist.resize_type=="x2")
				$("#x2").attr("checked", "checked");
			else if (booklist.resize_type=="cubic" || booklist.resize_type=="x3")
				$("#x3").attr("checked", "checked");
			else if (booklist.resize_type=="x4")
				$("#x4").attr("checked", "checked");
			else if (booklist.resize_type=="x5")
				$("#x5").attr("checked", "checked");
			else if (booklist.resize_type=="x6")
				$("#x6").attr("checked", "checked");
			else if (booklist.resize_type=="x7")
				$("#x7").attr("checked", "checked");
			else if (booklist.resize_type=="logarithmic")
				$("#log").attr("checked", "checked");
			else $("#linear").attr("checked", "checked");
			$("#ok").click(self.apply_editor);

			$("#appname").val(navigator.appName);
			$("#version").val(navigator.appVersion);
			$("#codename").val(navigator.userAgent);
		}
	},

 	/**
 	 * 	Applies all editor values and restarts the animation.
 	 *	This function is called if the "Apply" button is pressed
 	 */
 	apply_editor: function()
	{
		var self = bookanimation;
		booklist.book_space = parseInt($("#space").val());
		booklist.book_min_width = parseInt($("#minwidth").val());
		booklist.book_max_yoffset = parseInt($("#maxyoffset").val());
		booklist.use_canvas = ($("#usecanvas").attr("checked") ? true : false);
		booklist.use_blending = ($("#blending").attr("checked") ? true : false);
		booklist.auto_speed_factor = parseInt($("#autofactor").val());
		booklist.interval_time = parseInt($("#interval").val());
		booklist.default_scrolling = parseInt($("#defscrolling").val());
		booklist.max_scrolling = parseInt($("#maxscrolling").val());
		booklist.scroll_only_area = parseInt($("#scrollonly").val());
		booklist.scroll_interpolation_area = parseInt($("#scrollinter").val());
		booklist.blending_element_count = parseInt($("#blendingcount").val());
		booklist.blending_element_width = parseInt($("#blendingwidth").val());
		if ($("#x2").attr("checked"))
			booklist.resize_type = "quadratic";
		else if ($("#x3").attr("checked"))
			booklist.resize_type = "cubic";
		else if ($("#x4").attr("checked"))
			booklist.resize_type = "x4";
		else if ($("#x5").attr("checked"))
			booklist.resize_type = "x5";
		else if ($("#x6").attr("checked"))
			booklist.resize_type = "x6";
		else if ($("#x7").attr("checked"))
			booklist.resize_type = "x7";
		else if ($("#log").attr("checked"))
			booklist.resize_type = "logarithmic";
		else booklist.resize_type = "linear";
		self.init();
	}
};

// start book loading loading
$(document).ready(bookanimation.load);
document.onunload = bookanimation.stop;

