<!--
/* function for checking the maxlength of a textarea */
function TextAreaChanged(objTextArea, lngMaxLength){
	var strTemp = objTextArea.value;
	
	if( strTemp.length > lngMaxLength ){
		objTextArea.value = strTemp.substr(0, lngMaxLength);
	}
}

/*func for validating time fields*/
function validateTimeFld( oFld ){
	checkNumPositive( oFld );
	addZeroBeforeDecPoint( oFld );
	addTrailingZero( oFld );
	getRidOfExtraDecPoint( oFld );
	oFld.value = roundTwoDecimalPlaces( oFld.value );
	checkForMaxTimeValue( oFld );
}

/*func for validating cost fields*/
function validateRateFld( oFld ){
	checkNumPositive( oFld );
	addZeroBeforeDecPoint( oFld );
	addTrailingZero( oFld );
	getRidOfExtraDecPoint( oFld );
	oFld.value = roundTwoDecimalPlaces( oFld.value );
	checkForMaxRateValue( oFld );
}

/*func for validating cost fields*/
function validateCostFld( oFld ){
	checkNumPositive( oFld );
	addZeroBeforeDecPoint( oFld );
	addTrailingZero( oFld );
	getRidOfExtraDecPoint( oFld );
	oFld.value = roundTwoDecimalPlaces( oFld.value );
}

/*function for preventing user from entering any value greater than 9999.99 into time field*/
function checkForMaxTimeValue( oFld ){
	if( parseFloat(oFld.value,10) > 9999.99){
		oFld.value = 9999.99;
		oFld.select();
		oFld.focus();
	}
}

/*function for preventing user from entering any value greater than 999.99 into rate field*/
function checkForMaxRateValue( oFld ){
	if( parseFloat(oFld.value,10) > 9999.99){
		oFld.value = 9999.99;
		oFld.select();
		oFld.focus();
	}
}

/*func for checking num is positive*/
function checkNumPositive( oFld ){
	if( parseInt(oFld.value, 10) < 0 ){ oFld.value = 0; }
}

/*func for getting-rid of (unnecessarray) trailing decimal points at the end of a number (e.g. turn "1." into "1")*/
function getRidOfExtraDecPoint( oFld ){
	var reStr = new RegExp( "[\.]{1}$" );						//reg exp for checking if user already entered decimal point
	var bIsStrValid = reStr.test( oFld.value );						//check if user already entered decimal point

	if( bIsStrValid ){ oFld.value = oFld.value.replace(".", ""); }
}

/*func to add leading zero to decimal fraction that has no leading zero 
	- e.g. convert ".1" into "0.1" or ".25" into "0.25"*/
function addZeroBeforeDecPoint( oFld ){
	var sTmp = oFld.value;
	var reStr = new RegExp( "^[\.]{1}[0-9]+$" );
	var bIsStrValid = reStr.test( oFld.value );
	
	if( bIsStrValid ){ oFld.value = "0" + sTmp; }
}

function addTrailingZero( oFld ){
	var sTmp = oFld.value;
	var reStr = new RegExp( "[\.]{1}[0-9]{1}$" );
	var bIsStrValid = reStr.test( oFld.value );
	
	if( bIsStrValid ){ oFld.value = sTmp + "0"; }
}

/*func for rounding fld floating point value to 2 decimal places*/
function roundTwoDecimalPlaces( fVal ){
		var fFormattedVal;			
		var iDecPoint = 0;								//var for storing location of decimal point
		var sVal = fVal.toString();

		//if number is written in exponential notation, break-out of this function now//
		if( sVal.search("e") != -1 ){ return fVal; }
	
		//get position of decimal piont//
		for( var x=0; x<sVal.length; x++){
			if( sVal.charAt(x) == "." ){
				iDecPoint = x;
				break;
			}
		}
		
		//get rid of any decimal places, beyond the first two//
		if( iDecPoint > 0 ){
			fFormattedVal = sVal.substr(0, (iDecPoint+3));
			return fFormattedVal;
		}
		else{
			return fVal;
		}
}

function txtAreaFldMaxLen( oTxtAr, iMaxLen ){
	if( oTxtAr.value.length > iMaxLen ){
		oTxtAr.value = oTxtAr.value.substr(0, oTxtAr.value.length-1);
	}
}

/* func for displaying 'edit-mask' in time field to indicate to user what format data should be in*/
function timeFldformat_onfocus( oFld ){
	if( oFld.value == "" ){ oFld.value = "xxxx.yy"; } 
	oFld.select();
}

/* func for hiding 'edit-mask' in time field to indicate to user what format data should be in*/
function timeFldformat_onblur( oFld ){
	if( oFld.value == "xxxx.yy" ){ oFld.value = ""; }
}

