var preload = 1

function opacity()
{
var el = document.getElementById("dialog_bg")

var opacityType=(
  (typeof el.style.opacity !== 'undefined') ? 'opacity' :
  /*@cc_on @if (@_jscript)
    (typeof el.style.filters === 'object') ? 'filters' :
    (typeof el.style.filter === 'string') ? 'filter' :
  @end @*/
  'none'
);

el.style.backgroundColor = "#000000";

if(opacityType == "opacity")
	el.style[opacityType] = "0.6";
else if(opacityType != "none")
	el.style[opacityType] = "alpha(opacity=60)";
else
	return false; // replace background with a fake transparency
}

function closeDialog(e)
{
	document.getElementById("dialog_bg").style.display = "none"
	document.getElementById("container").style.display = "none"

	if (e && e.preventDefault)
		e.preventDefault();
	else //if (window.event)
		return false;
}

function randBg()
{
	document.body.style.background = "url(" + bgURL + ") fixed no-repeat #000000 center center"
}

// title, text, image, alt, width, height
var dialog = []

// add a variable to color the title/body text
// make the final array indicies the text.. if there are more than one, then make those appear as new paragraphs.
dialog["info"] = ["Tribes Master Server Query Info:", "Page last updated: " + (document.lastModified ? document.lastModified : "Unknown") + ".. This site is compatible and tested with Firefox, IE7/8, and Google Chrome.", "done", "done", "45", "19"]
dialog["motd"] = ["Message of the day:", "This site is still in beta. Many features will be available in the future to include sorting, user list configuration, and much more. ", "done", "done", "45", "19"]
dialog["settings"] = ["Settings:", "Eventually, you will be able to choose a wide variety of settings to customize the search results.", "done", "done", "45", "19"]


function showDialog(e)
{
	if(e)
	{
		var targ = e.target ? e.target : e.srcElement
		var x = targ.id
	}
	else //if (window.event)
	{
		alert("HOW DID THIS HAPPEN!?")
		return false;
	}

	document.getElementById("dialog_bg").style.display = "inline"
	document.getElementById("container").style.display = "inline"

	// out with the old
	while(document.getElementById("centerText").childNodes.length)
		document.getElementById("centerText").removeChild(document.getElementById("centerText").firstChild)

	if(document.getElementById("footer").firstChild)
		document.getElementById("footer").removeChild(document.getElementById("footer").firstChild)

	var title = document.createElement("p")
	title.style.color = "#fff"
	title.appendChild(document.createTextNode(dialog[x][0]))
	document.getElementById("centerText").appendChild(title)

	var text = document.createElement("p")
	text.style.display = "block" // ........ maybe
	text.appendChild(document.createTextNode(dialog[x][1]))
	document.getElementById("centerText").appendChild(text)

	var img = document.createElement("img")
	img.src = "images/buttons/" + dialog[x][2] + ".jpg"
	img.alt = dialog[x][3]
	img.width = dialog[x][4]
	img.height = dialog[x][5]
	document.getElementById("footer").appendChild(img)

	AttachEvent(document.getElementById("footer").firstChild,'click',closeDialog,false)
}

function initGUI()
{
	AttachEvent(document.getElementById("info"),'click',showDialog,false)
	document.getElementById("info").className = "clickable"

	AttachEvent(document.getElementById("motd"),'click',showDialog,false)
	document.getElementById("motd").className = "clickable"

	AttachEvent(document.getElementById("settings"),'click',showDialog,false)
	document.getElementById("settings").className = "clickable"
}