window.onload = function() {
	pageDIV = document.getElementById('page');
	sidebarDIV = document.getElementById('sidebar');

	if (pageDIV.offsetHeight >= sidebarDIV.offsetHeight) {
		sH = (pageDIV.offsetHeight + 10);
		sidebarDIV.style.height = (sH + 'px');
	};
};

function l() {
	username = document.login.username;
	password = document.login.password;

	if (username.value == '') {
		username.focus();
		return false;
	};

	if (password.value == '') {
		password.focus();
		return false;
	};

	return true;
};

function g(location) {
	window.location = location;
};

function s() {
	username = document.signup.username;
	password = document.signup.password;
	password2 = document.signup.password2;
	email = document.signup.email;
	email2 = document.signup.email2;
	nospam = document.signup.nospam;

	if (username.value == '') {
		username.focus();
		return false;
	};

	if (password.value == '') {
		password.focus();
		return false;
	};

	if (password2.value != password.value) {
		password2.focus();
		return false;
	};

	if (email.value == '') {
		email.focus();
		return false;
	};

	if (email.value.indexOf('@', 0) < 0) {
		email.focus();
		return false;
	};

	if (email.value.indexOf('.', 0) < 0) {
		email.focus();
		return false;
	};

	if (email2.value != email.value) {
		email2.focus();
		return false;
	};

	if (nospam.value != '455') {
		nospam.focus();
		return false;
	};

	return true;
};

function r() {
	uname = document.recover.uname;
	nospam = document.recover.nospam;

	if (uname.value == '') {
		uname.focus();
		return false;
	};

	if (nospam.value != '200') {
		nospam.focus();
		return false;
	};

	return true;
};

function task(page,type)	{
	if (type == 'acc') {

		document.getElementById('Unstucker').className = '';
		document.getElementById('Teleporter').className = '';
		document.getElementById('PvPTitle').className = '';
//		document.getElementById('Transfer').className = '';
		document.getElementById('Password').className = '';
	}

	if (type == 'vote') {

		document.getElementById('ItemShop').className = '';
		document.getElementById('VoteAbout').className = '';
		document.getElementById('ItemCost').className = '';

	}

	document.getElementById(page).className = 'home';

	if (type == 'acc') {

		document.getElementById('tool_Unstucker').className = 'story hidden'
		document.getElementById('tool_Teleporter').className = 'story hidden'
		document.getElementById('tool_PvPTitle').className = 'story hidden'
//		document.getElementById('tool_Transfer').className = 'story hidden'
		document.getElementById('tool_Password').className = 'story hidden'

	}

	if (type == 'vote') {

		document.getElementById('tool_ItemShop').className = 'story hidden'
		document.getElementById('tool_VoteAbout').className = 'story hidden'
		document.getElementById('tool_ItemCost').className = 'story hidden'

	}

	document.getElementById('tool_' + page).className = 'story';
};

function t_Unstucker() {
	character = document.tool_Unstucker.character;

	if (character.value == '') {
		character.focus();
		return false;
	};

	return true;
};

function t_Teleporter() {
	character = document.tool_Teleporter.character;
	destination = document.tool_Teleporter.destination;

	if (character.value == '') {
		character.focus();
		return false;
	};

	if (destination.value == '') {
		destination.focus();
		return false;
	};

	return true;
};

function t_PvPTitle() {
	character = document.tool_PvPTitle.character;
	title = document.tool_PvPTitle.title;

	if (character.value == '') {
		character.focus();
		return false;
	};

	if (title.value == '') {
		title.focus();
		return false;
	};

	return true;
};

function t_Transfer() {
	character = document.tool_Transfer.character;
	src_login = document.tool_Transfer.src_login;
	src_password = document.tool_Transfer.src_password;
	des_login = document.tool_Transfer.des_login;
	des_password = document.tool_Transfer.des_password;

	if (character.value == '') {
		character.focus();
		return false;
	};

	if (src_login.value == '') {
		src_login.focus();
		return false;
	};

	if (src_password.value == '') {
		src_password.focus();
		return false;
	};

	if (des_login.value == '') {
		des_login.focus();
		return false;
	};

	if (des_password.value == '') {
		des_password.focus();
		return false;
	};

	return true;
};

function t_Password() {
	password = document.tool_Password.password;
	password2 = document.tool_Password.password2;
	password3 = document.tool_Password.password3;

	if (password.value == '') {
		password.focus();
		return false;
	};

	if (password2.value == '') {
		password2.focus();
		return false;
	};

	if (password3.value == '') {
		password3.focus();
		return false;
	};

	if (password3.value != password2.value) {
		password3.focus();
		return false;
	};

	return true;
};

function c() {
	uname = document.contact.name;
	login = document.contact.login;
	char = document.contact.character;
	subject = document.contact.subject;
	email = document.contact.email;
	message = document.contact.message;
	nospam = document.contact.nospam;

	if (uname.value == '') {
		uname.focus();
		return false;
	};

	if (login.value == '') {
		login.focus();
		return false;
	};

	if (char.value == '') {
		char.focus();
		return false;
	};

	if (subject.value == '') {
		subject.focus();
		return false;
	};

	if (email.value == '') {
		email.focus();
		return false;
	};

	if (email.value.indexOf('@', 0) < 0) {
		email.focus();
		return false;
	};

	if (email.value.indexOf('.', 0) < 0) {
		email.focus();
		return false;
	};

	if (message.value == '') {
		message.focus();
		return false;
	};

	if (nospam.value != '435') {
		nospam.focus();
		return false;
	};

	return true;
};

function t_ItemShop() {
	iItem = document.item_shop.item;
	character = document.item_shop.character;

	if (iItem.value == '') {
		iItem.focus();
		return false;
	};

	if (character.value == '') {
		character.focus();
		return false;
	};

	return true;
};

function addItem(id) {
	iItem = document.item_shop.item;
	iItem.value = id;
};

var xmlHTTP

function searchItem(name,realm)	{
	xmlHTTP = GetxmlHTTPObject();

	var url = '/vote/tool.asp?searchItem=' + name + '&realm=' + realm;

	document.getElementById('results').innerHTML = '<tr><td>Searching...</td></tr>';

	xmlHTTP.onreadystatechange = showR;
	xmlHTTP.open('GET', url, true);
	xmlHTTP.send(null);
};

function showR()	{ 
	if (xmlHTTP.readyState == 0|1|2|3)	{
		document.getElementById('results').innerHTML = '<tr><td>Searching...</td></tr>';
	};

	if (xmlHTTP.readyState == 4)	{
		document.getElementById('results').innerHTML = xmlHTTP.responseText;
	};
};

function GetxmlHTTPObject(){var xmlHTTP=null;try{xmlHTTP=new XMLHttpRequest();}catch(e){try{xmlHTTP=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){xmlHTTP=new ActiveXObject('Microsoft.XMLHTTP');};};return xmlHTTP;};

function hide_vote() {
	document.getElementById('votepopup').style.display = 'none';
};
