/* This script and HTML code originally appeared on John Haggerty's web page
 * http://www.slimeland.com/
 * To contact, email slime@slime*NO*SPAM*land.com
 * You may NOT copy the images on this page without permission from John Haggerty.
 * You may copy the below code only if you leave this commented message at the top.*/

var IE = (document.all)?true:false;
var NN = (document.layers)?true:false;
var DOM = false;
if (!IE) DOM = (document.getElementById)?true:false;

//window.onerror = Oops; var errored = false;
function Oops(msg, url, line)
{
	if (errored) return true;
	errored = true;
	
	var errwin = window.open();
	errwin.myopener = top;
	var d = errwin.document;
	d.write('<html><head><title>JavaScript Error</title></head><body>');
	d.write("<p>Sorry, but there was an error. Chances are, your browser doesn't support something that this page needs. Internet Explorer or Netscape 6 on Windows should do the trick. (Of course, it's always possible that my page is the problem, and not your browser. In that case, I'm sorry.)</p>");
	d.write("<a href=\"http://www.webstandards.org/upgrade\">Click here</a> to upgrade your browser, if you want. It's free, and will make the Internet all that much more fun for you. What have you got to lose?");
	d.write("<p><i>The error, \"<b>" + msg + "</b>\" was at the page <b>" + url + "</b> in line <b>" + line + "</b>.</i></p>");
	d.write("</body></html>");
	return true;
}

var isloaded = false;

var loadedininterface = true; // flag for other windows to know if they're being loaded in this page or elsewhere

var topstr = "top", leftstr = "left";
visible = "visible"; hidden = "hidden";
var heightstr = "height", widthstr = "width";
if (IE)
{
	topstr = "pixelTop"; leftstr = "pixelLeft";
	visible = "visible"; hidden = "hidden";
	heightstr = "pixelHeight", widthstr = "pixelWidth";
}
else if (NN)
{
	visible = "show"; hidden="hide";
}

var maintop = 23, mainleft = 1;
var mainheight = 396, mainwidth = 638;

var dispwinstartwidth = 300;
var dispwinstartheight = 170;

var texttopmargin = 15;
var textbottommargin = 1;
var textmaxedgedist = 4;
var textmaxtopdist = texttopmargin + textmaxedgedist;
var textmaxbottomdist = textbottommargin + textmaxedgedist;
var textmaxallmargins = textmaxtopdist + textmaxbottomdist;

var scrolldistfromtop = 27;
var scrolldistfrombottom = 26;
if (NN) scrolldistfrombottom = 14;
var scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;

// it is safe to rearrange the dispwins as long as their id numbers remain the same.
var numdispwins = 4;
var dispwinhtmlfiles = new Array();
var dispwinidnums = new Array();
	dispwinhtmlfiles[0] = "about.htm";			dispwinidnums[0]=0; // idnums should never change even if the order of files changes.
	dispwinhtmlfiles[1] = "dhtml.htm";			dispwinidnums[1]=1;
	dispwinhtmlfiles[2] = "pastpages.htm";		dispwinidnums[2]=2;
	dispwinhtmlfiles[3] = "images.htm";			dispwinidnums[3]=3;
	dispwinhtmlfiles[4] = "slimelog.htm";		dispwinidnums[4]=4;
var dispwintitletext = new Array();
	dispwintitletext[0] = "About this site";
	dispwintitletext[1] = "DHTML pages by Slime";
	dispwintitletext[2] = "Past front pages";
	dispwintitletext[3] = "Images by Slime";
	dispwintitletext[4] = "The Slimelog";

var dispwin = new Array();
for (a=0; a < numdispwins; a++)
	dispwin[a] = new Object();

var activedispwin;
	
var mindispwinwidth = 130;
var minspaces = new Array();
var curminleft = mainleft+1;
var curmintop = maintop-16+mainheight;
for (a=0; a < numdispwins; a++)
{
	minspaces[a] = new Object();
	minspaces[a].inuse = false;
	minspaces[a].left = curminleft;
	minspaces[a].top = curmintop;

	curminleft += mindispwinwidth+1;
	if (curminleft > mainleft+mainwidth-mindispwinwidth)
	{
		curminleft = mainleft+1;
		curmintop -= 16;
	}
}

var mmimages = new Array();
for (a=0; a < 3; a++)
	mmimages[a] = new Image();
	mmimages[0].src = 'disprm.gif';
	mmimages[1].src = 'dispmm.gif';
	mmimages[2].src = 'dispmr.gif';

var numicons = 4;
var iconsplit = 0;
var icontimergoing = false;
var topicon = new Array();
for (a=0; a < numicons; a++)
	topicon[a] = new Object();
var icontext = new Array();
	icontext[0] = DefaultIconText(0,"about this site");
	icontext[1] = DefaultIconText(1,"DHTML pages by Slime");
	icontext[2] = DefaultIconText(2,"past front pages");
	icontext[3] = DefaultIconText(3,"images by Slime");
	icontext[4] = DefaultIconText(4,"the Slimelog");
function DefaultIconText(thenum,thetext)
{
	toreturn = '<a href="JavaScript: void(openwin(' + thenum + '));" ';
	toreturn += 'onMouseOver="window.status=\'' + thetext + '\'; return true;" ';
	toreturn += 'onMouseOut="window.status=\'\'; return true;" ';
	toreturn += 'onFocus="window.focus();"';
	
	if (!NN)
		toreturn += ' style="text-decoration:none;">';
	else
		toreturn += '>';
	
	for (a=0; a < thetext.length; a++)
		if (thetext.substr(a,1) == " ") thetext = thetext.substr(0,a) + "&nbsp;" + thetext.substring(a+1,thetext.length);
	toreturn += thetext;
	toreturn += '</a>';
	return toreturn;
}

var usedicons = false;

