var IE4 = (document.all && !document.getElementById) ? 1 : 0;
var NS4 = (document.layers) ? 1 : 0;
var IE5 = (document.all && document.getElementById) ? 1 : 0;
var NS6 = (document.getElementById && !document.all) ? 1 : 0;

var current_opacity = 0;
var interval = false;
var counter = 0;
var which_message = 0;
var strings = new Array(
	"The darkness has found me.",
	"I can't seem to escape it.",
	"It clings to me like a dying lover.",
	"The darkness that is my mind.",
	"Why have you come here?",
	"What do you hope to find?",
	"Do you think you are welcome here?",
	"This is my digital asylum.",
	"The voices are calling...",
	"Are you listening?",
	""
	);

function start() {

	interval = setInterval("fader()",1);

}

function fader() {

	elem = document.getElementById("message");

	if(counter == 0) {
		elem.innerHTML = strings[which_message];
		counter++;
	} else if(counter < 100) {
		current_opacity += 1;
		setOpacity(elem, current_opacity);
		counter++;
	} else if(counter < 200) {
		counter++;
	} else if(counter < 300) {
		current_opacity -= 1;
		setOpacity(elem, current_opacity);
		counter++;
	} else {
		counter = 0;
		which_message++;
		if(which_message == strings.length) {
			which_message = 0;
		}
	}

}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;

  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";

  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;

  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;

  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}


function showMenu(menu, show) {

	if (IE4) { elem = eval("document.all.menu_" + menu + ".style"); }
	else if (IE5 || NS6) { elem = document.getElementById('menu_' + menu).style; }


	if(show) { elem.display = "block"; }
	else { elem.display = "none"; }
}

function toggle(id) {
	if(document.getElementById(id).style.display == "block") {
		document.getElementById(id).style.display = "none";
	} else {
		document.getElementById(id).style.display = "block";
	}
}

function printable() {

	var url = location.href;
	var url1, url2;
	var loc = url.lastIndexOf('.');
	url1 = url.substr(0,loc);
	url2 = url.substr(loc);

	url = url1 + "-print" + url2;

	window.open(url,'printable','scrollbars=yes,resizable=yes,width=700,height=400');

}

function jumpMenu(control) {

	if (IE4) { elem = eval("document.all.content.style"); }
	else if (IE5 || NS6) { elem = document.getElementById('content').style; }

	elem.scrollTo(200,200);
}
