<!--
/*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 hiding formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function NameOrgFldformat_onblur( oFld ){
	if( oFld.value == "Name of organisation here" ){ oFld.value = ""; }
}

/* func for displaying formatting 'edit-mask' in cost field to indicate to user what format data should be in*/
function NameOrgFldformat_onfocus( oFld ){
	if( oFld.value == "" ){ oFld.value = "Name of organisation here"; } 
	oFld.select();
}

/* 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 ){ 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_onfocus( oFld, sFldFmtTxt ){ if(oFld.value == ""){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 reStr = new RegExp( "^[0-9]{2}\.{1}[0-9]{2}$" );						//reg exp for checking if user already entered decimal point
	var bIsStrValid = reStr.test( timeVal );						//check if user already entered decimal point

	if( !bIsStrValid ){ timeVal = "00:00"; }

	var sHrs = timeVal.substr(0, 2);
	var sMins = timeVal.substr(3, 4);
	
	if( parseInt(sHrs, 10) > 24 ){ sHrs = 24; }
	if( parseInt(sMins, 10) > 60 ){ sMins = 60; }	
	
	timeVal = sHrs + ":" + sMins;
	
	return timeVal;
}
//-->