/* func for displaying 'edit-mask' in rate field to indicate to user what format data should be in*/
function rateFldformat_onfocus( oFld ){
	if( oFld.value == "" ){ oFld.value = "xxx.yy"; } 
	oFld.select();
}

/* func for hiding 'edit-mask' in rate field to indicate to user what format data should be in*/
function rateFldformat_onblur( oFld ){
	if( oFld.value == "xxx.yy" ){ oFld.value = ""; }
}

/* func for displaying formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function costFldformat_onfocus( oFld ){
	if( oFld.value == "" || oFld.value == "0" ){ oFld.value = "xxxxxxx.yy"; } 
	oFld.select();
}

/* func for hiding formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function costFldformat_onblur( oFld ){
	if( oFld.value == "xxxxxxx.yy" ){ oFld.value = ""; }
}

/* func for displaying formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function DateFldformat_onfocus( oFld ){
	if( oFld.value == "" ){ oFld.value = "dd/mm/yyyy"; } 
	oFld.select();
}

/* func for hiding formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function DateFldformat_onblur( oFld ){
	if( oFld.value == "dd/mm/yyyy" ){ oFld.value = ""; }
}

/* func for displaying formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function IncidentTimeFldformat_onfocus( oFld ){
	if( oFld.value == "" ){ oFld.value = "hh:mm"; } 
	oFld.select();
}

/* func for hiding formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function IncidentTimeFldformat_onblur( oFld ){
	if( oFld.value == "hh:mm" ){ oFld.value = ""; }
}

/* func for displaying formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function NameCmpnyFldformat_onfocus( oFld ){
	if( oFld.value == "" ){ oFld.value = "Name of company here"; } 
	oFld.select();
}

/* func for hiding formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function NameCmpnyFldformat_onblur( oFld ){
	if( oFld.value == "Name of company here" ){ oFld.value = ""; }
}

/* func for displaying formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function PlaceOfIncidentFldformat_onfocus( oFld ){
	if( oFld.value == "" ){ oFld.value = "Place of incident here"; } 
	oFld.select();
}

/* func for hiding formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function PlaceOfIncidentFldformat_onblur( oFld ){
	if( oFld.value == "Place of incident here" ){ oFld.value = ""; }
}

/* func for displaying formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function NamePersonInvFldformat_onfocus( oFld ){
	if( oFld.value == "" ){ oFld.value = "Name of person involved here"; } 
	oFld.select();
}

/* func for hiding formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function NamePersonInvFldformat_onblur( oFld ){
	if( oFld.value == "Name of person involved here" ){ oFld.value = ""; }
}

/* func for displaying formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function NamePersonCmpltdFldformat_onfocus( oFld ){
	if( oFld.value == "" ){ oFld.value = "Name of person completing form here"; } 
	oFld.select();
}

/* func for hiding formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function NamePersonCmpltdFldformat_onblur( oFld ){
	if( oFld.value == "Name of person completing form here" ){ oFld.value = ""; }
}

/* func for displaying formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function PosOfPersonFldformat_onfocus( oFld ){
	if( oFld.value == "" ){ oFld.value = "Position of person here"; } 
	oFld.select();
}

/* func for hiding formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function PosOfPersonFldformat_onblur( oFld ){
	if( oFld.value == "Position of person here" ){ oFld.value = ""; }
}

/* func for displaying formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function DscrFldformat_onfocus( oFld, sVal ){
	if( oFld.value == "" ){ 
		if( sVal != "" ){ oFld.value = "Description of " + sVal + " here..."; }
		else{ oFld.value = "Description here.."; }
	}
	oFld.select();
}

/* func for hiding formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function DscrFldformat_onblur( oFld, sVal ){
	if( sVal != "" ){
		if( oFld.value == "Description of " + sVal + " here..." ){ oFld.value = ""; }
	}
	else{
		if( oFld.value == "Description here.." ){ oFld.value = ""; }
	}
}



/*func for hiding formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function fldFormatTxt_onblur( oFld, sFldFmtTxt, sNullVal ){ if(oFld.value == sFldFmtTxt || oFld.value == ""){oFld.value = sNullVal;} }

/*func for displaying formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function fldFormatTxt_onfocus( oFld, sFldFmtTxt, sNullVal ){ if(oFld.value == "" || oFld.value == sNullVal){oFld.value = sFldFmtTxt;} oFld.select(); }

/*func for displaying formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function fldFormatTxt_onmousedown( oFld, sFldFmtTxt ){ if(oFld.value == sFldFmtTxt){oFld.value = "";} }

/*func for displaying formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function fldFormatTxt_onkeydown( oFld, sFldFmtTxt ){ if(oFld.value == sFldFmtTxt){oFld.value = "";} }

/*func for validatig time fields*/
function validateTime( timeVal ){
	var reStr1 = new RegExp( "^[0-9]{2}.{1}[0-9]{2}$" );						//reg exp for checking if user already entered decimal point
	var bIsStrValid1 = reStr1.test( timeVal );						//check if user already entered decimal point
	var reStr2 = new RegExp( "^[0-9]{1}.{1}[0-9]{2}$" );						//reg exp for checking if user already entered decimal point
	var bIsStrValid2 = reStr2.test( timeVal );						//check if user already entered decimal point	
	var reStr3 = new RegExp( "^[0-9]{2}.{1}[0-9]{1}$" );						//reg exp for checking if user already entered decimal point
	var bIsStrValid3 = reStr3.test( timeVal );						//check if user already entered decimal point
	var reStr4 = new RegExp( "^[0-9]{1}.{1}[0-9]{1}$" );						//reg exp for checking if user already entered decimal point
	var bIsStrValid4 = reStr4.test( timeVal );						//check if user already entered decimal point	

	if( bIsStrValid1 ){			
		var sHrs = timeVal.substr(0, 2);
		var sMins = timeVal.substr(3, 4);
	}
	else if( bIsStrValid2 ){			
		var sHrs = "0" + timeVal.substr(0, 1);
		var sMins = timeVal.substr(2, 3);
	}
	else if( bIsStrValid3 ){			
		var sHrs = timeVal.substr(0, 2);
		var sMins = "0" + timeVal.substr(3, 3);
	}
	else if( bIsStrValid4 ){			
		var sHrs = "0" + timeVal.substr(0, 1);
		var sMins = "0" + timeVal.substr(2, 2);
	}
	else{
		timeVal = "";
		return "";
	}
	
	if( parseInt(sHrs, 10) > 23 ){ sHrs = "24"; }
	if( parseInt(sMins, 10) > 59 ){ sMins = "60"; }	
	
	timeVal = sHrs + ":" + sMins;
	
	return timeVal;
}

