<!--

var dG = (document.getElementById)
var dA = (document.all)
var dL = (document.layers)

function bodyOnload()
{
	for(var i=0; i < text_resize.length; i++)
	{
		textwidth(text_resize[i][0], text_resize[i][1]);
	}
	for(var i=0; i < image_resize.length; i++)
	{
		imagesize(image_resize[i][0], image_resize[i][1], image_resize[i][2], image_resize[i][3], image_resize[i][4]);
	}
	// Recalc the leftblocks sizes
	document.getElementById("leftblockstable").style.display = "none";
	document.getElementById("leftblockstable").style.display = "block";
}

function go(url)
{
	window.location = url
}

function change_image(name, image_new)
{
	document.images[name].src=image_new
}



//
// Mouse events, for moving picturs
//
if (dL)
	window.captureEvents(Event.MOUSEMOVE);
else if(dA)
	;
else if(dG)
	window.captureEvents(Event.MOUSEMOVE);

var mijneerstemuiscoordinaatx = 0;
var mijneerstemuiscoordinaaty = 0;

if(dA)
{
	function MoveHandler()
	{
		mijneerstemuiscoordinaatx = event.x + document.body.scrollLeft + offsetX;
		mijneerstemuiscoordinaaty = event.y + document.body.scrollTop + offsetY;
		if (current_pic)
		{
			document.all(current_pic).style.left = event.x + document.body.scrollLeft + offsetX
			document.all(current_pic).style.top = event.y + document.body.scrollTop + offsetY
		}
	}
	document.onmousemove = MoveHandler;
}
else if(dL)
{
	function MoveHandlerNN(e)
	{
		mijneerstemuiscoordinaatx = E.pageX + document.body.scrollLeft + offsetX;
		mijneerstemuiscoordinaaty = E.pageY + document.body.scrollTop + offsetY;
		if (current_pic)
		{
			document.layers[current_pic].style.left = E.pageX + document.body.scrollLeft + offsetX
			document.layers[current_pic].style.top = E.pageY + document.body.scrollTop + offsetY
		}
	}
	document.onmousemove = MoveHandlerNN;
}
else if(dG)
{
	function MoveHandlerNN(e)
	{
		mijneerstemuiscoordinaatx = e.clientX + document.body.scrollLeft + offsetX;
		mijneerstemuiscoordinaaty = e.clientY + document.body.scrollTop + offsetY;
		if (current_pic)
		{
			document.getElementById(current_pic).style.left = e.clientX + document.body.scrollLeft + offsetX
			document.getElementById(current_pic).style.top = e.clientY + document.body.scrollTop + offsetY
		}
	}
	document.onmousemove = MoveHandlerNN;
}

var current_pic = ''
var defaultOffsetX = 10
var defaultOffsetY = 10
var offsetX = 10
var offsetY = 10

function show_pic(pic, plusX, plusY)
{
	if (dA)
		document.all(pic).style.visibility = 'visible';
	else if (dL)
		document.layers[pic].style.visibility = 'show';
	else if (dG)
		document.getElementById(pic).style.visibility = 'visible';
	
	offsetX = defaultOffsetX + plusX;
	offsetY = defaultOffsetY + plusY;

	current_pic = pic
}
function hide_pic(pic)
{
	if (dA)
	{
		document.all(pic).style.visibility = 'hidden';
		document.all(current_pic).style.left = -999;
		document.all(current_pic).style.top = -999;
	}
	else if (dL)
	{
		document.layers[pic].style.visibility = 'hide';
		document.layers[current_pic].style.left = -999;
		document.layers[current_pic].style.top = -999;
	}
	else if (dG)
	{
		document.getElementById(pic).style.visibility = 'hidden';
		document.getElementById(current_pic).style.left = -999;
		document.getElementById(current_pic).style.top = -999;
	}

	current_pic = ''
}


//
// Script for Log in form on the left side of the page
//
var value = new Array(2)
value["username"] = "Username"
value["password"] = "Password"
function text_focus(text)
{
	if (document.login[text].value == value[text])
		document.login[text].value = "";
}
function text_blur(text)
{
	if (document.login[text].value == "")
		document.login[text].value = value[text];
}

