//Important! Nothing much will work if we don't run the Zsetup() function. :)

	onload=Zsetup;
	onresize=fixObjects;
	Zobjects = new Array(); 
	Zrefresh = 50; if (Zflag.gecko && !Zflag.IE) Zrefresh = 100;
	loaded=0; windowOpen=0;
	Zmisc = new Array(); 
ZmiscNames = new Array("Zwalking","Zozone","Zcontrols","Zinterface","ZtopHalf","ZbottomHalfWrap","ZbottomHalf",
"ZbuttonWrap");
	
// SETUP FUNCTION! ID,wrapper,top,left,height,width,zindex,visibility

function Zsetup() {
	Xpos=Zbrowse.width()*.4; Ypos=100;
	Zmisc[0] = new makeZobject("Zwalking",null,151,0,158,598,5);
	Zmisc[1] = new makeZobject("Zozone",null,0,0,149,598,30);
	Zmisc[2] = new makeZobject("Zcontrols",null,Zbrowse.height()-23,10,11,59,10,"hidden");
	Zmisc[3] = new makeZobject("Zinterface",null,100,(Zbrowse.width()-497)/2,720,497,500);
	Zmisc[4] = new makeZobject("ZtopHalf","Zinterface",0,0,9,497,2000);
	Zmisc[5] = new makeZobject("ZbottomHalfWrap","Zinterface",225,0,225,497,1000);
	Zmisc[6] = new makeZobject("ZbottomHalf","ZbottomHalfWrap",0,0,0,497,100);
	Zmisc[7] = new makeZobject("ZbuttonWrap","Zinterface",440,0,0,497,100);
	Zmisc[8] = new makeZobject("textWrapper",null,133,(Zbrowse.width()-465)/2,208,465,5000,'hidden');
	
		Zobjects[0] = new makeZobject("Zlayer1","Zwalking",0,0,158,3052,400);
		Zobjects[1] = new makeZobject("Zlayer2","Zwalking",0,0,158,3052,300);
		Zobjects[2] = new makeZobject("Zlayer3","Zwalking",0,0,158,3052,200);
		Zobjects[3] = new makeZobject("Zlayer4","Zwalking",0,0,158,3052,100);
		
scrollingText = new makeZobject('loadedText', 'textWrapper', 0,  5, 300, 455, 10000);
	Zmisc[9] = new makeZobject('sliderA', 'Zinterface', 11,  3, 46, 8, 11000,'hidden');
	Zmisc[10] = new makeZobject('sliderB', 'Zinterface', 11,  486, 46, 8, 11000,'hidden');

	Zmisc[11] = new makeZobject("leftSide",null,  0,0,  '100%',17,1);
	Zmisc[12] = new makeZobject("centerSide",null,0,17, '100%',598,2);
	Zmisc[13] = new makeZobject("rightSide",null, 0,615,'100%',17,1);

	fixObjects();
	
for (m=0; m<buttonNames.length; m++) { 
whichShown[m] = 0;
whichShould[m] = 0;
Zbuttons[m] = getZimage(buttonNames[m],'Z'+buttonNames[m],'Zinterface','ZbuttonWrap'); }

// listen for mousemovement, can't do this until onLoad...
// disable for speed testing...
if (Zflag.NS) {
	window.captureEvents(Event.MOUSEMOVE | Event.MOUSEDOWN | Event.MOUSEUP | Event.CLICK);
	window.onMouseMove = moveHandler;
	window.onMouseDown = StartE;
	window.onMouseUp = EndE;}
else if (Zflag.IE) {
	document.onmousemove=moveHandler;
	document.onmousedown=StartE;
	document.onmouseup=EndE;
	document.ondragstart=StartE;
	document.onselectstart=dontDoIt;
	//window.onblur=endInterval;
	//window.onfocus=reStartInterval;
	}
else if (Zflag.gecko && !Zflag.opera) {
	document.addEventListener("mousemove", moveHandler, true);
	document.addEventListener("mousedown", StartE, true);
	document.addEventListener("mouseup", EndE, true);
	}

//*/
initControls();
startInterval();
loaded=1;
setTimeout('checkIdleMouse()',60000);
}

	moved=1;
function checkIdleMouse() {
	/*
	which = Math.round(Math.random()*6);
	if (whichClicked == 99) openClose(which);
	*/
	}


	refreshed=0;

function startInterval() { ZrefreshID = setInterval ("Zwalking()",Zrefresh);refreshed=1; }
function endInterval() { 
clearInterval(ZrefreshID);refreshed=0;
 }

function reStartInterval(){
if (!refreshed) {
ZrefreshID = setInterval ("Zwalking()",Zrefresh);
refreshed=1;
}}

/*
thisWindow.onfocus=reStartInterval;
*/

// end SETUP FUNCTION 