//--------------------------------------------------------------------------------
// Purpose		Removes the leading and trailing spaces from a text string
//	
// Parameters		strData - text string
//
// Returns 		Empty string (Nothing)
//			Populated string (Success) - String contains no leading or
//			trailing spaces.			
//
// History		PA 20-Nov-2002 v0.1 (Created) 
//
// Comment		Cross Browser Version. NS6.2.3, NS7,IE5x
//			Dependencies are trimleft, trimright
//--------------------------------------------------------------------------------
function trimstring(strData)
{
 var strcontent = "";
 var strEmpty = "";

	strcontent = trimleft(strData);

	if(strcontent!="") 
	{ 
		strcontent = trimright(strcontent); 
		return(strcontent);
	}
	else
	return(strEmpty);
}

//--------------------------------------------------------------------------------
// Purpose		Removes the leading spaces from a text string 
//	
// Parameters		strData - text string
//
// Returns 		Empty string (Nothing)
//			Populated string (Success) - String contains no leading 
//			spaces.				
//
// History		PA 20-Nov-2002 v0.1 (Created) 
//
// Comment		Cross Browser Version. NS6.2.3, NS7,IE5x
//			Dependencies are trimright, trimstring
//--------------------------------------------------------------------------------
function trimleft(strData)
{
var j;
var strValue = "";
var strEmpty = "";

	//cycle through the string and remove the leading spaces and trailing spaces
	// leading first.

	for (j=0; j<strData.length; j++)
	{
	strValue = strData.charAt(j);                  
	if(strValue!=" ") 
		{
		  return(strData.substr(j));
		}
	}
	return(strEmpty);
}

//--------------------------------------------------------------------------------
// Purpose		Removes the trailing spaces from a text string
//	
// Parameters		strData - text string
//
// Returns 		Empty string (Nothing)
//			Populated string (Success) - String contains no trailing 
//			spaces.				
//
// History		PA 20-Nov-2002 v0.1 (Created) 
//
// Comment		Cross Browser Version. NS6.2.3, NS7,IE5x
//			Dependencies are trimleft, trimstring
//--------------------------------------------------------------------------------
function trimright(strData)
{
var j;
var intValue;
var strEmpty = "";
var intStart; 
	
	//Find the end of the string
	for (j=strData.length;j>-1;j--)
	{
		if(!isNaN(strData.charCodeAt(j)))
		{
			intStart = j;
			break; 
		}
	}
	
	for (j=intStart; j>-1; j--)
	{
	intValue = strData.charCodeAt(j);                 
	if(intValue!=32) 
		{
		  return(strData.substr(0,j+1));
		}
	}
	return(strEmpty);
}

//-->