//
// When a piece of text is to large this script will cut
// that text so that it will fit the given size and will add
// '...' at the end so you can see its not the whole name
//
function textwidth(text, width)
{
	if (dA)
	{
		obj = document.all(text)
	}
	else if (dL)
	{
		obj = document.layers[text]
	}
	else if (dG)
	{
		obj = document.getElementById(text);
	}
	else
		return false;

	if (obj.offsetWidth > width)
		obj.innerHTML += "...";
	while (obj.offsetWidth > width)
	{
		obj.innerHTML = obj.innerHTML.substring(0, obj.innerHTML.length - 4);
		obj.innerHTML += "...";
	}
}

//
// Make an image smaller to fit in the given size
// if the image is larger than the given size
//
function imagesize(image, maxwidth, maxheight, minwidth, minheight)
{
/*
	if (dA)
	{
		image = document.all(image)
	}
	else if (dL)
	{
		image = document.layers[image]
	}
	else if (dG)
	{
		image = document.getElementById(image)
	}
	else
		return false;

	if ( (image.height > maxheight && maxheight) || (image.width > maxwidth && maxwidth) )
	{
		//alert(image + " boe")
		toheight = ( maxheight ) ? image.height - maxheight : 0
		towidth = ( maxwidth ) ? image.width - maxwidth : 0
		toheight_percent = ( maxheight ) ? eval((toheight / image.height) * 100) : 0
		towidth_percent = ( maxwidth) ? eval((towidth / image.width) * 100) : 0

		if (toheight_percent > towidth_percent)
		{
			endheight = image.height - toheight
			endwidth = image.width - eval(( (toheight_percent / 100) * image.width ))
		}
		else
		{
			endwidth = image.width - towidth
			endheight = image.height - eval(( (towidth_percent / 100) * image.height ))
		}

		image.width = endwidth
		image.height = endheight
	}
	else if ( (image.height < minheight && maxheight) || (image.width < minwidth && maxwidth) )
	{
		//alert(image + " boe")
		toheight = ( maxheight ) ? maxheight - image.height : 0
		towidth = ( maxwidth ) ? maxwidth - image.width : 0
		toheight_percent = ( maxheight ) ? eval((toheight / image.height) * 100) : 0
		towidth_percent = ( maxwidth) ? eval((towidth / image.width) * 100) : 0

		if (toheight_percent > towidth_percent)
		{
			endheight = image.height + toheight
			endwidth = image.width + eval(( (toheight_percent / 100) * image.width ))
		}
		else
		{
			endwidth = image.width + towidth
			endheight = image.height + eval(( (towidth_percent / 100) * image.height ))
		}

		image.width = endwidth
		image.height = endheight
	}
	
	// Load the image so were sure it will take the correct size
	var mySizeImage = new Image; mySizeImage.src = image.src
*/
}

//
// To show a full name entered by several textboxes
//
function namechange()
{
	name = document.profile.tagprefix.value
	name += document.profile.username.value
	name += document.profile.tagsuffix.value

	if (dA)
	{
		document.all("name").innerHTML = name
	}
	else if (dL)
	{
		document.layers["name"].innerHTML = name
	}
	else if (dG)
	{
		document.getElementById("name").innerHTML = name
	}
	else
		return false;
	
	textwidth("name", 149)

	return true;
}

//
// To check and uncheck a self made checkbox
//
function checkbox_click()
{
	if (dA)
	{
		check = document.all("login_checkbox")
	}
	else if (dL)
	{
		check = document.layers["login_checkbox"]
	}
	else if (dG)
	{
		check = document.getElementById("login_checkbox")
	}
	else
		return false;

	hidden = document.login.autologin

	if (hidden.value == "0")
	{
		check.src = "images/site_layout/checkbox_checked.gif"
		hidden.value = "1"
	}
	else
	{
		check.src = "images/site_layout/checkbox.gif";
		hidden.value = "0"
	}

	return true;
}

