function isValidMoney(the_input)
{	  
	  var valid_amount = true;
	  var amount_money = the_input.value;
	  
	  //RegExp to see if the input contains a decimal point
	  var decimalPoint 	   	 = /[.]/;
	  
	  if (decimalPoint.test(amount_money) == false)
	  {//Has no decimal point so...
		   if(isNaN(amount_money))
		   {//no decimal point and not a number
		   		valid_amount = false;
		   }
		   else
		   {//no decimal point but is a number
		   	   	if (amount_money.length <= 5 && amount_money != "") 
				{//Makes sure it is less than 5 digits long as the ".00"
				 //would have made up the last 3 digits, then converts  
				 //by adding the ".00"
				 	amount_money = amount_money + ".00"
				}
				else
				{//number too long i.e. greater than £99999
				 	valid_amount = false;
				}
		   }
	  }
	  
	  //Regular Expressions
	  var units_re	  		 = /\d[.]\d\d/;
	  var tens_re 			 = /\d\d[.]\d\d/;
	  var hundreds_re 		 = /\d\d\d[.]\d\d/;
	  var thousands_re 		 = /\d\d\d\d[.]\d\d/;
	  var tenThousands_re 	 = /\d\d\d\d\d[.]\d\d/;
	  
	  switch(amount_money.length)
	  {
	  case 0: amount_money = "";
	  	   	  break;
	  case 4: valid_amount = (units_re.test(amount_money));
	  	   	  break;			  
	  case 5: valid_amount = (tens_re.test(amount_money));
	  	   	  break;
	  case 6: valid_amount = (hundreds_re.test(amount_money));
	  	   	  break;
	  case 7: valid_amount = (thousands_re.test(amount_money));
	  	   	  break;
	  case 8: valid_amount = (tenThousands_re.test(amount_money));
	  	   	  break;			  
	  }
	  
	  if (valid_amount == false)
	  {
	   	 	if (amount_money != "")
			{
			   		alert (amount_money + " is not a valid amount of\n" +
						  				  "money for this application.")
			   		amount_money = ""
					the_input.focus();
			}
	  }
	  	  
	  the_input.value = amount_money;
	  return true;
}

	var cP = navigator.appName;
	
	function click() 
  	{
     		// stop users right clicking
     		// no error message on Net browsers
     		if (cP=='Microsoft Internet Explorer')
     		{
       			if (event.button==2)
       			{	
         			str = "Unauthorized Reproduction Prohibited.";
         			str = str + "";
         			str = str + "";
         			alert (str);
        		}
     		}
  	}
  	
function onKeyPress ()
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if (keycode == 13)
	{
			  alert("Please click on the submit button to send the\n" +
			  "application.\n\n" +
			  "(Or use the tab key to move through the form.)");
			return false
	}
		
	return true 
}

document.onkeypress = onKeyPress;		
document.onmousedown = click;

function checkFields_onsubmit(thisform)
{	
		var x; //x is each ELEMENT in the form.
		for(x = 0;x <= thisform.elements.length -1; x++)
		 {
					if(thisform[x].value == "" && thisform[x].cmt != "optional")
					{
						alert("Please enter a value for " + thisform[x].cmt);
						thisform[x].focus();
						return false;
					}
		 }
		 
		 return true;
}

function maxInTextArea(obj)
{
 	   if(obj.value.length > 50)
	   {
	   		 alert("The value inputted is too long")
	   		 obj.select();
			 return false;
	   }
	   
	   return true;
}