dragActive = 0;
scrollDir = 0;
baseScroll=33;

function scrollUpDown(num) { scrollReady(num);baseScroll=33;scrollDir=num; }

function scrollReady(num) { 
	stopScroll();
if ((num == 1) && windowOpen) {
getZimage('upLeft','ZtopHalf','Zinterface').src = "/lost/brown/scrolling_orange/upLeft2.gif";
getZimage('upRight','ZtopHalf','Zinterface').src = "/lost/brown/scrolling_orange/upRight2.gif"; }
if ((num == -1) && windowOpen) {
getZimage('downLeft','ZbottomHalf','ZbottomHalfWrap','Zinterface').src = "/lost/brown/scrolling_orange/downLeft2.gif";
getZimage('downRight','ZbottomHalf','ZbottomHalfWrap','Zinterface').src = "/lost/brown/scrolling_orange/downRight2.gif"; }
 }
function stopScroll() {
getZimage('upLeft','ZtopHalf','Zinterface').src = "/lost/brown/scrolling_orange/upLeft1.gif";
getZimage('upRight','ZtopHalf','Zinterface').src = "/lost/brown/scrolling_orange/upRight1.gif";
getZimage('downLeft','ZbottomHalf','ZbottomHalfWrap','Zinterface').src = "/lost/brown/scrolling_orange/downLeft1.gif";
getZimage('downRight','ZbottomHalf','ZbottomHalfWrap','Zinterface').src = "/lost/brown/scrolling_orange/downRight1.gif"; 
}

function StartE() { 
if (!loaded) return false; 
if (doLandscape)controlEvent(3);else controlEvent(1);
	mDown=1;reStartInterval();return false;}
function EndE() { window.focus();mDown=0;baseScroll=0;dragActive=0;scrollDir=0;outtaScroller();stopScroll(); }
function dontDoIt() { return false; }

	dragOffset = 0;
	
function clickScroller() {
	overScroller();
	dragActive = 1;
	dragOffset = Ypos-Zmisc[9].top-Zmisc[3].top-1;
}

function overScroller() {
document.getElementById('sliderA').className = "slB";
document.getElementById('sliderB').className = "slB";
}

function outtaScroller() {
document.getElementById('sliderA').className = "slA";
document.getElementById('sliderB').className = "slA";
}

function doDragging() {
	Zmisc[9].top = Ypos-Zmisc[3].top-1-dragOffset; 
	if (Zmisc[9].top < 11) Zmisc[9].top = 11;
	if (Zmisc[9].top > (11+Zmisc[7].top-70)) Zmisc[9].top = (11+Zmisc[7].top-70);
	Zmisc[10].top = Zmisc[9].top;
	ZslideTravel= Zmisc[7].top-70
	scrollPercent = Math.abs((Zmisc[9].top-11)/ZslideTravel);
	if (scrollPercent > 1) scrollPercent=1;
	
	scrollingText.top = Math.round(scrollPercent * Ztravel);
	
	Zmisc[9].setZall(); Zmisc[10].setZall();
	scrollingText.DHTML.top = scrollingText.top;
}

	windowHeight = 9; // this var should be between 9 and 108. (var*2 for total height)
	windowOpened = 108; windowClosed = 9;
	windowHeightGoal = windowHeight;
	landscape=1;doLandscape= (Zflag.gecko && !Zflag.IE) ? 0:1;
	
function fixObjects() {
	maxWidth = 632;
	centerOffset = (Math.round((Zbrowse.width()-maxWidth) / 32)*16) ;
	if (Math.abs(windowHeight-windowHeightGoal) > 2) landscape=0; else landscape=1;
	windowOpened = Math.floor((Zbrowse.height() - 182)/2); 
	if (windowOpened <105) windowOpened=105;
	//window.status= "windowOpened="+windowOpened;
	if (windowOpened > 225) windowOpened = 225;
	if (windowOpen) windowHeightGoal = windowOpened;
	
	Zmisc[0].width = maxWidth-34;
	Zmisc[0].left = centerOffset+17;
	Zmisc[1].left = centerOffset+17;
	Zmisc[2].top = Zbrowse.height()-23;
	Zmisc[2].left = centerOffset+17;
	Zmisc[3].left = centerOffset+67;
	Zmisc[4].height = windowHeight;
	Zmisc[5].height = windowHeight;
	Zmisc[5].top = windowHeight + Zmisc[4].top;
	Zmisc[6].top = windowHeight - 225;
	
	Zmisc[7].top = Zmisc[5].top + windowHeight + 2;
	Zmisc[3].top = 346 - Zmisc[7].top;
		while (Zmisc[3].top < 132) Zmisc[3].top++;
	
	Zmisc[8].top = Zmisc[3].top +3;
	Zmisc[8].left = Zmisc[3].left + 16;
	Zmisc[8].height = (windowHeight*2)-6;
	
	Zmisc[11].left = centerOffset;
	Zmisc[12].left = centerOffset+17;
	Zmisc[13].left = centerOffset+615;
	
	//for (m=0;m<Zobjects.length;m++) Zobjects[m].setZall();
	for (m=0;m<Zmisc.length;m++) Zmisc[m].setZall();
	getTextHeight();

}

	count=0;
	countBit = Zrefresh/1000;
