// <SCRIPT>
<!-- //
	var MISSING_INPUT_CLASSNAME = ' MissingInput';

	function FormBuilderMissingTextValue( fieldRef, doFocus )
	{
		if( fieldRef.value.length == 0 )
		{
			fieldRef.parentNode.className += MISSING_INPUT_CLASSNAME;
			if( doFocus )
			{
				if( null!=fieldRef.focus )
					fieldRef.focus();
			}
			return true;
		}
		else
		{
			if( fieldRef.parentNode.className.indexOf( MISSING_INPUT_CLASSNAME )!=-1 )
			{
				fieldRef.parentNode.className = fieldRef.parentNode.className.split( MISSING_INPUT_CLASSNAME ).join('');
			}
			return false;
		}
	}
	
	function FormBuilderMissingNumberValue( fieldRef, doFocus )
	{
		if( fieldRef.value.length == 0 )
		{
			fieldRef.parentNode.className += MISSING_INPUT_CLASSNAME;
			if( doFocus )
			{
				if( null!=fieldRef.focus )
					fieldRef.focus();
			}
			return true;
		}
		else
		{
			if(/^\d*$/.test( fieldRef.value ))
			{
				if( fieldRef.parentNode.className.indexOf( MISSING_INPUT_CLASSNAME )!=-1 )
				{
					fieldRef.parentNode.className = fieldRef.parentNode.className.split( MISSING_INPUT_CLASSNAME ).join('');
				}
				return false;
			}
			else
			{
				fieldRef.parentNode.className += MISSING_INPUT_CLASSNAME;
				if( doFocus )
				{
					if( null!=fieldRef.focus )
						fieldRef.focus();
				}
				return true;
			}
		}
	}
	
	function FormBuilderIntegerNumber( fieldRef, doFocus, NumberOfDigits )
	{
		// backslash escaped with dbl backslash
		var str = "\\d{" + NumberOfDigits + "}"
		var rgx = new RegExp(str); 
		return FormBuilderRegExp( fieldRef, doFocus, rgx );
	}


	function FormBuilderRegExp( fieldRef, doFocus, regExp )
	{
		if( fieldRef.value.length == 0 )
		{
			fieldRef.parentNode.className += MISSING_INPUT_CLASSNAME;
			if( doFocus )
			{
				if( null!=fieldRef.focus )
					fieldRef.focus();
			}
			return true;
		}
		else
		{
			if(new RegExp( regExp).test( fieldRef.value ))
			{
				if( fieldRef.parentNode.className.indexOf( MISSING_INPUT_CLASSNAME )!=-1 )
				{
					fieldRef.parentNode.className = fieldRef.parentNode.className.split( MISSING_INPUT_CLASSNAME ).join('');
				}
				return false;
			}
			else
			{
				fieldRef.parentNode.className += MISSING_INPUT_CLASSNAME;
				if( doFocus )
				{
					if( null!=fieldRef.focus )
						fieldRef.focus();
				}
				return true;
			}
		}
	}
	
	function FormBuilderMissingPhoneNoValue( fieldRef, doFocus )
	{
		if( fieldRef.value.length == 0 )
		{
			fieldRef.parentNode.className += MISSING_INPUT_CLASSNAME;
			if( doFocus )
			{
				if( null!=fieldRef.focus )
					fieldRef.focus();
			}
			return true;
		}
		else
		{
			if(/^\d{8}$/.test( fieldRef.value ))
			{
				if( fieldRef.parentNode.className.indexOf( MISSING_INPUT_CLASSNAME )!=-1 )
				{
					fieldRef.parentNode.className = fieldRef.parentNode.className.split( MISSING_INPUT_CLASSNAME ).join('');
				}
				return false;
			}
			else
			{
				fieldRef.parentNode.className += MISSING_INPUT_CLASSNAME;
				if( doFocus )
				{
					if( null!=fieldRef.focus )
						fieldRef.focus();
				}
				return true;
			}
		}
	}
	
	function FormBuilderMissingEmailValue( fieldRef, doFocus )
	{
		fieldRef.value = fieldRef.value.split(' ').join('');
		var AtSplit = fieldRef.value.split('@');
		if( AtSplit.length == 2 )
		{
			if( AtSplit[0].length != 0 )
			{
				var HostSplit = AtSplit[1].split('.');
				if( HostSplit.length != 1 )
				{
					var EmptyHostPart = false;
					for( var i=0; i!=HostSplit.length; i++ )
					{
						EmptyHostPart = EmptyHostPart || (HostSplit[ i ].length == 0);
					}
					if( !EmptyHostPart )
					{
						if( fieldRef.value.indexOf( ';' )==-1 )
						{
							// Okay - enough is enough - come on in
							if( fieldRef.parentNode.className.indexOf( MISSING_INPUT_CLASSNAME )!=-1 )
							{
								fieldRef.parentNode.className = fieldRef.parentNode.className.split( MISSING_INPUT_CLASSNAME ).join('');
							}
							return false;
						}
					}
				}
			}
		}
		
		fieldRef.parentNode.className += MISSING_INPUT_CLASSNAME;
		if( doFocus )
		{
			if( null!=fieldRef.focus )
				fieldRef.focus();
		}
		return true;
	}
	
	function FormBuilderMissingSelectValue( fieldRef, doFocus )
	{
		if( fieldRef.selectedIndex == -1 || fieldRef.options[ fieldRef.selectedIndex ].value.length == 0 )
		{
			fieldRef.parentNode.className += MISSING_INPUT_CLASSNAME;
			if( doFocus )
			{
				if( null!=fieldRef.focus )
					fieldRef.focus();
					
			}
			return true;
		}
		else
		{
			if( fieldRef.parentNode.className.indexOf( MISSING_INPUT_CLASSNAME )!=-1 )
			{
				fieldRef.parentNode.className = fieldRef.parentNode.className.split( MISSING_INPUT_CLASSNAME ).join('');
			}
			return false;
		}
	}
	
	function FormBuilderMissingInputOptionValue( fieldRef, doFocus )
	{
		if( fieldRef.length == 0 )
		{
			return false;
		}
		
		if( fieldRef.length == undefined) // There is only one checkbox i.e. there is no array (possible in dynamic arrays)
		{
			if( fieldRef.checked )
			{
				if( fieldRef.parentNode.className.indexOf( MISSING_INPUT_CLASSNAME )!=-1 )
				{
					fieldRef.parentNode.className = fieldRef.parentNode.className.split( MISSING_INPUT_CLASSNAME ).join('');
				}
				return false;
			}
			else
			{
				fieldRef.parentNode.className += MISSING_INPUT_CLASSNAME;
				if( doFocus )
				{
					if( null!=fieldRef.focus )
						fieldRef.focus();
						
				}
				return true;
			}
		}
		else // There is more than one checkbox
		{
			var OptionSelected = false;

			for( var i=0; i!=fieldRef.length; i++ )
			{
				OptionSelected = OptionSelected || fieldRef[ i ].checked;
			}

			if( OptionSelected )
			{
				if( fieldRef[0].parentNode.className.indexOf( MISSING_INPUT_CLASSNAME )!=-1 )
				{
					fieldRef[0].parentNode.className = fieldRef[0].parentNode.className.split( MISSING_INPUT_CLASSNAME ).join('');
				}
				return false;
			}
			else
			{
				fieldRef[0].parentNode.className += MISSING_INPUT_CLASSNAME;
					if( doFocus )
				{
					if( null!=fieldRef[0].focus )
						fieldRef[0].focus();
				}
				return true;
			}
		}
	}


	//Random password generator- by javascriptkit.com
	//Visit JavaScript Kit (http://javascriptkit.com) for script
	//Credit must stay intact for use
	
	var keylist="abcdefghijklmnopqrstuvwxyz123456789"
	var temp=''
	
	function generatepass(plength)
	{
		temp=''
		for (i=0;i<plength;i++)
		{
			temp+=keylist.charAt(Math.floor(Math.random()*keylist.length))
		}
		return temp
	}
	
// --></SCRIPT>
