
/*
Function force_numeric($value)
 Accepts a string and returns only numeric parts of that string, only returns first decimal point found. 

Typical usage:

<script language="javascript" src="/javascript/force_date.js" type="text/javascript"></script>

<form name="form1">
 <input type="text" name="test" id = "test1" onChange="this.value = force_date(this.value);"> 
</form>


*/

function check_time($val) {
  if ($val.length > 0) {
	  x = new Date($val)
	  if (isNaN(x.getUTCHours()))
	   {
	   alert("I did not understand the time you entered")
	   return ""
	   }
	   
	  str_hr = "00" + (x.getUTCHours()+1)
	  str_hr = str_hr.substring(str_hr.length -2)
	  str_min = "00"  + x.getUTCMinutes()
	  str_min = str_min.substring(str_min.length -2)
	
	  $output = str_hr+":"+str_min
	  alert($output)
	 return $output
 }

 }

function force_time($ref) {
  
  	  
  if ($ref.value.length > 0) {
	  if ($ref.value.length < 3)
	  	{
			$ref.value = $ref.value + ":00"
		}
	  if ($ref.value.indexOf(":") == -1)
	  	{
			// stick a colon 2 characters from the end
			$ref.value = $ref.value.substring(0,$ref.value.length -2) + ":" + $ref.value.substring($ref.value.length -2, $ref.value.length)
		}
	  		
	  x = new Date("01/01/2000 " + $ref.value)
	  if (isNaN(x.getUTCMonth()))
	   {
	   alert("I did not understand the time you entered")
	   // push focus back onto the textbox
	   $ref.focus()
	   return false
	   }
	  if (x.getUTCFullYear() < 1990)
		if (x.getUTCFullYear() > 1900)
		   x.setFullYear(x.getUTCFullYear()+100)
		   
	  str_hr = "00" + (x.getHours())
	  str_hr = str_hr.substring(str_hr.length -2)
	  str_min = "00"  + x.getMinutes()
	  str_min = str_min.substring(str_min.length -2)
	
	  $output = str_hr+":"+str_min
	  
	  $ref.value = $output

	// return $output
 }

 }
