var letters = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m" ],
	x, y, z, spacer, buttonImages = [],
	path = "http://whatdoyouwant2be.org",
	imgPath = path + "/images/";

function init() {
	loadImages();
	ShowSponsors();
}

function loadImages() {
	var l, thisL;
		x = new Image(21,153);   x.src = imgPath + "btn_x.gif";
		y = new Image(21,153);   x.src = imgPath + "btn_y.gif";
		z = new Image(21,153);   z.src = imgPath + "btn_x.gif";
		spacer = new Image(14,135); spacer.src = imgPath + "spacer.gif";

	for ( l=0; l < letters.length; l++ ) {
		thisL = letters[l];
		buttonImages[ thisL + "1"] = new Image(21,153);
		buttonImages[ thisL + "1"].src = imgPath + "btn_" + thisL + "1.gif";

		buttonImages[ thisL + "2"] = new Image(21,153);
		buttonImages[ thisL + "2"].src = imgPath + "btn_" + thisL + "1.gif";

		buttonImages[ thisL + "3"] = new Image(21,153);
		buttonImages[ thisL + "3"].src = imgPath + "btn_" + thisL + "1.gif";
	}
}

var LayerRef = "document.layers",
	StyleRef = "",
	SubImgRef = "document.SubButtons.document",
	Visible = "a",
	SubVisible = null,
	SubSubVisible = null,
	Alphabet = "abcdefghijklmnopqrstuvwxyz",

	ie4 = (document.all) ? true : false,
	ie5 = ( navigator.appVersion.indexOf("MSIE 5") != -1 ),
	ns4 = ( document.layers) ? true : false,
	ns6 = ( (navigator.appName.indexOf("Netscape") != -1) && parseInt(navigator.appVersion) >= 5 ),
	mac = ( navigator.userAgent.indexOf("Mac") != -1) ? true : false,
	kht = ( navigator.userAgent.indexOf("KHTML") != -1),
	d;

function dIE4(id) { return document.all[id]; }
function dNS4(id) { return document.layers[id]; }
function dDOM(id) { return document.getElementById(id); }

function s(id) { return d(id).style; }

//  T O P    L E V E L   F U N C T I O N S   
function SwapIn(x,i) {
	SwapOut(Visible);
	document[x].src = buttonImages[ x + "1" ].src;
	if (i) {
		s("Sub" + x).visibility = "visible";
		SubVisible = "a";
	}
	ShowButtons(i);
	Visible = x;
}

function SwapOut(x) {
	document[x].src = imgPath + "btn_x.gif";
	if (SubVisible) {
		s("Sub" + Visible).visibility = "hidden";
		document.images["SB" + SubVisible].src = imgPath + "btn_x.gif";
		SwapSubOut();
		SubVisible = null;
	}
	KillSubButtons(0);
}

function ShowButtons(NumOfButns) {
	var i, but, h = Math.round( ( (350 - (NumOfButns*23) ) >> 1) + 391);
	for (i=0; i < NumOfButns; i++) {
		but = "y" + Alphabet.charAt(i);
		s(but).visibility = "visible";
		s(but).top = h + "px";
		h += 23;
	}
	KillButtons(NumOfButns);
}

function KillButtons(UnusedButns) {
	for (var i = UnusedButns; i < 19; i++) {
		var dead = "y" + Alphabet.charAt(i);
		s(dead).visibility = "hidden";
	}
}

//   2nd   L E V E L   M E N U    F U N C T I O N S  
function SwapSubIn(y,z,i) {
	SwapSubOut();
	document.images["SB" + y].src = buttonImages[ z + "2" ].src;
	if (i) {
		s("Sub" + z + y).visibility = "visible";
		SubSubVisible = "a";
	}
	ShowSubButtons(i);
	SubVisible = y;
}

function SwapSubOut() {
	document.images["SB" + SubVisible].src = imgPath + "btn_x.gif";
	if (SubSubVisible) {
		document.images["SSB" + SubSubVisible].src = imgPath + "btn_x.gif";
		s("Sub" + Visible + SubVisible).visibility = "hidden";
		SubSubVisible = null;
	}
}

function ShowSubButtons(NumOfButns) {
	var i, but, h = Math.round( ( (350 - (NumOfButns*23) ) >> 1) + 391);
	for (i=0; i < NumOfButns; i++) {
		but = "z" + Alphabet.charAt(i);
		s(but).visibility = "visible";
		s(but).top = h + "px";
		h += 23;
	}
	KillSubButtons(NumOfButns);
}

function KillSubButtons(UnusedButns) {
	var i, Subdead;
	for (i = UnusedButns; i < 20; i++) {
		Subdead = "z" + Alphabet.charAt(i);
		s(Subdead).visibility = "hidden";
	}
}

//  3rd   L E V E L    M E N U    F U N C T O N  
function Swap(y,z) {
	document.images["SSB" + SubSubVisible].src = imgPath + "btn_x.gif";
	document.images["SSB" + y].src = buttonImages[ z + "3" ].src;
	SubSubVisible = y;
}

function DoNothing() { return true; }

//  N E T S C A P E 4.x   F U N C T I O N S
function SwapIn_NS(x,i) {
	SwapOut(Visible);
	document.MainButtons.document[x].src = buttonImages[ x + "1" ].src;
	if (i) {
		s("Sub" + x).visibility = "visible";
		SubVisible = "a";
	}
	ShowButtons(i);
	Visible = x;
}

function SwapOut_NS(x) {
	document.MainButtons.document[x].src = imgPath + "btn_x.gif";
	if (SubVisible) {
		s("Sub" + Visible).visibility = "hidden";
		document["y" + SubVisible].document["SB" + SubVisible].src = imgPath + "btn_x.gif";
		SwapSubOut();
		SubVisible = null;
	}
	KillSubButtons(0);
}

function SwapSubIn_NS(y,z,i) {
	SwapSubOut();
	document["y" + y].document["SB" + y].src = buttonImages[ z + "2" ].src;
	if (i) {
		s("Sub" + z + y).visibility = "visible";
		SubSubVisible = "a";
	}
	ShowSubButtons(i);
	SubVisible = y;
}

function SwapSubOut_NS() {
	document["y" + SubVisible].document["SB" + SubVisible].src = imgPath + "btn_x.gif";
	if (SubSubVisible) {
		document["z" + SubSubVisible].document["SSB" + SubSubVisible].src = imgPath + "btn_x.gif";
		s("Sub" + Visible + SubVisible).visibility = "hidden";
		SubSubVisible = null;
	}
}

function Swap_NS(y,z) {
	document["z" + SubSubVisible].document["SSB" + SubSubVisible].src = imgPath + "btn_x.gif";
	document["z" + y].document["SSB" + y].src = buttonImages[ z + "3" ].src;
	SubSubVisible = y;
}

if ( ie4 ) {
	d = dIE4;
}
else if ( ns4 ) {
	d = dNS4;
	s = d;
	SwapIn = SwapIn_NS;
	SwapOut = SwapOut_NS;
	SwapSubIn = SwapSubIn_NS;
	SwapsSubOut = SwapSubOut_NS;
	Swap = Swap_NS;
}
else {
	d = dDOM;
}


