<!--
/* -------------------------------------------------------------------------- */

function checkForm() 
	
	{

	var theTags=checkForm.arguments;
	var theForm=theTags[0];
	var elementHiLite=0;
	
	ErrorMSG = "Some of the required fields have been left empty, fields requiring attention have been highlighted in light blue.\n\n";
	ErrorMSG2 = "";
	
	// Repeat for each form element in "theTags", excluding the first [form name]
	for (i=1; i<(theTags.length); i=i+2)
		{
			var j = i + 1
			
			// Create a local variable with the form element name
			var theElement=theTags[i];
			
			// Create a local variable with the type of check
			var theChecker=theTags[j];
			
			// split the incoming parameter into an array based on the presne ceof the '-' character
			action = theChecker.split("-");
			
			document.forms[theForm].elements[theElement].style.background='#FFFFFF';
			
			// if the field is required then check that it contains data then set the ToCheck varaible to the type to check	
			if(action[0] == "R")
				{
					if(document.forms[theForm].elements[theElement].value == "")
						{
							if(elementHiLite == 0)
								{
									elementHiLite=theTags[i];
								}

							document.forms[theForm].elements[theElement].style.background='#C5D3E0';
						}
					
					var ToCheck = action[1];
				}
			else
				{
					var ToCheck = action[0];
				}


					
			switch(ToCheck)
				{
					case "NUM":
					
					if(document.forms[theForm].elements[theElement].value != "")
						{
							fieldName = (document.forms[theForm].elements[theElement].name);
						
							if(isNaN(document.forms[theForm].elements[theElement].value))
								{
									ErrorMSG2 += "  - ";
									ErrorMSG2 += "Not a valid number:\n";
									
								if(elementHiLite == 0)
									{
										elementHiLite=theTags[i];
									}
								
									document.forms[theForm].elements[theElement].style.background='#C5D3E0';
								}
						}
						
					break;

					case "EMAIL":
					
					if(document.forms[theForm].elements[theElement].value != "")
						{
							// check if @ or the '.' is missing
							if(document.forms[theForm].elements[theElement].value.indexOf('@') == -1 || document.forms[theForm].elements[theElement].value.indexOf('.') == -1)
								{
									ErrorMSG2 += "  - ";
									ErrorMSG2 += "Email format incorrect.     try: me@domain.com.au\n";
									
									if(elementHiLite == 0)
										{
											elementHiLite=theTags[i];
										}
									document.forms[theForm].elements[theElement].style.background='#C5D3E0';
								}
						}
						
					break;

					case "URL":
					
					if(document.forms[theForm].elements[theElement].value != "")
						{
							// check if http:// or the '.' is missing
							if(document.forms[theForm].elements[theElement].value.indexOf('http://') == -1)
								{
									ErrorMSG2 += "  - ";
									ErrorMSG2 += "URL format incorrect.       try: http://www.domain.com.au\n";
									
									if(elementHiLite == 0)
										{
											elementHiLite=theTags[i];
										}
									document.forms[theForm].elements[theElement].style.background='#C5D3E0';
								}
						}
					
					break;

					case "PHONE":
					
					if(document.forms[theForm].elements[theElement].value != "")
						{
							// check if '(' or the ')' is missing
							if(document.forms[theForm].elements[theElement].value.indexOf('(') == -1 || document.forms[theForm].elements[theElement].value.indexOf(')') == -1)
								{
									ErrorMSG2 += "  - ";
									ErrorMSG2 += "Phone format incorrect.    try: (08)/(+61) 9555 1234\n";
									
									if(elementHiLite == 0)
										{
											elementHiLite=theTags[i];
										}
									document.forms[theForm].elements[theElement].style.background='#C5D3E0';
								}
						}
						
					break;

					case "TEXT":
					
					if(document.forms[theForm].elements[theElement].value != "")
						{
							fieldName = (document.forms[theForm].elements[theElement].name);
						
							if(!isNaN(document.forms[theForm].elements[theElement].value))
								{
									ErrorMSG2 += "  - ";
									ErrorMSG2 += fieldName.toUpperCase();
									ErrorMSG2 += " is not text\n";
									
								if(elementHiLite == 0)
									{
										elementHiLite=theTags[i];
									}
								
									document.forms[theForm].elements[theElement].style.background='#C5D3E0';
								}
						}
						
					break;

					case "MONEY":
					
					if(document.forms[theForm].elements[theElement].value != "")
						{
							// check if '$' is missing
							if(document.forms[theForm].elements[theElement].value.indexOf('$') == -1)
								{
									ErrorMSG2 += "  - ";
									ErrorMSG2 += "Money format incorrect.    try: $8594.83\n";
									
									if(elementHiLite == 0)
										{
											elementHiLite=theTags[i];
										}
									document.forms[theForm].elements[theElement].style.background='#C5D3E0';
								}
						}
						
					break;
	
				}
		}
	
	if(elementHiLite == 0)
		{
				return true;
		}
	else
		{
			if(ErrorMSG2 != "")
				{
					ErrorMSG += "In addition the following fields have been flagged as containing errors:\n\n";
					ErrorMSG += ErrorMSG2;
				}
				
			alert(ErrorMSG);
		
			document.forms[theForm].elements[elementHiLite].focus();

			return false;
		}
	} 


/* -------------------------------------------------------------------------- */
//-->