//
// Playerlist function for submit war
// Add a member to the playerlist
//
function add_member()
{
	if (dA)
	{
		add_button = document.all("add")
		del_button = document.all("del")
	}
	else if (dL)
	{
		add_button = document.layers["add"]
		del_button = document.layers["del"]
	}
	else if (dG)
	{
		add_button = document.getElementById("add")
		del_button = document.getElementById("del")
	}
	else
		return false;

	// Get the selected member
	b_selected = false
	for (var i=0; i<document.war.memberlist.length; i++)
	{
		if (document.war.memberlist.options[i].selected)
		{
			b_selected = true
			break;
		}
	}
	if (!b_selected)
		return false;

	if (document.war.memberlist.options[i].text != "")
	{
		// Increase the playerlist length
		document.war.playerlist.length++
		// Add the member to the playerlist
		document.war.playerlist.options[document.war.playerlist.length-1].text = document.war.memberlist.options[i].text
		// Remove the member from the memberlist
		for (j=i+1; j<document.war.memberlist.length; j++)
			document.war.memberlist.options[j-1].text = document.war.memberlist.options[j].text;
		// Decrease the length of the memberlist
		document.war.memberlist.length = j-1
		// Disable the add button if everything is allready added
		if (document.war.memberlist.length < 1)
		{
			document.war.add.disabled = true;
			add_button.className = "input_button_disabled";
		}
		// Delete button can be enabled since something is added
		document.war.del.disabled = false;
		del_button.className = "input_button";
	}
	
	return true;
}

//
// Playerlist function for submit war
// Delete a member from the playerlist
//
function del_member()
{
	if (dA)
	{
		add_button = document.all("add")
		del_button = document.all("del")
	}
	else if (dL)
	{
		add_button = document.layers["add"]
		del_button = document.layers["del"]
	}
	else if (dG)
	{
		add_button = document.getElementById("add")
		del_button = document.getElementById("del")
	}
	else
		return false;

	// Get the selected player
	b_selected = false
	for (var i=0; i<document.war.playerlist.length; i++)
	{
		if (document.war.playerlist.options[i].selected)
		{
			b_selected = true
			break;
		}
	}
	if (!b_selected)
		return false;

	if (document.war.playerlist.options[i].text != "")
	{
		// Increase the memberlist length
		document.war.memberlist.length++
		// Add the player to the memberlist
		document.war.memberlist.options[document.war.memberlist.length-1].text = document.war.playerlist.options[i].text
		// Remove the member from the playerlist
		for (j=i+1; j<document.war.playerlist.length; j++)
			document.war.playerlist.options[j-1].text = document.war.playerlist.options[j].text;
		// Decrease the length of the playerlist
		document.war.playerlist.length = j-1
		// Disable the del button if everything is allready deleted
		if (document.war.playerlist.length < 1)
		{
			document.war.del.disabled = true;
			del_button.className = "input_button_disabled";
		}
		// Add button can be enabled since something is deleted
		document.war.add.disabled = false;
		add_button.className = "input_button";
	}

	return true;
}
function pre_playerlist()
{
	if (dA)
	{
		add_button = document.all("add")
		del_button = document.all("del")
	}
	else if (dL)
	{
		add_button = document.layers["add"]
		del_button = document.layers["del"]
	}
	else if (dG)
	{
		add_button = document.getElementById("add")
		del_button = document.getElementById("del")
	}
	else
		return false;

	// Disable del button if playerlist is empty
	if (document.war.playerlist.length < 1)
	{
		document.war.del.disabled = true;
		del_button.className = "input_button_disabled";
	}
	else
	{
		document.war.playerlist.options[0].selected = true;
	}
	// Disable add button if memberlist is empty
	if (document.war.memberlist.length < 1)
	{
		document.war.add.disabled = true;
		add_button.className = "input_button_disabled";
	}
}

function post_playerlist()
{
	document.war.playerlist.name = "playerlist[]"
	document.war.playerlist.multiple = true
	alert("Hey schatje")
	return select_all()
}

function select_all()
{
	var i = 0;
	for (i=0; i<document.war.playerlist.length; i++)
		document.war.playerlist.options[i].selected = true;

	var b_all_selected = true
	for (i=0; i<document.war.playerlist.length; i++)
	{
		if (document.war.playerlist.options[i].selected == false)
			b_all_selected = false;
	}
	
	return b_all_selected
}
function show_info(content, offset_right, offset_bottom)
{
	if (!offset_right) offset_right = -3;
	if (!offset_bottom) offset_bottom = 17;
	document.getElementById("info_content").innerHTML = content;
	document.getElementById("info_table").style.top = mijneerstemuiscoordinaaty + offset_bottom;
	document.getElementById("info_table").style.left = mijneerstemuiscoordinaatx + offset_right;
}
function hide_info()
{
	document.getElementById("info_table").style.top = -999;
}
function place_ip()
{
	war.server2_ip.value = ips[document.getElementById('opponent_id').options[document.getElementById('opponent_id').selectedIndex].value];
}

text_resize = new Array()
image_resize = new Array()
menu_width = new Array()
b_playerlist = false

-->