var TookAWhileToLoad = false;
setTimeout("TookAWhileToLoad=true;",1500);
var LoadDelay = 2000;
function DoneLoading()
{
	if (!TookAWhileToLoad)
	{
		LoadDelay = 0;
		RemoveLoadingStuff();
		return;
	}
	// setTimeout('temp()',3000);} function temp() {
	var newtext = '<span style="color:#355;">' + loadquote + '<br>- <i>Slime</i></span><br><br>';
	newtext += 'Well then, the page has finished loading.<br>';
	newtext += '<a href="JavaScript: void 0;" onClick="RemoveLoadingStuff();" onMouseOver="window.status=\'Oh, just click for heaven\\\'s sake.\'; return true;" onMouseOut="window.status=\'\';">Are you ready?</a>';
	if (IE)
		document.all.loadingtext.innerHTML = newtext;
	else if (NN)
	{
		document.loadingtext;
		document.loadingtext.document.write('<span style="font-family:\'Comic Sans MS\',Arial,sans-serif; color:#9FF; font-size:11px; text-align:center;">' + newtext + '</span>');
		document.loadingtext.document.close();
	}
	else if (DOM)
		document.getElementById("loadingtext").innerHTML = newtext;
}
function RemoveLoadingStuff() {
	if (IE)
		document.all.loadingtext.style.visibility = hidden;
	else if (DOM)
		document.getElementById("loadingtext").style.visibility = hidden;
	if (LoadDelay > 0)
		setTimeout("SetupMainStuff();",LoadDelay);
	else
		SetupMainStuff();
}
function SetupMainStuff()
{
	if (IE)
	{
		for (a=0; a < numboxes; a++)
			boxes[a].css = document.all["smlbox" + a].style;

		document.onmousemove = GetMousePos;
		document.onmousedown = Grab;
		document.onmouseup = Release;
		document.onmousewheel = WheelScroll;
		
		var da = document.all;
		for (a=0; a < numdispwins; a++)
		{
			dispwin[a].css = da["dispwin" + a].style;
			dispwin[a].wh = da["dispwin" + a].style;
			dispwin[a].winstateinfo = new Object();
			dispwin[a].bg = da["dispwinbg" + a].style;
			dispwin[a].btmline = da["dispwinbtmline" + a].style;
			dispwin[a].ur = da["dispwinur" + a].style;
			dispwin[a].mm = da["dispwinminmax" + a].style;
			dispwin[a].mmimg = da["dispwinmmimg" + a];
			dispwin[a].dr = da["dispwindr" + a].style;
			dispwin[a].r = da["dispwinrightline" + a].style;
			dispwin[a].rwh = da["dispwinrightline" + a].style;
			dispwin[a].text = da["dispwintext" + a].style;
			dispwin[a].textwh = da["dispwintext" + a].style;
			dispwin[a].textmain = da["dispwintext" + a];
			dispwin[a].titletext = da["dispwintitle" + a].style;
			dispwin[a].scroller = da["dispwinscrl" + a].style;
			dispwin[a].scrollerwh = da["dispwinscrl" + a].style;
			dispwin[a].htmlfile = dispwinhtmlfiles[a];
			dispwin[a].beenopened = false;
			dispwin[a].contentloaded = false;
		}
		
		for (a=0; a < numicons; a++)
		{
			topicon[a].css = da["icon" + a].style;
			topicon[a].wh = da["icon" + a].style;
			topicon[a].bg = da["iconbg" + a].style;
			topicon[a].text = da["icontext" + a].style;
			 topicon[a].textmain = da["icontext" + a];
		}
		
		document.all.mainbg.style.visibility = visible;
		document.all.slimecvr.style.visibility = visible;
	}
	else if (NN)
	{
		for (a=0; a < numboxes; a++)
		{
			document["smlbox" + a];
			boxes[a].css = document["smlbox" + a];
		}
		window.captureEvents(Event.MOUSEMOVE | Event.MOUSEDOWN | Event.MOUSEUP);
		window.onmousemove=GetMousePos;
		window.onmousedown=Grab;
		window.onmouseup=Release;

		for (a=0; a < numdispwins; a++)
		{
			// The following lines *should* be pointless. Blame Netscape for the necessity of their existance.
			document["dispwin" + a];
			document["dispwin" + a].document["dispwinbg" + a];
			document["dispwin" + a].document["dispwinbtmline" + a]; document["dispwin" + a].document["dispwinur" + a]; document["dispwin" + a].document["dispwindr" + a];
			document["dispwin" + a].document["dispwinrightline" + a]; document["dispwin" + a].document["dispwintext" + a]; document["dispwin" + a].document["dispwintitle" + a];
			document["dispwin" + a].document["dispwinscrl" + a];
			
			dispwin[a].css = document["dispwin" + a];
			dispwin[a].wh = document["dispwin" + a].clip;
			dispwin[a].winstateinfo = new Object();
			dispwin[a].bg = document["dispwin" + a].document["dispwinbg" + a];
			dispwin[a].btmline = document["dispwin" + a].document["dispwinbtmline" + a];
			dispwin[a].ur = document["dispwin" + a].document["dispwinur" + a];
			dispwin[a].dr = document["dispwin" + a].document["dispwindr" + a];
			dispwin[a].r = document["dispwin" + a].document["dispwinrightline" + a];
			dispwin[a].rwh = document["dispwin" + a].document["dispwinrightline" + a].clip;
			dispwin[a].text = document["dispwin" + a].document["dispwintext" + a];
			dispwin[a].textwh = document["dispwin" + a].document["dispwintext" + a].clip;
			dispwin[a].textheight;
			dispwin[a].titletext = document["dispwin" + a].document["dispwintitle" + a]; //new
			dispwin[a].scroller = document["dispwin" + a].document["dispwinscrl" + a];
			dispwin[a].scrollerwh = document["dispwin" + a].document["dispwinscrl" + a].clip;
			dispwin[a].htmlfile = dispwinhtmlfiles[a];
			dispwin[a].beenopened = false;
			dispwin[a].contentloaded = false;
		}

		for (a=0; a < numicons; a++)
		{
			document["icon" + a]; document["icon" + a].document["iconbg" + a]; document["icon" + a].document["icontext" + a];
			topicon[a].css = document["icon" + a];
			topicon[a].wh = document["icon" + a].clip;
			topicon[a].bg = document["icon" + a].document["iconbg" + a];
			topicon[a].text = document["icon" + a].document["icontext" + a];
			 topicon[a].textwh = document["icon" + a].document["icontext" + a].clip; // NN only
		}

		document.mainbg.visibility = visible;
		document.slimecvr.visibility = visible;
	}
	else if (DOM)
	{
		window.onmousemove = null;
		for (a=0; a < numboxes; a++)
			boxes[a].css = document.getElementById("smlbox" + a).style;

		document.body.onmousemove = GetMousePos;	
		document.body.onmousedown = Grab;
		document.body.onmouseup = Release;
		
		//var dg = document.getElementById;
		for (a=0; a < numdispwins; a++)
		{
			dispwin[a].css = document.getElementById("dispwin" + a).style;
			dispwin[a].wh = document.getElementById("dispwin" + a).style;
			dispwin[a].winstateinfo = new Object();
			dispwin[a].bg = document.getElementById("dispwinbg" + a).style;
			dispwin[a].btmline = document.getElementById("dispwinbtmline" + a).style;
			dispwin[a].ur = document.getElementById("dispwinur" + a).style;
			dispwin[a].mm = document.getElementById("dispwinminmax" + a).style;
			dispwin[a].mmimg = document.getElementById("dispwinmmimg" + a);
			dispwin[a].dr = document.getElementById("dispwindr" + a).style;
			dispwin[a].r = document.getElementById("dispwinrightline" + a).style;
			dispwin[a].rwh = document.getElementById("dispwinrightline" + a).style;
			dispwin[a].text = document.getElementById("dispwintext" + a).style;
			dispwin[a].textwh = document.getElementById("dispwintext" + a).style;
			dispwin[a].titletext = document.getElementById("dispwintitle" + a).style;
			dispwin[a].scroller = document.getElementById("dispwinscrl" + a).style;
			dispwin[a].scrollerwh = document.getElementById("dispwinscrl" + a).style;
			dispwin[a].textmain = document.getElementById("dispwintext" + a);
			dispwin[a].htmlfile = dispwinhtmlfiles[a];
			dispwin[a].beenopened = false;
			dispwin[a].contentloaded = false;
		}

		for (a=0; a < numicons; a++)
		{
			topicon[a].css = document.getElementById("icon" + a).style;
			topicon[a].wh = document.getElementById("icon" + a).style;
			topicon[a].bg = document.getElementById("iconbg" + a).style;
			topicon[a].text = document.getElementById("icontext" + a).style;
			topicon[a].textmain = document.getElementById("icontext" + a);
		}
		
		document.getElementById("mainbg").style.visibility = visible;
		document.getElementById("slimecvr").style.visibility = visible;
	}
	
	var cookies = document.cookie;
	if (cookies.indexOf('cyanslimeboxes=') != -1)
	{
		var startpos = cookies.indexOf('cyanslimeboxes')+15;
		var endpos = cookies.indexOf(";",startpos)-1;
		if (endpos == -2) endpos = cookies.length;
		var savedinfo = unescape(cookies.substring(startpos,endpos));
		if (savedinfo == "true") stopboxes = true;
	}
	
	for (a=0; a < numboxes; a++)
	{
		boxes[a].css[leftstr] = (10 + boxes[a].xpos*20);
		boxes[a].css[topstr] = (28 + boxes[a].ypos*20);
		if (!stopboxes)
			setTimeout("boxes[" + a + "].css.visibility = visible;",1000 + 200*a);
	}
	
	for (a=0; a < numdispwins; a++)
	{
		dispwin[a].css[leftstr] = 300;
		dispwin[a].css[topstr] = 200;
		dispwin[a].wh[widthstr] = dispwinstartwidth;
		dispwin[a].wh[heightstr] = dispwinstartheight;
		dispwin[a].css.zIndex = 1000 - a;
		dispwin[a].winstateinfo.winstate = 1;
		dispwin[a].textheightamnt = 0;
	}
	
	for (a=0; a < numicons; a++)
	{
		topicon[a].css[leftstr] = 619-20*(numicons-1-a);
		topicon[a].wh[widthstr] = 19;
		topicon[a].ptheta = 0;
		topicon[a].thetadir = 0;
		topicon[a].css.visibility = visible;
	}
	
	isloaded = true;
	if (!stopboxes)
		setTimeout("BoxStep();",4000);
	setTimeout('AttentionToTopIcons(0);',8000);
	LoadSavedWindows();
}

