<!--
	
	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)
							{
								alert(field.title + ': Please select an option');
							
								if(field.style.visibility == 'hidden')
								{
									element = document.getElementById(field.name + 'Select');
									if(element)
									{
										element.focus();
									}
								} 
								else
								{
									field.focus();
								}
								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();
		}
	}
	
-->