var MAX_DIARY_SNIPPET_LENGTH=175


bridgeName=new Array("CRN4","PCM9R","WLNK8","DPP5","PCOM87",
	"TB891","TB883","CRN5R","CRN6","NYX3","NYX5","NYX8",
	"NATL3","NECOR5","NECOR6","WLNK92","WLNK94","WLNK4A")
var TBRIDGE=bridgeName[randomInt(0,bridgeName.length-1)]




contentDivTextObj=new Object()
	
contentDivTextObj.About="<B><FONT CLASS=\"layeredContentFontBold\">about the avocado papers</FONT></B><BR><BR>The Avocado Papers is proof that the art of sticking your tongue into a light socket is alive and well.  You'll come for the free linguine, but you'll stay because it really doesn't get any better than this.  It really doesn't.  Unless you have a car.  If you have a car, that changes everything.<br/><br/>Copyright &copy; 1996-2009 Steve Schneider unless otherwise noted. All rights reserved.<BR><BR><div ALIGN=\"right\"><BR></div>"


var s=""
s+="<FORM METHOD=\"get\" ACTION=\"javascript:void(0)\" onSubmit=\"submitComments(this.elements['comments'].value,this.elements['addr'].value,(this.elements['spammable'].checked?'yes':'no')); return false; \"><FONT CLASS=\"scrollerFont\"><B><FONT CLASS=\"layeredContentFontBold\">contact</FONT></B><BR><BR></FONT><FONT SIZE=3><TEXTAREA name=comments "+(browserIsIE?"CLASS=\"contactUsTextareaField\"":"")+" ROWS=3 COLS=28 WRAP=virtual  onBlur=\"playLaughIfEnabled()\" onFocus=\"playLaughIfEnabled()\">your comments go here.</TEXTAREA></FONT><BR><IMG SRC=\"images/spacer.gif\" BORDER=0 WIDTH=1 HEIGHT=6 ><BR><INPUT "+(browserIsIE?"CLASS=\"contactUsTextField\"":"")+"   name=addr TYPE=text VALUE=\"your e-mail address goes here.\"  SIZE=23 onBlur=\"playLaughIfEnabled()\" onFocus=\"playLaughIfEnabled()\">"
if (!browserIsIE)
{
	// Why is this necessary?  Ask Netscape.  Maybe they know.  I don't.
	s+="<BR><IMG SRC=\"images/spacer.gif\" BORDER=0 WIDTH=1 HEIGHT=6><BR>"
}
else
{
	s+="<BR>"
}
s+="<FONT CLASS=\"scrollerFont\">"
s+="<INPUT TYPE=\"checkbox\" NAME=\"spammable\" id=\"spammable\" VALUE=\"yes\"><label for=spammable>Check this if you want infrequent mail from this site.</label><br>"
s+="<IMG SRC=\"images/spacer.gif\" BORDER=0 WIDTH=1 HEIGHT=8><BR>"
s+="Please click \"submit\" to send your comments.<BR></FONT><IMG SRC=\"images/spacer.gif\" BORDER=0 WIDTH=1 HEIGHT=8><BR><INPUT TYPE=\"image\" SRC=\"images/scroller_submit.gif\" WIDTH=47 HEIGHT=20 BORDER=0></FORM>"
contentDivTextObj.Contact=s






var s=""
s+="<B><FONT CLASS=\"layeredContentFontBold\">avocado chat</FONT></B><BR><BR>Hello, 'erichards'. The following users are currently online.  Please choose one to chat with from the list below:<BR><BR><FORM METHOD=\"get\" ACTION=\"javascript:void(0)\"><IMG SRC=\"images/spacer.gif\" BORDER=0 WIDTH=8 HEIGHT=1 >"