var mx = -1, my = -1;
var mousemanip = -1;
var mousefunc = 0;
var relmx = 0, relmy = 0;
var origwidth = 0, origheight = 0;
var scrolldir = 0;

function GetMousePos(e)
{
	if (IE)
	{
		if (event.button == 3) return true;
		mx = event.x;
		my = event.y;
	}
	else if (NN)
	{
		if (e.which == 2 || e.which == 3) return true;
		mx = e.pageX;
		my = e.pageY;
	}
	else if (DOM)
	{
		if (e.button == 3) return;
		mx = e.clientX;
		my = e.clientY;
	}
		
	if (mousemanip != -1)
	{
		if (mousefunc == 0) // move
		{
			dispwin[mousemanip].css[leftstr] = fit(mx - relmx, mainleft+1, mainleft+mainwidth-1 - parseInt(dispwin[mousemanip].wh[widthstr]));
			dispwin[mousemanip].css[topstr] = fit(my - relmy, maintop+1, maintop+mainheight-1 - parseInt(dispwin[mousemanip].wh[heightstr]));
			AlignBG(mousemanip);
		}
		else if (mousefunc == 1) // resize
		{
			var newwidth = fit(mx-relmx + origwidth, 150, mainleft+mainwidth-1 - parseInt(dispwin[mousemanip].css[leftstr]));
			var newheight = fit(my-relmy + origheight, 75, maintop+mainheight-1 - parseInt(dispwin[mousemanip].css[topstr]));

			dispwin[mousemanip].css.visibility = hidden;
			ResizeDispwin(mousemanip, newwidth, newheight, false);
			dispwin[mousemanip].css.visibility = visible;
		}
		else if (mousefunc == 2) // scroll drag
		{
			dispwin[mousemanip].scroller[topstr] = fit(my-relmy, scrolldistfromtop+1, parseInt(dispwin[mousemanip].wh[heightstr]) - parseInt(dispwin[mousemanip].scrollerwh[heightstr]) - scrolldistfrombottom);
			SetTextWithScroll(mousemanip);
		}
	}
	else if (my >= 2 && my <= 20) //test for icon touching
	{
		for (a=0; a < numicons; a++)
		{
			if (topicon[a].thetadir == 0 && mx >= parseInt(topicon[a].css[leftstr]) && mx < parseInt(topicon[a].css[leftstr]) + 19)
			{
				if (a >= iconsplit) // right half
				{
					for (b=a; b >= iconsplit; b--)
						topicon[b].thetadir = 1;
				}
				else if (a != numicons-1 && a+1 < iconsplit) // left half
				{
					for (b=a+1; b < iconsplit; b++)
						topicon[b].thetadir = -1;
				}
				iconsplit = a+1;
				if (!icontimergoing)
				{
					icontimergoing = true;
					setTimeout("MoveIcons();",50);
				}
				usedicons = true;
			}
		}
	}

	if (DOM) e.cancelBubble = true;
	if (!NN || mousemanip != -1) return false;
}
/*function MouseLeft(e) {
	mx=0; my=0;
	if (DOM) e.cancelBubble = true;
	if (!NN) return false;
}*/
function Grab (e)
{
	if (IE && (event.button == 3)) return true;
	else if (NN && (e.which == 3)) return true;
	else if (DOM && (e.button == 3)) return true;
	
	var winner = -1;
	var zindexsearch = 1000;
	var winnersoldzindex;
	for (b=0; b < numdispwins; b++)
	{
		for (a=0; a < numdispwins; a++)
		{
			if (parseInt(dispwin[a].css.zIndex) == zindexsearch && dispwin[a].css.visibility != hidden && mx >= parseInt(dispwin[a].css[leftstr]) && my >= parseInt(dispwin[a].css[topstr]) && mx < parseInt(dispwin[a].css[leftstr]) + parseInt(dispwin[a].wh[widthstr]) && my < parseInt(dispwin[a].css[topstr]) + parseInt(dispwin[a].wh[heightstr]))
			{
				relmx = mx - parseInt(dispwin[a].css[leftstr]);
				relmy = my - parseInt(dispwin[a].css[topstr]);
				winnersoldzindex = parseInt(dispwin[a].css.zIndex);
				dispwin[a].css.zIndex = 1001;
				winner = a;
				b = numdispwins;
			}
		}
		zindexsearch -= 1;
	}
	for (a=0; a < numdispwins; a++)
	{
		if (parseInt(dispwin[a].css.zIndex) >= winnersoldzindex) dispwin[a].css.zIndex = parseInt(dispwin[a].css.zIndex ) - 1;
	}
	
	if (winner != -1)
	{
		if (dispwin[winner].winstateinfo.winstate == 2)
		{
			scrolldistfrombottom = 14;
			scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;
		}
		else if (!NN)
		{
			scrolldistfrombottom = 26;
			scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;
		}
		activedispwin = winner;
		MouseHitWin(winner);
	}
	
	if (DOM) e.cancelBubble = true;
	
	if (!NN) return false;
}
function Release (e)
{
	if (IE && (event.button == 3)) return true;
	else if (NN && (e.which == 3)) return true;
	else if (DOM && (e.button == 3)) return true;

	mousemanip = -1;
	if (DOM) e.cancelBubble = true;
	if (!NN) return false;
}
function WheelScroll() // IE 6 only
{
	if (dispwin[activedispwin].winstateinfo.winstate == 0)
	{
		return;
	}
	else if (dispwin[activedispwin].winstateinfo.winstate == 2)
	{
		scrolldistfrombottom = 14;
		scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;
	}
	else if (!NN)
	{
		scrolldistfrombottom = 26;
		scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;
	}

	scrolldir = event.wheelDelta/120;
	var oldmousemanip = mousemanip;
	mousemanip = activedispwin;
	SmallScroll();
	mousemanip = oldmousemanip;
}

