	function hashLoginPassword(doForm, cur_session_id)
	{
		// Compatibility.
		if (cur_session_id == null)
			cur_session_id = smf_session_id;

		if (typeof(hex_sha1) == 'undefined')
			return;
		// Are they using an email address?
		if (doForm.user.value.indexOf('@') != -1)
			return;

		// Unless the browser is Opera, the password will not save properly.
		if (!('opera' in window))
			doForm.passwrd.autocomplete = 'off';

		doForm.hash_passwrd.value = hex_sha1(hex_sha1(doForm.user.value.php_to8bit().php_strtolower() + doForm.passwrd.value.php_to8bit()) + cur_session_id);

		// It looks nicer to fill it with asterisks, but Firefox will try to save that.
		if (is_ff != -1)
			doForm.passwrd.value = '';
		else
			doForm.passwrd.value = doForm.passwrd.value.replace(/./g, '*');
	}

	function checkForm(form)
	{
		var htmlStart = '<h3>Error</h3>';
		var htmlEnd = '<br />';

		if(form.name.value == '')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Server name</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.fileType.value == 'select')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Server files</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.chronicle.value == 'select')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Chronicle</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.language.value == 'select')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Language</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.rate_xp.value == '')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Rate, XP</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.rate_sp.value == '')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Rate, SP</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.rate_drop.value == '')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Rate, Drop</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}
		
		if(form.rate_adena.value == '')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Rate, Adena</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}
		
		if(form.rate_spoil.value == '')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Rate, Spoil</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.url_website.value == '')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Website url</i>\' is invalid.</font><br />'+htmlEnd;
			return false;
		}

		if(form.ip_login.value == '')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Login IP</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.ip_game.value == '')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Game IP</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.login_port.value == '')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Login port</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.game_port.value == '')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Game port</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.hasCustomArmor.value == 'select')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Custom armors</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.hasCustomWeapon.value == 'select')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Custom weapons</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.donation_items.value == 'select')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Stats-items by donation</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.donation_enchant.value == 'select')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Enchant by donation</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		return true;
	}

	function checkFormPortal(form)
	{
		var htmlStart = '<h3>Error</h3>';
		var htmlEnd = '';

		if(form.name.value == '')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Portal name</i>\' cannot be left empty.</font><br />'+htmlEnd;
			return false;
		}

		if(form.url_website.value == '' || form.url_website.value == 'http://')
		{
			document.getElementById('errorReport').innerHTML = htmlStart+'<font color=\'red\'>The field \'<i>Portal url</i>\' is invalid.</font><br />'+htmlEnd;
			return false;
		}
		
		return true;
	}

	function tryResetForm(form)
	{
		if (document.getElementById(form) != null)
			document.getElementById(form).reset();
	}

	function setQuoteId(id)
	{
		var textBox = document.getElementById("commentInput");
		var textBox2 = document.getElementById("commentInputBox");
		if (textBox != null && textBox2 != null)
		{
			textBox.value = id;
			textBox2.focus();
			smoothScroll('commentInputBox');
		}
	}

	/* Smooth-Scroll functions from http://www.itnewb.com/v/Creating-the-Smooth-Scroll-Effect-with-JavaScript */
	function currentYPosition()
	{
		if (self.pageYOffset)
			 return self.pageYOffset;
		if (document.documentElement && document.documentElement.scrollTop)
			return document.documentElement.scrollTop;
		if (document.body.scrollTop)
			 return document.body.scrollTop;
		return 0;
	}
	function elmYPosition(eID)
	{
		var elm  = document.getElementById(eID);
		var y    = elm.offsetTop;
		var node = elm;
		while (node.offsetParent && node.offsetParent != document.body) {
			node = node.offsetParent;
			y   += node.offsetTop;
		} return y;
	}
	function smoothScroll(eID)
	{
		var startY   = currentYPosition();
		var stopY    = elmYPosition(eID);
		var distance = stopY > startY ? stopY - startY : startY - stopY;
		if (distance < 100) {
			scrollTo(0, stopY); return;
		}
		var speed = Math.round(distance / 100);
		if (speed >= 20) speed = 20;
		var step  = Math.round(distance / 25);
		var leapY = stopY > startY ? startY + step : startY - step;
		var timer = 0;
		if (stopY > startY) {
			for ( var i=startY; i<stopY; i+=step ) {
				setTimeout("window.scrollTo(0, "+leapY+")", timer * speed);
				leapY += step; if (leapY > stopY) leapY = stopY; timer++;
			} return;
		}
		for ( var i=startY; i>stopY; i-=step ) {
			setTimeout("window.scrollTo(0, "+leapY+")", timer * speed);
			leapY -= step; if (leapY < stopY) leapY = stopY; timer++;
		}
	}
	/* End Smooth-Scroll functions */
	
	function SelectAll(id)
	{
		document.getElementById(id).focus();
		document.getElementById(id).select();
	}