function Zwalking() {
	if (Xpos < Zbrowse.width()/2) motionX = 1; 
	else motionX = -1;
	/*
	count++;
countSeconds = Math.round(count*countBit*10)/10;
zeroSecs = ''; if (Math.round(count*countBit) == countSeconds) zeroSecs = '.0';
window.status='OZONE visitor for ' + countSeconds + zeroSecs + ' seconds.';
	+'top='+scrollingText.top
	+',travel='+Ztravel
	+',scroll='+scrollPercent+"%"
	+',offset='+dragOffset;
	*/
	if ((scrollDir ==0) && landscape && doLandscape) {
	for (m=0;m<=3;m++) {
	if (Ypos>Zbrowse.height()/2) {
	Zobjects[m].left = Zobjects[m].left - ((m+1)*motionX); }
	else {
	Zobjects[m].left = Zobjects[m].left - (Math.abs(m-4)*motionX); }
	if (Zobjects[m].left < -763) Zobjects[m].left = Zobjects[m].left + 763;
	if (Zobjects[m].left > 0) Zobjects[m].left = Zobjects[m].left - 763;
	
	//Zobjects[m].setZall();
	Zobjects[m].DHTML.left=Zobjects[m].left;
		}
	}
	checkButtons();
	fixObjects();
	fixWindow();
	checkScroll();
	checkOpacity();
	if (windowHeight > windowOpened-2) {
	Zmisc[8].visibility="visible";
	Zmisc[9].visibility="visible";
	Zmisc[10].visibility="visible";
		}
}

	mDown=0;
	scrollPercent=0;
function checkScroll() {
//handle scrolling parameters...
	if (mDown && (scrollDir!=0) && windowOpen && Ztravel) {
		scrollingText.top = scrollingText.top + (scrollDir*baseScroll);
		if (scrollingText.top >= 0) scrollingText.top = 0;
		if (scrollingText.top <= Ztravel) scrollingText.top = Ztravel;
		scrollingText.DHTML.top = scrollingText.top;
	}
	if ((Ztravel != 0) && !(dragActive && mDown)) {
	scrollPercent = Math.abs(scrollingText.top/Ztravel);
	if (scrollPercent > 1) scrollPercent=1;
	} 
if ((windowOpen) && !(dragActive && mDown)) {
	Zmisc[9].top = 11 + Math.round(scrollPercent * (Zmisc[7].top-70));
	Zmisc[10].top = Zmisc[9].top;
	scrollingText.top = Math.round(scrollPercent * Ztravel);
	Zmisc[9].setZall(); Zmisc[10].setZall();
	scrollingText.DHTML.top = scrollingText.top;
		}
// end scrolling parameters...
}

function checkButtons() {
//handle button mouseovers...
	for (m=0; m<Zbuttons.length; m++) { 
	if (whichShould[m] < whichShown[m]) { whichShown[m]--; 
Zbuttons[m].src = buttons[m+(whichShown[m]*Zbuttons.length)].src; }
	else if (whichShould[m] > whichShown[m]) { whichShown[m]++; 
Zbuttons[m].src = buttons[m+(whichShown[m]*Zbuttons.length)].src; }
	 }
// end mouseover code...
}

function fixWindow() {
//open/close display window...
	if (windowHeightGoal < windowHeight) windowHeight = Math.floor(windowHeight - ((windowHeight-windowHeightGoal)/1.5));
	else if (windowHeightGoal > windowHeight) windowHeight = Math.floor(windowHeight + ((windowHeightGoal-windowHeight)/1.5));
// end open/close display window...
}
	firstTime = 1;
function moveHandler(e) {
	if (!loaded) return false;
if(!firstTime) clearTimeout(fooTime);
firstTime=0; 
fooTime=setTimeout('moved=0',20000);
	Xpos = (Zflag.IE)?event.x:e.pageX;
	Ypos = (Zflag.IE)?event.y:e.pageY;
	if (dragActive && mDown) doDragging();
	}

buttonNames = new Array( "home","imageindex","playsites","worksites","interfaces","aboutozone" );

	buttons = new Array();
	whichShown = new Array();
	whichShould = new Array();
	Zbuttons = new Array();
	
	numImages = 4;