function MouseHitWin(which)
{
	mousemanip = which;
	if (relmx <= parseInt(dispwin[which].wh[widthstr]) - 3 && relmx >= parseInt(dispwin[which].wh[widthstr]) - 13)
	{
		if (relmy >= 2 && relmy <= 12)
		{
			// Close
			mousemanip = -1;
			closewin(which);
		}
		else if (relmy >= scrolldistfromtop-11 && relmy < scrolldistfromtop)
		{
			// small scroll up
			scrolldir = 1;
			mousefunc = -1;
			SmallScroll();
		}
		else if (relmy > parseInt(dispwin[which].wh[heightstr]) - scrolldistfrombottom && relmy <= parseInt(dispwin[which].wh[heightstr]) - (scrolldistfrombottom-11))
		{
			// small scroll down
			scrolldir = -1;
			mousefunc = -1;
			SmallScroll();
		}
		else if (relmy <= parseInt(dispwin[which].wh[heightstr]) - 3 && relmy >= parseInt(dispwin[which].wh[heightstr]) - 13 && !NN)
		{
			// Resize, must be after small scroll down so that maximized dispwins can be scrolled down.
			// NN not supported
			relmx = mx;
			relmy = my;
			origwidth = parseInt(dispwin[which].wh[widthstr]);
			origheight = parseInt(dispwin[which].wh[heightstr]);
			mousefunc = 1;
		}
		else if (relmy <= parseInt(dispwin[which].wh[heightstr]) - scrolldistfrombottom && relmy >= scrolldistfromtop)
		{
			// Scroll
			if (relmy < parseInt(dispwin[which].scroller[topstr]) || relmy > parseInt(dispwin[which].scroller[topstr]) + parseInt(dispwin[which].scrollerwh[heightstr]))
			{
				// big scroll
				mousefunc = -1;
				relmy = parseInt(dispwin[which].css[topstr]);
				BigScroll();
				return;
			}
			//relmx will not be used.
			relmy = my - (parseInt(dispwin[which].scroller[topstr]));
			mousefunc = 2; // scroll drag
		}
		else
		{
			// Drag
			mousefunc = 0;
		}
	}
	else if (relmy >= 2 && relmy <= 12 && !NN)
	{
		// Maximize, Minimize, and Restore
		if (relmx <= parseInt(dispwin[which].wh[widthstr]) - 15 && relmx >= parseInt(dispwin[which].wh[widthstr]) - 25)
		{
			if (dispwin[which].winstateinfo.winstate != 2)
			{
				dispwin[which].css.visibility = hidden;
				MaximizeDispWin(which);
				dispwin[which].css.visibility = visible;
			}
			else
			{
				scrolldistfrombottom = 26;
				scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;

				dispwin[which].css.visibility = hidden;
				dispwin[which].winstateinfo.winstate = 1;
				ResizeDispwin(which, dispwin[which].winstateinfo.width, dispwin[which].winstateinfo.height, false);
				dispwin[which].css[leftstr] = dispwin[which].winstateinfo.left;
				dispwin[which].css[topstr] = dispwin[which].winstateinfo.top;
				dispwin[which].mmimg.src = mmimages[1].src;
				AlignBG(which);
				dispwin[which].css.visibility = visible;
			}
			mousefunc = -1;
		}
		else if (relmx <= parseInt(dispwin[which].wh[widthstr]) - 27 && relmx >= parseInt(dispwin[which].wh[widthstr]) - 37)
		{
			if (dispwin[which].winstateinfo.winstate != 0)
			{
				dispwin[which].css.visibility = hidden;
				MinimizeDispWin(which);
				dispwin[which].css.visibility = visible;
			}
			else
			{
				UnminimizeDispwin(which);
			}
			mousefunc = -1;
		}
		else
		{
			// Drag
			mousefunc = 0;
		}
	}
	else
	{
		// Drag
		mousefunc = 0;
	}
	
	if (dispwin[which].winstateinfo.winstate != 1 && (mousefunc == 0 || mousefunc == 1))
		mousefunc = -1;
}

