function smiley(symbol)
{
	document.pjirc.setFieldText(document.pjirc.getFieldText()+symbol+' ');
	document.pjirc.requestSourceFocus();
}

function start_chat()
{
	if (document.login.nick.value == '')
	{
		// document.login.nick.value = 'Guest'+Math.round(Math.random()*1000);
		alert('Please enter a nickname!');
		document.login.nick.focus();

		return false;
	}

	document.login.target = 'mypopup';
	OpenPopup(750, 590);

	return true;
}

function OpenPopup(x, y)
{
	var values  = 'width='+x+', height='+y+', left=0, top=0,'
	values += 'dependent=no, hotkeys=no, resizable=yes, scrollbars=yes, menubar=no'
	window.open(document.login.action, document.login.target, values);
}

function nickserv_register()
{
	if (document.getElementById('pw').value != document.getElementById('pw2').value)
	{
		alert('The passwords don\'t match!\nPlease type again!');
		document.getElementById('pw').value = '';
		document.getElementById('pw2').value = '';
		return;
	}
	if (document.getElementById('pw').value == '')
	{
		alert('Please enter a password!');
		return;
	}
	if (document.getElementById('email').value == '')
	{
		alert('Please enter an email address!');
		return;
	}

	document.pjirc.sendString('/msg nickserv register '+document.getElementById('pw').value+' '+document.getElementById('email').value);
	alert('A Registration request has been sent.\nTake a look at the chat window, to see, if the registration has been successful.');

	document.getElementById('pw').value = '';
	document.getElementById('pw2').value = '';
	document.getElementById('email').value = '';
}

function show_register()
{
	var html = '<b>Register your nickname:</b>&nbsp;';
	html += '<b>Password:<\/b>&nbsp;<input type="password" id="pw" size="20">&nbsp;&nbsp;';
	html += '<b>Confirm Password:<\/b>&nbsp;<input type="password" id="pw2" size="20">&nbsp;&nbsp;';
	html += '<b>Email:<\/b>&nbsp;<input type="text" id="email" size="20">&nbsp;&nbsp;';
	html += '<input type="button" value="Register" onclick="nickserv_register();">';
	
	document.getElementById('register').innerHTML = html;
}