s+="<table border=0 cellspacing=0 cellpadding=2><tr><td><SELECT NAME=\"chatters\" id=\"chatters\">"
s+="<OPTION VALUE=\"\">..."
for (var i=0; i<shortUserNames.length; i++)
{
	if (Math.random()<.5)
	{
		s+="<OPTION VALUE=\""+shortUserNames[i]+"\">"+shortUserNames[i]
	}
}
s+="</SELECT><br/></td>"
s+="<td><input type=button value=\"chat\" onclick=\"openChat(document.getElementById('chatters').options[document.getElementById('chatters').selectedIndex].value)\" style=\"font-size:12px;border:1px solid #999999; height:20px; width:45px;\" /><br/>"
s+="</td></tr></table>"

s+="</FORM>"
contentDivTextObj.Chat=s

var s=""
s+="<B><FONT CLASS=\"layeredContentFontBold\">screen saver</FONT></B><BR><BR><IMG SRC=\"images/screen_thumb.gif\" BORDER=0 ALIGN=right WIDTH=100 HEIGHT=71>How to install it:<BR><BR>"
s+="1) Make sure you're running Windows 98 or higher. There's no Mac version.<BR><BR>"
s+="2) Right-click on <A HREF=\"../screensaver/avocado.scr\" onClick=\"return false\" onMouseOver=\"playLaughIfEnabled()\" onClick=\"playLaughIfEnabled()\"><FONT CLASS=\"layeredContentLinkFont\">this link</FONT></A>, then choose \"Save Target As\" or \"Save Link As.\" (Right-click, not left-click.)<BR><BR>"
s+="3) Save the file to your Windows directory (usually c:\\windows or c:\\winnt).  The file is about 430K.<BR><BR>"
s+="4) Click the Windows \"Start\" button, then choose \"Settings\" and then \"Control Panel.\"<BR><BR>"
s+="5) In the control-panel window, double-click \"Display.\"<BR><BR>"
s+="6) In the \"Display Properties\" dialog box, click the \"Screen Saver\" tab, then choose \"avocado\" from the \"Screen Saver\" menu; then click \"OK.\""
contentDivTextObj.Saver=s





contentDivTextObj.ContactWait="<B><FONT CLASS=\"layeredContentFontBold\">contact</FONT></B><BR><BR>Sending your comments.  Please wait..."

contentDivTextObj.ContactThanks="<B><FONT CLASS=\"layeredContentFontBold\">contact</FONT></B><BR><BR>Your comments have been sent. Thanks for your time."

contentDivTextObj.ContactError="<B><FONT CLASS=\"layeredContentFontBold\">contact</FONT></B><BR><BR>There was a problem. Your comments have not been sent. Please try again later. Thanks.</FONT>"

contentDivTextObj.LaughTrackOnOff="<B><FONT CLASS=\"layeredContentFontBold\">enable/disable laugh track</FONT></B><BR><BR>Enable laugh track?<div style='margin:10px 0px 0px 10px;'><a href='#' onclick='switchLaughTrack(true); hideLayeredHPContent(); return false' style='color:#990000;'>enable</a> | <a href='#' onclick='switchLaughTrack(false); hideLayeredHPContent(); return false' style='color:#990000;'>disable</a></div>"

contentDivTextObj.Copyright="<B><FONT CLASS=\"layeredContentFontBold\">&copy;</FONT></B><BR><BR>Copyright &copy; 1996-2008 Steve Schneider unless otherwise noted. All rights reserved."