function MinimizeDispWin(which)
{
	if (dispwin[which].winstateinfo.winstate == 1)
	{
		dispwin[which].winstateinfo.left = parseInt(dispwin[which].css[leftstr]);
		dispwin[which].winstateinfo.top = parseInt(dispwin[which].css[topstr]);
		dispwin[which].winstateinfo.width = parseInt(dispwin[which].wh[widthstr]);
		dispwin[which].winstateinfo.height = parseInt(dispwin[which].wh[heightstr]);
	}

	scrolldistfrombottom = 26;
	scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;

	ResizeDispwin(which, mindispwinwidth, 15, true);
		
	for (a=0; a < numdispwins; a++)
	{
		if (!minspaces[a].inuse)
		{
			dispwin[which].css[leftstr] = minspaces[a].left;
			dispwin[which].css[topstr] = minspaces[a].top;
			dispwin[which].winstateinfo.minspace = a;
			minspaces[a].inuse = true;
			break;
		}
	}
	
	dispwin[which].winstateinfo.winstate = 0;
	dispwin[which].mmimg.src = mmimages[0].src;
	AlignBG(which);
}
function MaximizeDispWin(which)
{
	if (dispwin[which].winstateinfo.winstate == 1)
	{
		dispwin[which].winstateinfo.left = parseInt(dispwin[which].css[leftstr]);
		dispwin[which].winstateinfo.top = parseInt(dispwin[which].css[topstr]);
		dispwin[which].winstateinfo.width = parseInt(dispwin[which].wh[widthstr]);
		dispwin[which].winstateinfo.height = parseInt(dispwin[which].wh[heightstr]);
	}
	dispwin[which].css[leftstr] = mainleft+1;
	dispwin[which].css[topstr] = maintop+1;
	
	scrolldistfrombottom = 14;
	scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;

	ResizeDispwin(which, mainwidth-2, mainheight-2, false);
	
	if (dispwin[which].winstateinfo.winstate == 0)
		minspaces[dispwin[which].winstateinfo.minspace].inuse = false;
	
	dispwin[which].winstateinfo.winstate = 2;
	dispwin[which].mmimg.src = mmimages[2].src;
	AlignBG(which);
}

function MoveIcons()
{
	var thetachange = Math.PI/20;
	var allareok = true;
	for (a=0; a < numicons; a++)
	{
		if (topicon[a].thetadir != 0)
		{
			topicon[a].ptheta += topicon[a].thetadir*thetachange;
			if (topicon[a].ptheta <= 0)
				topicon[a].ptheta = 0;
			else if (topicon[a].ptheta >= Math.PI)
				topicon[a].ptheta = Math.PI;
			else
				allareok = false;
			if (topicon[a].ptheta == 0 || topicon[a].ptheta == Math.PI)
				topicon[a].thetadir = 0;

			topicon[a].css[leftstr] = Math.round((2 + a*20) + ((Math.cos(topicon[a].ptheta)+1)/2)*((619 - (numicons-1-a)*20) - (2 + a*20)));
			var newwidth = 637 - (numicons-1)*20 - (parseInt(topicon[a].css[leftstr]) - (2+a*20));

			topicon[a].wh[widthstr] = newwidth;
			topicon[a].css.clip = "rect(0," + newwidth + ",19,0)";
			
			// use this only with centered text:
			/*topicon[a].text[leftstr] = 2 - parseInt(topicon[a].css[leftstr]);
			topicon[a].text.clip = "rect(0,638,15," + (19-parseInt(topicon[a].text[leftstr])) + ")";*/

			topicon[a].bg[leftstr] = 2-parseInt(topicon[a].css[leftstr]);
		}
	}
	if (!allareok)
		setTimeout("MoveIcons();",50);
	else
		icontimergoing = false;
}
function AttentionToTopIcons(iconnum)
{
	if (!usedicons)
	{
		topicon[iconnum].thetadir = 1;
		if (!icontimergoing)
		{
			icontimergoing = true;
			MoveIcons();
		}
		iconsplit = iconnum+1;
		if (iconnum + 1 < numicons)
			setTimeout('AttentionToTopIcons(' + (iconnum+1) + ');', 140);
	}
}

function UnminimizeDispwin(which)
{
	dispwin[which].css.visibility = hidden;
	dispwin[which].winstateinfo.winstate = 1;
	minspaces[dispwin[which].winstateinfo.minspace].inuse = false;
	dispwin[which].css[leftstr] = dispwin[which].winstateinfo.left;
	dispwin[which].css[topstr] = dispwin[which].winstateinfo.top;
	dispwin[which].mmimg.src = mmimages[1].src;
	ResizeDispwin(which,dispwin[which].winstateinfo.width,dispwin[which].winstateinfo.height,false);
	AlignBG(which);
	dispwin[which].css.visibility = visible;
}

function ResizeDispwin(which, newwidth, newheight, minimizing)
{
	dispwin[which].css.clip = "rect(0," + newwidth + "," + newheight + ",0)";
	
	dispwin[which].wh[widthstr] = newwidth;
	dispwin[which].wh[heightstr] = newheight;
	
	dispwin[which].ur[leftstr] = newwidth - 13;

	dispwin[which].mm[leftstr] = newwidth - 37;
	
	dispwin[which].titletext.clip = 'rect(0,' + (newwidth-41) + ',13,0)';
	
	if (!minimizing)
	{
		dispwin[which].r.clip = "rect(0,13," + (newheight-scrollareaheight) + ",0)";

		dispwin[which].btmline[topstr] = newheight - 1;
		dispwin[which].dr[leftstr] = newwidth - 13;
		dispwin[which].dr[topstr] = newheight - scrolldistfrombottom + 1;
		dispwin[which].r[leftstr] = newwidth - 13;
		dispwin[which].rwh[heightstr] = newheight - scrollareaheight;
		dispwin[which].scroller[leftstr] = newwidth - 11;

		var temptextheightamnt = dispwin[which].textheightamnt;

		dispwin[which].text[topstr] = textmaxtopdist-dispwin[which].textheightamnt*parseInt(dispwin[which].textheight);
		ResetTextClipping(which);
		dispwin[which].textwh[widthstr] = newwidth - 22;
		dispwin[which].textheight = dispwin[which].textmain.offsetHeight;

		SetScrollWithText(which);

		dispwin[which].textheightamnt = temptextheightamnt;
	}
}

function ResetTextClipping(which)
{
	var ctop = texttopmargin-parseInt(dispwin[which].text[topstr]);
	var cright = parseInt(dispwin[which].wh[widthstr]);
	var cbottom = -parseInt(dispwin[which].text[topstr])+parseInt(dispwin[which].wh[heightstr])-textbottommargin;
	if (!NN)
		dispwin[which].text.clip = "rect(" + ctop + "," + cright + "," + cbottom + ",0)";
	else
	{
		dispwin[which].textwh.top = ctop;
		dispwin[which].textwh.bottom = cbottom;
	}
	dispwin[which].textheightamnt = (textmaxtopdist-parseInt(dispwin[which].text[topstr]))/dispwin[which].textheight;
}

