window.onbeforeunload = function()

{

	var a = document.getElementsByTagName("object");

	for(var i=a.length-1;i>=0;i--) $(a[i]).remove();

}

Event.observe(document,"mousedown",function(evt) {

	evt = evt||event;

	var e = Event.element(evt);

	if(e.nodeName == "IMG" && e.className == "sh")

	{

		if(e.src.indexOf("plus") != -1)

		{

			$($(e).readAttribute("ref")).show();

			e.src = "images/menus/minusnp.gif";

		}

		else if(e.src.indexOf("minus") != -1)

		{

			$($(e).readAttribute("ref")).hide();

			e.src = "images/menus/plusnp.gif";

		}

	}

});







var Bookmark = {

	Do : function()

	{

		ill.Add("bookmark",[

		["show",showid],

		["page",page]

		],"files/workers/show.php");

	},

	Server : function()

	{

		window.close();

	}

}

Define("bookmark",Bookmark.Do);

Define("bookmark server",Bookmark.Server);





var Nav = {

	selected : null,

	Over : function(evt)

	{

		if(typeof(GEvent) != "function" || typeof(GEvent.length) == "undefined") return;

		var e = GEvent(evt);

		if(e.nodeName != "DIV") e = Test.Up(e,"nodeName","DIV");		

		if(e.style.backgroundColor != "white") e.style.backgroundColor = "#dddddd";

	},

	Out : function(evt)

	{

		if(typeof(GEvent) != "function" || typeof(GEvent.length) == "undefined") return;

		var e = GEvent(evt);

		if(e.nodeName != "DIV") e = Test.Up(e,"nodeName","DIV");

		if(e.style.backgroundColor != "white") e.style.backgroundColor = "";

	},

	Click : function(evt,bp)

	{		

		if(typeof(GEvent) != "function" || typeof(GEvent.length) == "undefined") return;		

		var e = bp?bp:GEvent(evt);

		if(e.nodeName != "DIV") e = Test.Up(e,"nodeName","DIV");

		if(e == Nav.selected) return;

		if(Nav.selected) Nav.selected.style.backgroundColor = "";

		e.style.backgroundColor = "white";

		Nav.selected = e;

	}

}

function Init()

{

	var a = document.getElementById("nav").getElementsByTagName("div");

	for(i=0;i<a.length;i++)

	{

		if(a[i].className == "chapter" || a[i].className == "page")

		{

			a[i].onmouseover = Nav.Over;

			a[i].onmouseout = Nav.Out;

			a[i].onmousedown = Nav.Click;

		}

	}

	max = 0;

	var a = document.getElementsByTagName("div");

	for(i=0;i<a.length;i++)

	{

		if(a[i].className == "page") max++;

	}

}





function Prev()

{

	if(current > 1)

	{

		location.href = base+comp+"/show/"+show+"/"+(current-1);

	}

}

function Next()

{

	if(current < (max))

	{

		location.href =  base+comp+"/show/"+show+"/"+(current+1);

	}

}