for (x=0; x<numImages; x++) { 
for (m=buttonNames.length*x; m<buttonNames.length*(x+1); m++) { 
	buttons[m] = new Image();
if (x==99) {
buttons[m].src = "/lost/brown/buttons3/" + buttonNames[m-(buttonNames.length*x)] + (x+1) + ".gif"; }
else {
buttons[m].src = "/lost/brown/buttons_orange/" + buttonNames[m-(buttonNames.length*x)] + (x+1) + ".gif"; }
}}

function goOver(num) {
outtaScroller();stopScroll();
if (num != whichClicked) whichShould[num] = numImages - 1;
}

function goOut(num) {
if (num != whichClicked) whichShould[num] = 0;
}

	whichClicked = 99;
	
function openClose(num) {
if ((whichClicked == num) && windowOpen) {
	if (scrollingText.top !=0 ) {scrollingText.top=0;scrollPercent=0;}
	else {windowOpen=0; windowHeightGoal=windowClosed;
		Zmisc[8].visibility="hidden";
		Zmisc[9].visibility="hidden";
		Zmisc[10].visibility="hidden";
		Zmisc[9].setZall();Zmisc[10].setZall(); }}
else if (whichClicked == num) { windowOpen=1; windowHeightGoal=windowOpened; }
else {
window.status = buttonNames[num];
for (m=0; m<buttonNames.length; m++) { whichShould[m] = 0; }
whichShould[num] = numImages - 3;
	whichClicked = num;
	//windowHeightGoal = windowClosed; 
Zmisc[8].visibility="hidden"; 
showWin(num);
}}

function loadPage(num,which) {
if (num > 5) {
for (m=0; m<buttonNames.length; m++) { whichShould[m] = 0; }
showWin(num,which); }
else openClose(num);
}

	waitingText = "Please wait, loading... <img src=/ourWalls/images/window/clock.gif width=7 height=7 border=0>";
	id="loadedText";nestref="textWrapper";
function showWin(num,which) {
if (Zflag.IE) {document.all[id].innerHTML = waitingText;}
else if(Zflag.gecko || Zflag.opera) {document.getElementById(id).innerHTML = waitingText;}
	if (which) url = "/lost/content/"+which+".html";
	else url = "/lost/content/"+buttonNames[num]+".html";
if (Zflag.NS) {
	lyr = (nestref)? eval('document.'+nestref+'.document.'+id) : document.layers[id];
	lyr.load(url,465);
	lyr.onLoad = getTextHeight;loadHeader(headerImg);}
else if(Zflag.IE) { document.tempText.location = url; }
else if(Zflag.gecko || Zflag.opera) { document.getElementById('tempText').src = url; }}

function showPage() {
setTimeout('showPageNow()',300); }

function showPageNow() {
windowOpen=1;
windowHeightGoal = windowOpened;
scrollingText.top=0;
if (Zflag.IE) {
document.all[id].innerHTML = "<img src=/lost/images/blank.gif width=455 height=4><br>" + document.tempText.document.body.innerHTML + "<br>";}

else if(Zflag.gecko) {
document.getElementById(id).innerHTML = "<img src=/lost/images/blank.gif width=455 height=4><br>" +  window.frames['tempText'].document.getElementById('theBody').innerHTML + "<br>";}
}

function foo() { fooBar=0; }

function goOverAll() { 
/*
setTimeout('goOver(0)',0);
*/
 }

	launchNew=0;
	
function goLink(where){
if (launchNew) {
	window.open(where,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,titlebar=yes,status=yes,scrollbars=yes,resizable=yes');
	}
else location.href = where;
}

	currOpacity = 100; 
	baseOpacity = 100; // this is the 'goal'
	
function checkOpacity() {
if (baseOpacity == currOpacity) return true;
else if (baseOpacity < currOpacity) currOpacity=currOpacity-2; 
else if (baseOpacity > currOpacity) currOpacity=currOpacity+2; 
fadeTo(currOpacity);
	}

function fadeTo(num) {
setOpacity('Zinterface',num);
setOpacity('textWrapper',num);
	}

function setOpacity(which,num) {
if(Zflag.IE)  document.getElementById(which).filters.alpha.opacity = num; 
if(Zflag.gecko)  document.getElementById(which).style.MozOpacity = num + '%';
	}

	function getTextHeight() {
if (Zflag.NS) 		{scrollingText.height=document.textWrapper.document.loadedText.document.height;}
if (Zflag.Opera) 	{scrollingText.height=document.getElementById('loadedText').style.pixelHeight;}
else if (Zflag.gecko) 	{scrollingText.height=document.getElementById('loadedText').offsetHeight;}
Ztravel = 0-(scrollingText.height-(windowHeightGoal*2));
if (Ztravel>0) Ztravel=0;
	}

function PrfFrostIE()
{/*for (a in document.links) document.links[a].onfocus=document.links[a].blur;*/}