function BigScroll()
{
	if (mousemanip == -1) return;
	if (my-relmy < parseInt(dispwin[mousemanip].scroller[topstr]))
		dispwin[mousemanip].scroller[topstr] = max(my-relmy-Math.round(parseInt(dispwin[mousemanip].scrollerwh[heightstr])/2), scrolldistfromtop+1, parseInt(dispwin[mousemanip].scroller[topstr]) - max(parseInt(dispwin[mousemanip].scrollerwh[heightstr]) - 1,1))
	else if (my-relmy > parseInt(dispwin[mousemanip].scroller[topstr]) + parseInt(dispwin[mousemanip].scrollerwh[heightstr]))
		dispwin[mousemanip].scroller[topstr] = min(my-relmy-Math.round(parseInt(dispwin[mousemanip].scrollerwh[heightstr])/2), parseInt(dispwin[mousemanip].wh[heightstr]) - parseInt(dispwin[mousemanip].scrollerwh[heightstr]) - scrolldistfrombottom, parseInt(dispwin[mousemanip].scroller[topstr]) + max(parseInt(dispwin[mousemanip].scrollerwh[heightstr]) - 1,1))
	SetTextWithScroll(mousemanip);
	SetScrollWithText(mousemanip);
	setTimeout("BigScroll();",100);
}

function SmallScroll()
{
	if (mousemanip == -1) return;

	dispwin[mousemanip].text[topstr] = fit(parseInt(dispwin[mousemanip].text[topstr]) + scrolldir*20,parseInt(dispwin[mousemanip].wh[heightstr])-textmaxbottomdist-dispwin[mousemanip].textheight,textmaxtopdist);
	ResetTextClipping(mousemanip);
	SetScrollWithText(mousemanip);
	setTimeout("SmallScroll();",100);
}

function SetScrollWithText(which)
{
	if (NN) 
	{
		dispwin[which].textheight = dispwin[which].text.document.height;
		if (dispwin[which].textheight < 20) setTimeout('SetScrollWithText(' + which + ');',300);
	}

	if (dispwin[which].textheight < parseInt(dispwin[which].wh[heightstr]) - textmaxallmargins)
		dispwin[which].text[topstr] = textmaxtopdist;
	else if (parseInt(dispwin[which].text[topstr]) + dispwin[which].textheight < parseInt(dispwin[which].wh[heightstr]) - textmaxbottomdist)
		dispwin[which].text[topstr] = parseInt(dispwin[which].wh[heightstr]) - textmaxbottomdist - dispwin[which].textheight;
	ResetTextClipping(which);
	SetScrollTopWithText(which);
	SetScrollHeightWithText(which);
}
function SetScrollTopWithText(which)
{
	var newtopamnt = fit((textmaxtopdist-parseInt(dispwin[which].text[topstr]))/(dispwin[which].textheight),0,1);
	dispwin[which].scroller[topstr] = Math.round(scrolldistfromtop+1 + newtopamnt*(parseInt(dispwin[which].wh[heightstr])-(scrollareaheight+2)));
}
function SetScrollHeightWithText(which)
{
	var newheightamnt = min((parseInt(dispwin[which].wh[heightstr]) - textmaxallmargins)/dispwin[which].textheight,1);
	var newheight = fit(newheightamnt*(parseInt(dispwin[which].wh[heightstr])-(scrollareaheight+2)),1,parseInt(dispwin[which].wh[heightstr]) - scrolldistfrombottom - parseInt(dispwin[which].scroller[topstr]));
	newheight = Math.round(newheight);
	dispwin[which].scroller.clip = "rect(0,7," + newheight + ",0)";
	dispwin[which].scrollerwh[heightstr] = newheight;
}
function SetTextWithScroll(which)
{
	if (NN) dispwin[which].textheight = dispwin[which].text.document.height;

	if (dispwin[which].textheight > parseInt(dispwin[which].wh[heightstr]) - textmaxallmargins)
	{
		var amnt = (parseInt(dispwin[which].scroller[topstr]) - (scrolldistfromtop+1))/(parseInt(dispwin[which].wh[heightstr])-(scrollareaheight+2)-parseInt(dispwin[which].scrollerwh[heightstr]));
		//alert(textmaxallmargins);
		dispwin[which].text[topstr] = textmaxtopdist - amnt*(dispwin[which].textheight - (parseInt(dispwin[which].wh[heightstr]) - textmaxallmargins));
	}
	ResetTextClipping(which);
}

function AlignBG(which)
{
	dispwin[which].bg[leftstr] = mainleft-parseInt(dispwin[which].css[leftstr]);
	dispwin[which].bg[topstr] = maintop-parseInt(dispwin[which].css[topstr]);
}

function closewin(which)
{
	dispwin[which].css.visibility = hidden;

	if (dispwin[which].winstateinfo.winstate == 0)
		minspaces[dispwin[which].winstateinfo.minspace].inuse = false;

	for (a=0; a < numdispwins; a++)
		dispwin[a].css.zIndex = parseInt(dispwin[a].css.zIndex ) + 1;
	dispwin[which].css.zIndex = 1000 - (numdispwins - 1);
	
	if (LoadDispWhich[0] == which)
	{
		LoadFailed();
	}
}
function openwin(which, keepinvisible)
{
	var thisoldzindex = parseInt(dispwin[which].css.zIndex);
	dispwin[which].css.zIndex = 1001;
	for (a=0; a < numdispwins; a++)
		if (parseInt(dispwin[a].css.zIndex) >= thisoldzindex) dispwin[a].css.zIndex -= 1;
	
	if (!keepinvisible) activedispwin = which;
	
	if (dispwin[which].winstateinfo.winstate == 0)
		UnminimizeDispwin(which);
	
	if (dispwin[which].css.visibility != visible)
	{
		if (!dispwin[which].beenopened)
		{
			dispwin[which].css[leftstr] = mainleft + Math.floor(Math.random()*(mainwidth-dispwinstartwidth));
			dispwin[which].css[topstr] = maintop + Math.floor(Math.random()*(mainheight-dispwinstartheight));
			dispwin[which].beenopened = true;
		}

		dispwin[which].text[topstr] = textmaxtopdist;

		if (!dispwin[which].contentloaded && !keepinvisible)
		{
			AddToLoadQueue(which);
		}
		else if (!keepinvisible)
			SetScrollWithText(which);

		AlignBG(which);

		if (!keepinvisible)
			dispwin[which].css.visibility = visible;
	}
}
function openwinid(idnum)
{
	for (b=0; b < numdispwins; b++)
		if (dispwinidnums[b] == idnum) openwin(b);
}