function showLayeredHPContent(id)
{
	var textHtml=window.contentDivTextObj[id]
	var s="<img src=v2/images/hpContentTop.gif width=293 height=19 border=0 usemap=#closeLayeredContentMap><BR>"
		+"<table width=292 border=0 cellspacing=0 cellpadding=0>"
		+"<tr>"
		+"<td nowrap width=1 bgcolor=#000000><img src=images/spacer.gif width=1 height=4><BR>"
		+"<td nowrap width=10 bgcolor=#CFD05F><img src=images/spacer.gif width=1 height=1><BR>"
		+"<td nowrap width=271 bgcolor=#CFD05F><img src=images/spacer.gif width=1 height=1><BR>"
		+"<td nowrap width=10 bgcolor=#CFD05F><img src=images/spacer.gif width=1 height=1><BR>"
		+"<td nowrap width=1 bgcolor=#000000><img src=images/spacer.gif width=1 height=1><BR>"
		+"</tr>"

		+"<tr>"
		+"<td bgcolor=#000000><img src=images/spacer.gif width=1 height=1><BR>"
		+"<td bgcolor=#CFD05F><img src=images/spacer.gif width=1 height=1><BR>"
		+"<td bgcolor=#CFD05F><font class=layeredContentFont>"+textHtml+"<BR><BR></font>"
		+"<td bgcolor=#CFD05F><img src=images/spacer.gif width=1 height=1><BR>"
		+"<td bgcolor=#000000><img src=images/spacer.gif width=1 height=1><BR>"
		+"</tr>"

		+"<tr>"
		+"<td bgcolor=#000000><img src=images/spacer.gif width=1 height=1><BR>"
		+"<td bgcolor=#000000><img src=images/spacer.gif width=1 height=1><BR>"
		+"<td bgcolor=#000000><img src=images/spacer.gif width=1 height=1><BR>"
		+"<td bgcolor=#000000><img src=images/spacer.gif width=1 height=1><BR>"
		+"<td bgcolor=#000000><img src=images/spacer.gif width=1 height=1><BR>"
		+"</tr>"
		
		+"</table>"
	
	
	writeToDiv("layeredContent",s)
	setDivStyle("layeredContent","visibility","visible")
}


function hideLayeredHPContent()
{
	setDivStyle("layeredContent","visibility","hidden")
}

function getDiaryPreviewText()
{
	// take most recent entry and chop off all but 1ast MAX_DIARY_SNIPPET_LENGTH chars, but work back from 150 chars to a space char:
	var s=diaryEntryContent // diaryEntryContent is the most recent diary entry, included by diary/yyyy/mm/dd.js.

	s=s.substring(0,MAX_DIARY_SNIPPET_LENGTH)

	if (s.length>=MAX_DIARY_SNIPPET_LENGTH)
	{
		//find a space char:
		while (s.charAt(s.length-1)!=" ")
		{
			s=s.substring(0,s.length-1)
		}
		// then strip it (them):
		while (s.charAt(s.length-1)==" ")
		{
			s=s.substring(0,s.length-1)
		}
	}
	return s
}







// BEGIN DIARY-LAUNCH CODE

function openDiary()
{
	var s=""
	s+="toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,"
	s+="resizable=0,width=365,height=500"
	openWin("diaryWin","diary","diary/diary.html?/"+lastEntry.year+"/"+lastEntry.month+"/"+lastEntry.date,s)
}

// END DIARY-LAUNCH CODE

// START CHAT-LAUNCH CODE


function openChat(arg_userName)
{
	if (arg_userName=="")
	{
		alert("Please choose a user to chat with and press the \"chat\" button again.")
		return
	}
	var s=""
	var thisDate=new Date()
	var winInstance="chatWinObj"+thisDate.getTime()
	s+="toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,"
	s+="resizable=0,width=306,height=402"
	window.open("chat/chat.html?"+arg_userName,"_blank",s)

}


// END CHAT-LAUNCH CODE

// BEGIN ARCHIVES-LAUNCH CODE

function openArchives()
{

	var s=""
	s+="toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,"
	s+="resizable=0,width=470,height=640"
	openWin("archivesWin","archives","content/archives/v2/archives.html",s)
}

// END ARCHIVES-LAUNCH CODE






function openBatteryDoor()
{
	setDivStyle("batteryDoorOpenDiv","visibility","visible")
	setDivStyle("batteryDoorClosedDiv","visibility","hidden")
	setDivStyle("batteryAdDiv","visibility","hidden")
}

function closeBatteryDoor()
{
	setDivStyle("batteryDoorOpenDiv","visibility","hidden")
	setDivStyle("batteryDoorClosedDiv","visibility","visible")
	setDivStyle("batteryAdDiv","visibility","visible")
}

