if (!window.place) window.place = "welcome"	// must be in lowercase!
if (!window.amount) window.amount = 7
if (!window.muvehost) window.muvehost = 'psyced.org'
if (!window.muveloc) window.muveloc = 'http://'+window.muvehost+'/@'
// was: https
if (!window.webchat) window.webchat = 'http://'+window.muvehost+'/PSYC/'

if (!window.top.psyclogdone) {
	window.muvelink = window.muveloc
	window.muvelink += escape(window.place)
	    +'?format=js&amount='+window.amount
	    +'&from='+escape(document.referrer)
	    +'&location='+escape(document.location)
	//  +'&timezone='+escape((new Date()).getTimezoneOffset())
	//alert(window.muvelink);
	document.write('<script src="'+ window.muvelink +'"></script>\n')
}

function psyclogView(logData) {
	if (logData) {
		l = logData.length-1
		for (i=0; i<l;) {
			when = logData[i++]
			who = logData[i++]
			how = logData[i++]
			what = logData[i++]

			if (what == "")
			    document.writeln("<tr><td nowrap class=ts>" +when
			    +"</td><td colspan=2 nowrap class=sp><b>"+who
			    +"</b> "+how +"</td></tr>")
			else document.writeln("<tr><td nowrap class=ts>" +when
			    +"</td><td nowrap class=sp><b>"+who
			    +"</b> "+how +":</td><td class=tx>"+what
			    +"</td></tr>")
		}
		document.writeln("<tr><td colspan=2 class=sp>currently in "
		    +window.place+":</td><td class=tx><b>"+ logData[l]
		    +"</b></td></tr>")
	} else {
/*		document.writeln(
	    "<tr><td colspan=3>[sigh, cannot reach room service at "+
	    + window.muvelink + "]</td></tr>") */
	}
	document.writeln('<tr><td class=if colspan=3>You can <a href="'
	    +window.webchat+'?room='+window.place+'">ENTER THIS ROOM</a>, '
	    +'via <a href="psyc://'+window.muvehost+'/@'+window.place
	    +'">PSYC</a>, <a href="telnet://'+window.muvehost+'">TELNET</a>, '
	    +'<a href="xmpp:*'+window.place+'@'+window.muvehost
	    +'">XMPP</a><br> or <a href="irc://'+window.muvehost+'/'
	    +window.place+'">IRC</a> using /server '+window.muvehost
	    +' and /join #'+window.place+'</td></tr>')
}

function psyclog() {
	if (window.top.psyclogdone)
	    document.write('<script> psyclogView(window.top.document.'
		+window.top.place+') </script>\n')
	else document.write('<script> psyclogView(document.'+window.place
		+') </script>\n')
}

window.top.psyclogdone = 1