function winstatus(idnum)
{
	for (b=0; b < numdispwins; b++)
		if (dispwinidnums[b] == idnum) window.status = 'View the "' + dispwintitletext[b] + '" display window';
	return true;
}
function nostatus() {window.status = ''; return true;}

var LoadDispWhich = new Array();
var LoadIsLoaded = true;
function LoadDisp()
{
	if (LoadDispWhich.length > 0)
	{
		if (dispwin[LoadDispWhich[0]].winstateinfo.winstate == 2)
		{
			scrolldistfrombottom = 14;
			scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;
		}
		else if (!NN)
		{
			scrolldistfrombottom = 26;
			scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;
		}
		dispwin[LoadDispWhich[0]].textmain.innerHTML = parent.outsidefile.document.body.innerHTML;
		
		dispwin[LoadDispWhich[0]].textheight = dispwin[LoadDispWhich[0]].textmain.offsetHeight;
		SetScrollWithText(LoadDispWhich[0]);
		dispwin[LoadDispWhich[0]].contentloaded = true;
		for (a=0; a < LoadDispWhich.length - 1; a++)
			LoadDispWhich[a] = LoadDispWhich[a + 1];
		LoadDispWhich.length -= 1;
	}
	LoadIsLoaded = true;
	LoadDispSetup();
}
function LoadFailed()
{
	if (LoadDispWhich.length > 0)
	{
		if (dispwin[LoadDispWhich[0]].winstateinfo.winstate == 2)
		{
			scrolldistfrombottom = 14;
			scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;
		}
		else if (!NN)
		{
			scrolldistfrombottom = 26;
			scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;
		}

		dispwin[LoadDispWhich[0]].textmain.innerHTML = 'Loading failed. ( <a href="JavaScript:void(AddToLoadQueue(' + LoadDispWhich[0] + '));" onMouseOver="window.status=\'click to retry loading\'; return true;" onMouseOut="window.status=\'\'; return true;">retry</a> )';
		
		dispwin[LoadDispWhich[0]].textheight = dispwin[LoadDispWhich[0]].textmain.offsetHeight;
		SetScrollWithText(LoadDispWhich[0]);
		for (a=0; a < LoadDispWhich.length - 1; a++)
			LoadDispWhich[a] = LoadDispWhich[a + 1];
		LoadDispWhich.length -= 1;
	}
	LoadIsLoaded = true;
	LoadDispSetup();
}
function LoadDispSetup()
{
	if (LoadDispWhich.length > 0 && LoadIsLoaded)
	{
		if (dispwin[LoadDispWhich[0]].css.visibility != visible)
		{
			for (a=0; a < LoadDispWhich.length - 1; a++)
				LoadDispWhich[a] = LoadDispWhich[a + 1];
			LoadDispWhich.length -= 1;
			return;
		}
		LoadIsLoaded = false;
		dispwin[LoadDispWhich[0]].textmain.innerHTML = 'Loading content... ( <a href="JavaScript:void(LoadFailed());" onMouseOver="window.status=\'click to cancel loading\'; return true;" onMouseOut="window.status=\'\'; return true;">cancel</a> )';
		SetScrollWithText(LoadDispWhich[0]);
		if (parent.outsidefile.location != dispwin[LoadDispWhich[0]].htmlfile)	
			parent.outsidefile.location.href = dispwin[LoadDispWhich[0]].htmlfile;
		else
			LoadDisp();
	}
}
function AddToLoadQueue(which)
{
	if (NN)
	{
		dispwin[which].text.load(dispwinhtmlfiles[which],dispwinstartwidth-22);
		dispwin[which].contentloaded = true;
		dispwin[which].css.visibility = visible;
		setTimeout('SetScrollWithText(' + which + ');', 300);
		return;
	}
	dispwin[which].textmain.innerHTML = "Waiting to load content...";
	LoadDispWhich[LoadDispWhich.length] = which;
	dispwin[which].css.visibility = visible;
	SetScrollWithText(LoadDispWhich[0]);
	LoadDispSetup();
}



var boxspacesx = Math.floor(mainwidth/20);
var boxspacesy = Math.floor(mainheight/20);
var boxspacesstartleft = mainleft + Math.ceil((mainwidth-boxspacesx*20)/2);
if (boxspacesstartleft - mainleft < 5) {boxspacesx -= 1; boxspacesstartleft += 10;}
var boxspacesstarttop = maintop + Math.ceil((mainheight-boxspacesy*20)/2);
if (boxspacesstarttop - maintop < 5) {boxspacesy -= 1; boxspacesstarttop += 10;}

var numboxes = 10;
var boxpositions = new Array();
for (a=0; a < boxspacesx*boxspacesy; a++)
	boxpositions[a] = -1;
var boxes = new Array();
for (a=0; a < numboxes; a++)
	boxes[a] = new Object();
var theta;
var thetastep = 1;

var stopboxes = false;

function RestartBoxes()
{
	stopboxes = false;
	for (a=0; a < numboxes; a++)
		setTimeout("boxes[" + a + "].css.visibility = visible;",1000 + 200*a);
	setTimeout('BoxStep();',4000);
}

function BoxStep()
{
	if (stopboxes)
	{
		for (a=0; a < numboxes; a++)
			boxes[a].css.visibility = hidden;
		return;
	}
	
	var pos, xpos, ypos;
	var diroptions = new Array(), dir = 0;
	
	for (a=0; a < numboxes; a++)
	{
		dir = 0;
		diroptions.length = 0;
		
		pos = boxes[a].pos;
		xpos = boxes[a].xpos;
		ypos = boxes[a].ypos;
		
		if (ypos > 0 && boxpositions[pos - boxspacesx] == -1)
			diroptions[diroptions.length] = -boxspacesx;
		if (ypos < 18 && boxpositions[pos + boxspacesx] == -1)
			diroptions[diroptions.length] = boxspacesx;
		if (xpos > 0 && boxpositions[pos - 1] == -1)
			diroptions[diroptions.length] = -1;
		if (xpos < 30 && boxpositions[pos + 1] == -1)
			diroptions[diroptions.length] = 1;
		
		if (diroptions.length > 0)
			dir = diroptions[Math.floor(Math.random()*diroptions.length)];
			
		if (dir == -1) xpos -= 1;
		if (dir == 1) xpos += 1;
		if (dir == -boxspacesx) ypos -= 1;
		if (dir == boxspacesx) ypos += 1;
				
		boxpositions[pos] = -1;
		boxpositions[pos + dir] = a;

		boxes[a].pos = pos + dir;
		boxes[a].xpos = xpos;
		boxes[a].ypos = ypos;
		
		boxes[a].oldx = parseInt(boxes[a].css[leftstr]);
		boxes[a].oldy = parseInt(boxes[a].css[topstr]);
		boxes[a].destx = (boxspacesstartleft + xpos*20);
		boxes[a].desty = (boxspacesstarttop + ypos*20);
	}
	
	theta = 0;
	thetastep = 1;
	setTimeout("BoxSlide();",100);
}
function BoxSlide()
{
	var realtheta = Math.PI* (1 - theta/4);
	var amnt = (Math.cos(realtheta)+1)/2;

	for (a=0; a < numboxes; a++)
	{
		boxes[a].css[leftstr] = (boxes[a].destx - boxes[a].oldx) * amnt + boxes[a].oldx;
		boxes[a].css[topstr] = (boxes[a].desty - boxes[a].oldy) * amnt + boxes[a].oldy;
	}

	theta += thetastep;
	if (theta > 4)
	{
		for (a=0; a < numboxes; a++)
		{
			boxes[a].css[leftstr] = boxes[a].destx;
			boxes[a].css[topstr] = boxes[a].desty;
		}
		setTimeout("BoxStep();",1000);
	}
	else setTimeout("BoxSlide();",100);
}