function autoLaunchChat()
{
	// disabled:
	if (false) {
		if (!window.autoChatAccepted)
		{
			if (generalConfirm("User 'acorn55' has requested to chat with you. Do you wish to chat with this user?"))
			{
				var zigExecuteTime=doZig() // doZig() returns its latest timeout
				setTimeout("openChat(\"acorn55\")",zigExecuteTime+200)
				window.autoChatAccepted=true
			}
			else
			{
				doZig()
			}
		}
		else
		{
			setTimeout("autoLaunchChat()",1000*60*9)
		}
	}
}


function doZig()
{
	showOrHideTitle("hidden")
	setDivStyle("zig0","visibility","visible")
	//for (var i=1; i<=32; i*=2)
	for (var i=2; i<=32; i*=4)
	{
		setDivStyle("zig"+i,"visibility","visible")	
	}
	
	var zigInterval=50
	var currTimeout=zigInterval
	//for (var i=32; i>=1; i/=2)
	for (var i=32; i>=2; i/=4)
	{
		setTimeout("setDivStyle(\"zig"+i+"\",\"visibility\",\"hidden\")",currTimeout)
		currTimeout+=zigInterval
	}
	setTimeout("showOrHideTitle(\"visible\")",currTimeout)
	setTimeout("setDivStyle(\"zig0\",\"visibility\",\"hidden\")",currTimeout+zigInterval)
	return currTimeout
}

function showOrHideTitle(visibleOrHidden)
{
	var suffixes=["THE","AVOCADO","PAPERS"]
	for (var i=0; i<suffixes.length; i++)
	{
		setDivStyle("hpTitleText"+suffixes[i],"visibility",visibleOrHidden)
	}
}



// START CONTACT-US CODE


function submitComments(comments,addr,spammable)
{

	showLayeredHPContent("ContactWait")
	// Show "sorry, there was a problem" notice in 45 seconds, if commentsReceived() is never called by submit_comments_success.html:
	contactErrorTimeout=setTimeout("showLayeredHPContent('ContactError')",1000*45)
	var s=""
	/*
	s+="<BODY onLoad=\"document.forms[0].submit()\">"
	s+="<FORM METHOD=\"get\" ACTION=\"../comments/processv2.php\">"
	s+="<INPUT TYPE=hidden NAME=\"browser\" VALUE=\""+navigator.appName+" "+navigator.appVersion+"\">"
	// following two fields are textareas in case user inputs double quotes (or lf's in the first):
	s+="<TEXTAREA NAME=\"comments\">"+comments+"</TEXTAREA>"
	s+="<TEXTAREA NAME=\"email\">"+addr+"</TEXTAREA>"
	s+="<INPUT TYPE=hidden NAME=\"spammable\" VALUE=\""+spammable+"\">"
	s+="<INPUT TYPE=submit>"
	s+="</FORM>"
	s+="</BODY>"
	*/
	s+="http://"+location.host+"/comments/processv2.php?comments="+escape(comments)+"&browser="+escape(navigator.appName+" "+navigator.appVersion)+"&email="+escape(addr)+"&spammable="+escape(spammable)+""
	//prompt("",s)
	
	/*
	top.frames["hidden1"].document.open()
	top.frames["hidden1"].document.write(s)
	top.frames["hidden1"].document.close()
	*/
	top.frames["hidden1"].location.href=s

}

function commentsReceived()
{
	clearTimeout(contactErrorTimeout)
	setTimeout("showLayeredHPContent('ContactThanks')",1000)
	// "reset" hidden1 frame in case server only responded after 45 secs:
	top.frames.hidden1.document.open()
	top.frames.hidden1.document.write("")
	top.frames.hidden1.document.close()
}

function commentsNotReceived(arg_errMsg)
{
	setTimeout("showLayeredHPContent('ContactError')",1000)
	setTimeout("window.status='SMTP error: "+arg_errMsg+"'; window.defaultStatus='SMTP error: "+arg_errMsg+"'",1000)
	setTimeout("window.status=''; window.defaultStatus=''",10000)

}


// END CONTACT-US CODE



// BEGIN SPLOTCH CODE


