<!--
	
	function validate(formName,str)
	{
		/*
			The validation string is passed in the following format: '0,4,2;1,1,2;6,1'
			Each form element is semicolon delimited, with the 1st value of each representing its position within the form object
			and the remaining values representing the validation checks to be made.
			For example, 'element, check, check ; element, check'
			
			The string must 1st be broken into an array containing the elements details
		*/
		var msg;
		var fieldArray = str.split(';');
		for(i=0; i<fieldArray.length; i++)
		{
			/*
				Whilst looping through the array, break each value into an array
				Using the formName and the elements numerical position within the form object
				assign the form elements object to the variable field
				then loop through the values of the array (starting at i=1 to skip the elements value)
				using the check value in a switch to determine which check to make.
			*/
			var checkArray = fieldArray[i].split(',');
			field = document.forms[formName][checkArray[0]];
			for(n=1; n<checkArray.length; n++)
			{
				
				if(field)
				{
					
					/*
						Used for tabs to display the tab containing the field in question.
					*/
					fieldset = document.getElementById(field.id).parentNode.parentNode.parentNode;
					if(window.fieldset)
					{
						if(fieldset.tagName == 'FIELDSET')
						{
							fieldsetId = fieldset.id
							toggleTabs(fieldsetId,'');
						}
					}
					/*
					
					*/
					switch(checkArray[n])
					{
						/*
							Empty check - Text fields
						*/
						case '1':
							if(field.value.length <= 0)
							{
								alert(field.title + ': Empty');
								if(window.field)
									field.focus(); //field.select(); - Not required as field will be empty
								return false;
							}
							break;
						
						/*
							Empty check - Selects
						*/
						case '1.1':
							if (field.value <= 0)
							{
								field.focus();
								//alert(field.title + ': Please select an option');
								return false;
							}
							break;
						 
						/*
							Email validation
						*/
						case '2':
							re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
							if(!re.test(field.value))
							{
								alert(field.title + ': Invalid email address');
								field.focus(); field.select();
								return false;
							}
							break;
							
						/*
							URL check
						*/
						case '3':
							re = /^http:\/\//;
							if(!re.test(field.value) && field.value)
							{
								alert(field.title + ": Must start with 'http://'");
								field.focus(); field.select();
								return false;
							}
							break;
							
					
					}
				}
			}
		}
	}

	/*
	
	*/
	function wordCount(formItem,maxNum)
	{
		strTextValue = document.getElementById(formItem).value;
		strTextValue = strTextValue.replace(/^\s+/, '').replace(/\s+$/, '');
		var strSplit = strTextValue.split(/\s+/g);
		var intWordCount = strSplit.length;
		if (intWordCount > maxNum)
		{
			alert('Only '+maxNum+' words allowed');
			formItem.focus();
			return false
		}
	}
	
	/*
	
	*/
	function charCount(formItem,maxNum,dipslayAlert)
	{
		strTextLength = document.getElementById(formItem).value.length;
		if (strTextLength > maxNum)
		{
			if(dipslayAlert)
			{
				alert('Only '+maxNum+' characters allowed');
			}
			document.getElementById(formItem).value = document.getElementById(formItem).value.substring(0,maxNum);
			document.getElementById(formItem).focus();
		}
	}

/*
				case '3': // May only contain specified characters
					echo "
					re = /^(".$value[2].")*$/;
					if(!re.test($form_name.$key.value)) {
						alert('".$field_name.": Invalid characters'); 
						$form_name.$key.focus(); $form_name.$key.select(); return false;
					}";
					break;
				case '4': // Numbers only
					echo "
					re = /^\d+$/;
					if(!re.test($form_name.$key.value)) {
						alert('".$field_name.": Only numbers allowed'); 
						$form_name.$key.focus(); $form_name.$key.select(); return false;
					}";
					break;
				case 'a': // Min length
					echo "
					if ($form_name.$key.value.length < 6) {
						alert('".$field_name.": Min 6 characters'); $form_name.$key.focus(); return false;
					} else if ($form_name.$key.value.length > 15) {
						alert('".$field_name.": Max 15 characters'); 
						$form_name.$key.focus(); $form_name.$key.select(); return false;
					}";
					break;
				case 'b': // Matching passwords
					echo "
					if (document.getElementById('password').value != document.getElementById('password_confirm').value) {
						alert('Passwords do not match, please re-enter them');
						document.getElementById('password').value = '';
						document.getElementById('password_confirm').value = '';
						document.getElementById('password').focus();
						return false;
					}";
					break;
*/
	
-->