function max ()
{
	var maximum = arguments[0];
	for (a=1; a < arguments.length; a++)
		if (arguments[a] > maximum) maximum = arguments[a];
	return maximum;
}
function min ()
{
	var minimum = arguments[0];
	for (a=1; a < arguments.length; a++)
		if (arguments[a] < minimum) minimum = arguments[a];
	return minimum;
}
function fit (num,min,max)
{
	if (num < min) num = min;
	if (num > max) num = max;
	return num;
}

// idnum,left,top,width,height,zindex,winstate;
function LoadSavedWindows()
{
	var cookies = document.cookie;
	if (cookies.indexOf('cyanslimewins=') != -1)
	{
		var startpos = cookies.indexOf('cyanslimewins')+14;
		var endpos = cookies.indexOf(";",startpos);
		if (endpos == -1) endpos = cookies.length;
		var savedinfo = unescape(cookies.substring(startpos,endpos));

		var allsavedwins = savedinfo.split(/;/);
		var zorder = new Array();
		var zindexes = new Array();

		// open all the windows, invisibly
		for (d=0; d < allsavedwins.length; d++)
		{
			if (allsavedwins[d] == '') continue;
			var theinfo = allsavedwins[d].split(/,/);
			//alert('now working with savedinfo # ' + d + ': ' + theinfo);
			for (c=0; c < numdispwins; c++)
			{
				if (dispwinidnums[c] == theinfo[0])
				{
					openwin(c, true);
					dispwin[c].css[leftstr] = theinfo[1];
					dispwin[c].css[topstr] = theinfo[2];
					
					if (!NN)
						ResizeDispwin(c,theinfo[3],theinfo[4],false);
					
					var savedzindex = false;
			//		alert('trying to place zindex ' + theinfo[5]);
					for (e=0; e < zorder.length; e++)
					{
			//			alert(e + ' has zindex ' + zindexes[e] + '. compared to ' + theinfo[5] + ', it is ' + (parseInt(theinfo[5]) < parseInt(zindexes[e])) + ' that it is smaller.');
						if (parseInt(theinfo[5].valueOf()) < parseInt(zindexes[e].valueOf()))
						{
			//				alert('replacing # ' + e + ', pushing everything above that up one space in the array...');
							for (f=zorder.length; f>e; f--)
							{
								zorder[f] = zorder[f-1];
								zindexes[f] = zindexes[f-1];
							}
							zorder[e] = c;
							zindexes[e] = theinfo[5];
							savedzindex = true;
							break;
						}
					}
					if (!savedzindex)
					{
			//			alert('placing it at the end of the array');
						zorder[zorder.length] = c;
						zindexes[zindexes.length] = theinfo[5];
					}

			//		for (e=0; e < zorder.length; e++)
			//			alert(zorder[e] + ' -> ' + zindexes[e]);
			//		alert('done');
					
					AlignBG(c);
					
					if (theinfo[6] == 0) MinimizeDispWin(c);
					else if (theinfo[6] == 2) MaximizeDispWin(c);
					
					if (dispwin[c].css.visibility == visible) alert(c);
					
					if (!NN)
					{
						scrolldistfrombottom = 26;
						scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;
					}
					
					break;
				}
			}
		}

		// put windows in zorder
		if (zorder.length > 0)
		{
			for (a=0; a < zorder.length; a++)
			{
				var thisoldzindex = parseInt(dispwin[zorder[a]].css.zIndex);
				dispwin[zorder[a]].css.zIndex = 1001;
				for (b=0; b < numdispwins; b++)
					if (parseInt(dispwin[b].css.zIndex) >= thisoldzindex) dispwin[b].css.zIndex = parseInt(dispwin[b].css.zIndex) - 1;
			}
			if (dispwin[zorder[zorder.length-1]].winstateinfo.winstate == 2)
			{
				scrolldistfrombottom = 14;
				scrollareaheight = scrolldistfromtop + scrolldistfrombottom - 1;
			}
			
			// load content, this will also visibilize them
			for (d=zorder.length-1; d >= 0; d--)
			{
				if (NN && d < zorder.length - 1) dispwin[zorder[d]].css.visibility = visible;
				else AddToLoadQueue(zorder[d]);
			}
			activedispwin = zorder[zorder.length-1];
		}
	}
}
function SaveWindows()
{
	if (!isloaded) return;
	var expdate = new Date();
	expdate.setTime(expdate.getTime() + 1000 * 60 * 60 * 24 * 365);
	var value='';
	for (a=0; a < numdispwins; a++)
	{
		if (dispwin[a].css.visibility == visible)
		{
			value += dispwinidnums[a] + ',';
			if (dispwin[a].winstateinfo.winstate == 1)
			{
				value += parseInt(dispwin[a].css[leftstr]) + ',' + parseInt(dispwin[a].css[topstr]) + ',';
				value += parseInt(dispwin[a].wh[widthstr]) + ',' + parseInt(dispwin[a].wh[heightstr]) + ',';
			}
			else
			{
				value += dispwin[a].winstateinfo.left + ',' + dispwin[a].winstateinfo.top + ',';
				value += dispwin[a].winstateinfo.width + ',' + dispwin[a].winstateinfo.height + ',';
			}
			value += parseInt(dispwin[a].css.zIndex) + ',' + dispwin[a].winstateinfo.winstate + ';';
		}
	}
	document.cookie = "cyanslimewins=" + escape(value) + "; expires=" + expdate.toGMTString() + "; path=/";
	document.cookie = "cyanslimeboxes=" + escape(stopboxes) + "; expires=" + expdate.toGMTString() + "; path=/";
}