var SPLOTCH_MIN_TOP=-150
var SPLOTCH_MAX_TOP=1100
var SPLOTCH_MIN_LEFT=-150
var SPLOTCH_MAX_LEFT=1100
var SPLOTCH_NUM_SPLOTCHES=60
var SPLOTCH_INTERVAL_MS=1000*60*0.5
var SPLOTCH_DELAY_BEFORE_START_MS=1000*60*5
var SPLOTCH_HEIGHT=300
var SPLOTCH_WIDTH=300

var xEdge=Math.round(SPLOTCH_WIDTH/2)
var yEdge=Math.round(SPLOTCH_HEIGHT/2)

var liveAreaWidth=SPLOTCH_MAX_LEFT-SPLOTCH_MIN_LEFT
var liveAreaHeight=SPLOTCH_MAX_TOP-SPLOTCH_MIN_TOP

var currSplotchIdx=0
var splotchInterval=null
var startTimeout=null
var docLoaded=false
var resetInProgress=false

function getEl(elName) {
	if (document.getElementById) {
		return document.getElementById(elName)
	}
	if (document.all) {
		if (typeof document.all[elName]=="undefined") {
			return null
		}
		else {
			return document.all[elName]
		}
	}
	return null
}


function initSplotches() {
	docLoaded=true
	if (splotchInterval!=null) {
		clearInterval(splotchInterval)
	}
	if (startTimeout!=null) {
		clearTimeout(startTimeout)
	}
	startTimeout=setTimeout("startSplotches()", SPLOTCH_DELAY_BEFORE_START_MS)
}

function startSplotches() {
	currSplotchIdx=0
	if (window.setInterval) {
		for (var i=0; i<finalSelectIdx; i++) {
			var els=document.forms["mainForm"].elements
			els["select"+i].style.visibility="hidden"
		}
		splotchInterval=setInterval(newSplotch, SPLOTCH_INTERVAL_MS)
	}
}

function newSplotch() {
	if (docLoaded) {
		var el=getEl("splotch"+currSplotchIdx)
		if (el!=null) {
			var elTop=randomInt(liveAreaHeight)+SPLOTCH_MIN_TOP
			var elLeft=randomInt(liveAreaWidth)+SPLOTCH_MIN_LEFT
			
			elTop-=yEdge
			elLeft-=xEdge
			if (elTop<SPLOTCH_MIN_TOP) {
				elTop=SPLOTCH_MIN_TOP
			}
			else if (elTop+yEdge*2>SPLOTCH_MAX_TOP) {
				elTop=SPLOTCH_MAX_TOP-yEdge*2
			}
			if (elLeft<SPLOTCH_MIN_LEFT) {
				elLeft=SPLOTCH_MIN_LEFT
			}
			else if (elLeft+xEdge*2>SPLOTCH_MAX_LEFT) {
				elLeft=SPLOTCH_MAX_LEFT-xEdge*2
			}
			el.style.top=""+(elTop)+"px"
			el.style.left=""+(elLeft)+"px"
			currSplotchIdx++
			if (currSplotchIdx>=SPLOTCH_NUM_SPLOTCHES-1) {
				//currSplotchIdx=0
				if (splotchInterval!=null) {
					clearInterval(splotchInterval)
				}
			}
		}
	}
}

function clearSplotches() {
	if (splotchInterval!=null) {
		clearInterval(splotchInterval)
	}
	for (var i=0; i<SPLOTCH_NUM_SPLOTCHES; i++) {
		var el=getEl("splotch"+i)
		el.style.top="-400px"
		el.style.left="-400px"
	}
	var els=document.forms["mainForm"].elements
	for (var i=0; i<finalSelectIdx; i++) {
		els["select"+i].style.visibility="visible"
	}
}



function resetSplotches() {
	if (docLoaded && !resetInProgress) {
		resetInProgress=true
		currSplotchIdx=0
		if (splotchInterval!=null) {
			clearInterval(splotchInterval)
		}
		clearSplotches()
		initSplotches()
		resetInProgress=false
	}
}

// END SPLOTCH CODE




