//<script>
/******************************************************************************
* NAME: CValidate()
* AUTH: Paul Kersey - eClaims
* DATE: 04/20/2004
*
* DESC: This JavaScript class will handle form validations.  This will be used
*		as a base class for form validation classes.
* MODS: 
*		1- Added AllTrims  - Shawn Hamzee 20/7/04
*							 See descriptions below for details
******************************************************************************/
function CValidate()
{
	// data members
	this.errorList			= new Array();				// Array of error messages
	this.genericMsg;									// Standard error message
	
	// member functions
	this.Errors					= Errors;					// Returns number of errors
	this.RaiseError				= RaiseError;				// Raise an error message on a form
	this.DisplayErrors			= DisplayErrors;			// Displays form errors
	this.ReqFieldValidator		= ReqFieldValidator;		// Checks for a value in field object
	this.RangeValidator			= RangeValidator;			// Checks range of field object
	this.DateRangeValidator		= DateRangeValidator;		// Checks date range of field object
	this.DropDownListValidator	= DropDownListValidator;	// Checks drop-down list box for value
	this.IsBlankForm			= IsBlankForm;				// Checks if form is blank
	this.IsChecked				= IsChecked;				// Checks if field object is checked
	this.IsRadioChecked			= IsRadioChecked;			// Checks if a radio field object is checked		
	this.IsDate					= IsDate;					// Checks if value is a date
	this.IsZeroPaddedDate		= IsZeroPaddedDate;			// Checks if a date is using format mm/dd/yyyy (zero padded)
	this.IsTime					= IsTime;					// Checks if a value is a valid time
	this.IsValidTime			= IsValidTime;				// Checks if a value is a valid time (military and standard)
	this.IsNumeric				= IsNumeric;				// Checks if value is numeric
	this.IsAlphabetic			= IsAlphabetic;				// Checks if value is alphabetic
	this.IsAlphaNumeric			= IsAlphaNumeric;			// Checks if value is alphanumeric
	this.IsAlphaNumericSpace	= IsAlphaNumericSpace;		// Checks if value is alphanumeric or space
	this.IsEmailAddress			= IsEmailAddress;			// Checks if value is a valid email address
	this.IsNull					= IsNull;					// Checks to see if value is null
	this.IsKeyEventChar			= IsKeyEventChar;			// Checks to see if key event is a character
	this.IsKeyEventNumeric		= IsKeyEventNumeric;		// Checks to see if key event is a number
	this.IsKeyEventAlpha		= IsKeyEventAlpha;			// Checks to see if key event is a alphanumeric
	this.validateDate			= validateDate;				// verify date
	this.formatTime				= formatTime;				// verify time
	this.IsPolicyVerified		= IsPolicyVerified;			// check to see if policy has been verified
	this.CheckGISReqFields		= CheckGISReqFields;		// Alert user if required field for making GIS is missing
	this.ResetPolicyVerification= ResetPolicyVerification;	// Alert user to re-verify policy
	this.IsAlliedPolicy			= IsAlliedPolicy;			// Checks if we using an Allied Policy
	
	// trim member functions
	this.StripQuotes		= StripQuotes;
	this.LTrim				= LTrim;					// Returns string with whitespace trimmed
	this.RTrim				= RTrim;
	this.Trim				= Trim;
	this.LTrimAll			= LTrimAll;
	this.RTrimAll			= RTrimAll;
	this.TrimAll			= TrimAll;
	this.AllTrims			= AllTrims;					// Trims newline/CR in the beginning and end of string
														// and mutliple spaces in the middle as well
	this.XMLEncode			= XMLEncode;
	
	// data member initialization and default setting
	this.genericMsg = "Please enter the following information:\n\n"
}

//-----------------------------------------------------------------------------
// NAME: Errors()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Returns number of errors
// MODS: None
//-----------------------------------------------------------------------------
function Errors() { return this.errorList.length; }

//-----------------------------------------------------------------------------
// NAME: RaiseError()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Allows user to specify error message for an invalidation
// MODS: None
//-----------------------------------------------------------------------------
function RaiseError( sMessage ) { this.errorList[this.errorList.length] = sMessage; }

//-----------------------------------------------------------------------------
// NAME: DisplayErrors()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Displays errors listed
// MODS: None
//-----------------------------------------------------------------------------
function DisplayErrors()
{
	try {
		var saErrMsg = new Array(); 
		saErrMsg.push( this.genericMsg );
	
		for (var i = 0; i < this.Errors(); i++) 
			saErrMsg.push( "* " + this.errorList[i] + "\n");

		var sErrMsg = saErrMsg.join('');

		alert(sErrMsg);
		
		// reset error list
		this.errorList.length = 0;  
	}
	catch( exception ) {
		var oError = new CError();
		oError.HandleError( oError.CCC_ERR_VALIDATE, exception.message, "CValidate:DisplayErrors" );
		delete( oError );
	}
	finally {
		delete( saErrMsg );
	}
}

//-----------------------------------------------------------------------------
// NAME: ReqFieldValidator()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Checks to see if field object has a value
// MODS: None
//-----------------------------------------------------------------------------
function ReqFieldValidator( idField )
{
	try {
		if ( typeof idField != "object" ) throw "Object Parameter Expected";
		
		return(! (idField.value.length == 0) || (idField.value == null) );
	}
	catch( exception ) {
		var oError  = new CError();
		var sErrMsg = "";
		if ( typeof exception == "object" ? sErrMsg = exception.message : sErrMsg = exception );
		oError.HandleError( oError.CCC_ERR_VALIDATE, sErrMsg, "CValidate:ReqFieldValidator" );
		delete( oError );
		return false;
	}	
	finally {

	}
}

//-----------------------------------------------------------------------------
// NAME: RangeValidator()
// AUTH: Paul Kersey - eClaims	
// DATE: 04/20/2004
//
// DESC: This will validate the range of a given field object
// MODS: None
//-----------------------------------------------------------------------------
function RangeValidator( sValue, vMin, vMax )
{
	try {
		// error checking
		if ( this.IsNull(sValue) || sValue == '' )	throw "Required Parameter Missing";
		if ( this.IsNull(vMin)   || vMin == '' )	throw "Required Parameter Missing";
		if ( this.IsNull(vMax)   || vMax == '' )	throw "Required Parameter Missing";
		
		return( (idField.value >= vMin) && (idField.value <= vMax) ); 
	}
	catch( exception ) {
		var oError  = new CError();
		var sErrMsg = "";
		if ( typeof exception == "object" ? sErrMsg = exception.message : sErrMsg = exception);
		oError.HandleError( oError.CCC_ERR_VALIDATE, sErrMsg, "CValidate:RangeValidator" );
		delete( oError );
		return false;
	}
	finally {

	}
}

//-----------------------------------------------------------------------------
// NAME: DateRangeValidator()
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: This will validate two given dates fall within acceptable ranges
// MODS: None
//-----------------------------------------------------------------------------
function DateRangeValidator( sValue, vMin, vMax )
{
	try {
		// error checking
		if ( this.IsNull(sValue) || sValue == '')	throw "Required Parameter Missing";
		if ( this.IsNull(vMax) || vMax == '' )		throw "Required Parameter Missing";
		if ( this.IsNull(vMin) || vMin == '' )		throw "Required Parameter Missing";
		
		// local variable declarations
		var bResult         = false;
		var oCompareDate	= new Date(sValue);
		oCompareDate.setHours( 0, 0, 0, 0 );
		var oMaxDate		= new Date(vMax);
		oMaxDate.setHours( 0, 0, 0, 0 );
		var oMinDate		= new Date(vMin);
		oMinDate.setHours( 0, 0, 0, 0 );
		
		bResult = ((oCompareDate >= oMinDate) && (oCompareDate <= oMaxDate));
		
		delete( oCompareDate );
		delete( oMaxDate );
		delete( oMinDate );
		
		return bResult; 
	
	}
	catch( exception ) {
		var oError  = new CError();
		var sErrMsg = "";
		if ( typeof exception == "object" ? sErrMsg = exception.message : sErrMsg = exception);
		oError.HandleError( oError.CCC_ERR_VALIDATE, sErrMsg, "CValidate:DateRangeValidator" );
		delete( oError );
	}
	finally {

	}
}

//-----------------------------------------------------------------------------
// NAME: DropDownListValidator()	
// AUTH: Sheri Jones
// DATE: 5/2004
//
// DESC: Verifies the user has selected one value in the drop-down box that 
//			isn't set to a zero-length string.
// MODS: None
//-----------------------------------------------------------------------------
function DropDownListValidator( idField ){
	
	try {
		
		if ( idField.options[idField.selectedIndex].value == "" ){
			return false;	
		}else{
			return true;
		}
	
	} catch( exception ){	
		var oError  = new CError();
		var sErrMsg = "";
		if ( typeof exception == "object" ? sErrMsg = exception.message : sErrMsg = exception);
		oError.HandleError( oError.CCC_ERR_VALIDATE, sErrMsg, "CValidate:DropDownListValidator" );
		delete( oError );
	}
}


//-----------------------------------------------------------------------------
// NAME: IsBlankForm()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Checks to see if the form is blank
// MODS: None
//-----------------------------------------------------------------------------
function IsBlankForm( oFrm )
{
	try {
		// error checking
		if ( typeof oFrm != "object" ) throw "Object Parameter Expected";
		
		for ( var i = 0; i < oFrm.elements.length; i++ )  {
			if ( oFrm.elements[i].value != "" )  return false;
		}

		return true;
	}
	catch( exception ) {
		var oError  = new CError();
		var sErrMsg = "";
		if ( typeof exception == "object" ? sErrMsg = exception.message : sErrMsg = exception );
		oError.HandleError( oError.CCC_ERR_VALIDATE, sErrMsg, "CValidate:IsBlankForm" );
		delete( oError );
	}
	finally {
	
	}
}
	
//-----------------------------------------------------------------------------
// NAME: IsChecked()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Checks to see if field object is checked
// MODS: None
//-----------------------------------------------------------------------------
function IsChecked( idField ) { return( idField.checked ); }


//-----------------------------------------------------------------------------
// NAME: IsRadioChecked()	
// AUTH: Drew Repasky - eClaims
// DATE: 06/09/2004
//
// DESC: Checks to see if a set of radio input fields (sharing the same name)
//			has a field that is checked.
// MODS: None
//-----------------------------------------------------------------------------
function IsRadioChecked( idRadioField )
{
	var i, iTotalButtons;
	iTotalButtons = idRadioField.length;
	
	for( i=0; i<iTotalButtons; i++ )
	{
		if( idRadioField[i].checked )
			return true;
	}
	
	return false;
}


//-----------------------------------------------------------------------------
// NAME: IsDate()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Checks to see if value is a valid date
// MODS: None
//-----------------------------------------------------------------------------
function IsDate( sDate )
{
	if ( sDate.match( /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/ ) ) 
		return true;
	else
		return false;
}


//-----------------------------------------------------------------------------
// NAME: IsZeroPaddedDate()	
// AUTH: Sheri Jones
// DATE: 6/2004
//
// DESC: Checks to see if value is a date in the format mm/dd/yyyy (zero padded)
// MODS: None
//-----------------------------------------------------------------------------
function IsZeroPaddedDate( sDate )
{
	if ( sDate.match( /^(\d{2})(\/|-)(\d{2})(\/|-)(\d{4})$/ ) ) 
		return true;
	else
		return false;
}


//-----------------------------------------------------------------------------
// NAME: IsTime()	
// AUTH: Sheri Jones
// DATE: 5/2004
//
// DESC: Checks to see if value is a valid time
// MODS: None
//-----------------------------------------------------------------------------
function IsTime( sTime ){
	 
	if ( sTime.length < 8 ){
		return false;
	}else{
		if ( sTime.match( /^([012]|[012][0-9]|[012][0-9]\:|[012][0-9]\:[0-5]|[012][0-9]\:[0-5][0-9]|[012][0-9]\:[0-5][0-9]\ |[012][0-9]\:[0-5][0-9]\ [ap]|[012][0-9]\:[0-5][0-9]\ [ap]m)$/i ) )	
			return true;
		else
			return false;
	}
}

//-----------------------------------------------------------------------------
// NAME: IsValidTime()	
// AUTH: Paul Kersey - eClaims
// DATE: 07/19/2004
//-----------------------------------------------------------------------------
// REVISION HISTORY
// Date			Name			Description
// 07/19/2004	Paul Kersey		Initial Creation
//-----------------------------------------------------------------------------
function IsValidTime( timeStr )
{
	var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

	var matchArray = timeStr.match(timePat);

	if (matchArray == null) {
		alert("Time is not in a valid format.");
		return false;
	}

	hour = matchArray[1];	
	minute = matchArray[2];
	second = matchArray[4];
	ampm = matchArray[6];

	if (second=="") { second = null; }
	if (ampm=="") { ampm = null; }

	if (hour < 1  || hour > 12) {
		alert("Hour must be between 1 and 12.");
		return false;
	}

	if (ampm == null) {
			alert("You must specify AM or PM.");
			return false;
	}
	
	if (minute<0 || minute > 59) {
		alert ("Minute must be between 0 and 59.");
		return false;
	}

	if (second != null && (second < 0 || second > 59)) {
		alert ("Second must be between 0 and 59.");
		return false;
	}

	return true;
}

//-----------------------------------------------------------------------------
// NAME: IsNumeric()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Checks to see if value is numeric
// MODS: None
//-----------------------------------------------------------------------------
function IsNumeric( sValue )
{
	var fValue = 1.0 * sValue;
    
    if ( isNaN(fValue) )
		return false;
    else
        return true;
}

//-----------------------------------------------------------------------------
// NAME: CValidate.IsDigits()	
// AUTH: Drew Repasky - eClaims
// DATE: 07/08/2005
//
// DESC: Checks to see if a string value is ALL digits.
//       Note that this is *not* a redundant function for the above
//       CValidate.IsNumeric, which returns true for spaces.
// MODS: None
//-----------------------------------------------------------------------------
CValidate.IsDigits =
function( psValue )
{
	if( psValue.match(/^[\d]+$/) )
		return true;
	else
		return false;
};

CValidate.prototype.IsDigits =
function( psValue )
{
	return CValidate.IsDigits( psValue );
};


//-----------------------------------------------------------------------------
// NAME: IsAlphabetic()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Checks to see if value is alphabetic
// MODS: None
//-----------------------------------------------------------------------------
function IsAlphabetic( sValue )
{
	if (sValue.match(/^[a-zA-Z ]+$/))
		return true;
	else
		return false;
}

//-----------------------------------------------------------------------------
// NAME: IsAlphaNumeric()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Checks to see if value is alphanumeric
// MODS: None
//-----------------------------------------------------------------------------
function IsAlphaNumeric( sValue )
{
	if ( sValue.match(/^[a-zA-Z0-9]+$/) )
		return true;
	else
		return false;
}

//-----------------------------------------------------------------------------
// NAME: IsAlphaNumericSpace()	
// AUTH: Drew Repasky - eClaims
// DATE: 3/18/2006
//
// DESC: Checks to see if value is alphanumeric or space.
// MODS: None
//-----------------------------------------------------------------------------
function IsAlphaNumericSpace( sValue )
{
	if ( sValue.match(/^[a-zA-Z0-9 ]+$/) )
		return true;
	else
		return false;
}

//-----------------------------------------------------------------------------
// NAME: IsEmailAddress()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Checks to see if field object is checked
// MODS: None
//-----------------------------------------------------------------------------
function IsEmailAddress( sValue )
{
	if (sValue == "" ) return true;
	if (sValue.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
        return false;
}

//-----------------------------------------------------------------------------
// NAME: IsNull()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Checks to see if value is null
// MODS: None
//-----------------------------------------------------------------------------
function IsNull( sValue ) { return( sValue == null || sValue =="" || sValue.length == 0 ); }

//-----------------------------------------------------------------------------
// NAME: IsKeyEventChar()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Checks for a valid character typed into form
// MODS: None
//-----------------------------------------------------------------------------
function IsKeyEventChar()
{
	event.returnValue = this.IsAlphabetic( String.fromCharCode(window.event.keyCode) );
}

//-----------------------------------------------------------------------------
// NAME: IsKeyEventNumeric()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Checks for a valid character typed into form
// MODS: None
//-----------------------------------------------------------------------------
function IsKeyEventNumeric()
{
	event.returnValue = this.IsNumeric( String.fromCharCode(window.event.keyCode));
}

//-----------------------------------------------------------------------------
// NAME: IsKeyEventAlpha()	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Checks for a valid character typed into form
// MODS: None
//-----------------------------------------------------------------------------
function IsKeyEventAlpha()
{
	event.returnValue = this.IsAlphaNumeric( String.fromCharCode(window.event.keyCode));
}

//-----------------------------------------------------------------------------
// NAME: StripQuotes()	
// AUTH: Paul Kersey - eClaims
// DATE: 06/07/2004
//
// DESC: Strips quotations from text fields
// MODS: None
//-----------------------------------------------------------------------------
function StripQuotes( sText ) { return sText.replace( /"|'/g, "" ); }

//-----------------------------------------------------------------------------
// NAME: TRIM MEMBER FUNCTIONS	
// AUTH: Paul Kersey - eClaims
// DATE: 04/20/2004
//
// DESC: Returns strings with whitespace trimmed
// MODS: None
//-----------------------------------------------------------------------------
function LTrim( str )
{
	if ( str == null ) { return null; }
	for( var i=0; str.charAt(i)==" "; i++ );
	return str.substring( i, str.length );
}

function RTrim( str )
{
	if ( str == null ) { return null; }
	for( var i=str.length-1; str.charAt(i)==" "; i-- );
	return str.substring( 0, i+1 );
}

function Trim(str){ return LTrim( RTrim( str ) );}

function LTrimAll(str) 
{
	if ( str == null ) { return str; }
	for ( var i=0; str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t"; i++ );
	return str.substring( i, str.length );
}

function RTrimAll( str ) 
{
	if ( str == null ) { return str; }
	for( var i=str.length-1; str.charAt(i)==" " || str.charAt(i)=="\n" || str.charAt(i)=="\t"; i-- );
	return str.substring( 0, i+1 );
}

function TrimAll(str) { return LTrimAll( RTrimAll( str ) ); }


//-----------------------------------------------------------------------------
//Function:		Trim strings 
//Purpose:		Removes leading and trailing spaces from the passed string. Also removes
//				consecutive spaces and replaces it with one space. If something besides
//				a string is passed in (null, custom object, etc.) then return the input.
//Input:		string 
//Ouput:		trimmed out string
//Author:		Shawn Hamzee  7/2004
//Revisions:
//-----------------------------------------------------------------------------
function AllTrims(str) 
{

   if (typeof str != "string") { return str; }

   var retValue = str;
   var ch = retValue.substring(0, 1);

   while (ch == " " || ch == "\r" || ch == "\n") { // Check for spaces, newline or carriage returns at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);

   while (ch == " " || ch == "\r" || ch == "\n") { // Check for spaces, newline or carriage returns at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   
   
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
       
   return retValue; // Return the trimmed string back to the user

}

//-----------------------------------------------------------------------------
// NAME: XMLEncode()	
// AUTH: Drew Repasky - eClaims
// DATE: 08/02/2004
//
// DESC: The XMLEncode method applies XML encoding to a specified string.
//		 Replace "&" with "&amp;", ">" with "&gt;", "<" with "&lt;",
//		 "'" with "&apos;", '"' (double quote) with "&quot;".
// MODS: None
//-----------------------------------------------------------------------------
function XMLEncode( pstrEncode )
{
	var strFixed;
	
	strFixed = pstrEncode;

	strFixed = strFixed.replace( /&/g, "&amp;" );
	
	strFixed = strFixed.replace( />/g, "&gt;" );
	
	strFixed = strFixed.replace( /</g, "&lt;" );
	
	strFixed = strFixed.replace( /'/g, "&apos;" );
	
	strFixed = strFixed.replace( /"/g, "&quot;" );

	return strFixed;
}

//***************************************************************
//FUNCTION:			validateDate()
//DESCRIPTION:
//This will make sure the use enters a valid date in the format mm/dd/yyy
//The allowFuture will allow future dates and, allow past will allow past dates
//Dependents:autoPolicyVerification
//***************************************************************
function validateDate( fieldMonth, fieldDay, fieldYear, allowFuture, allowPast ) {
	if ( fieldMonth.value == "" || fieldDay.value == "" || fieldYear.value == "") return;
	
	//1. validate the date entered is properlly formatted
	var curDate		= new Date;
	var inputDate	= new Date( fieldMonth.value + "/" + fieldDay.value + "/" + fieldYear.value );
	var lossDate	= new Date("01/01/1950");

	if ( isNaN(inputDate) || inputDate.getFullYear().toString().length != 4 || inputDate.getMonth() > 11 || inputDate.getMonth() < 0 ) {
		g_oMessage.HandleAlert(g_oMessage.WARN_DATE_INVALIDDATEFORMAT);
		fieldMonth.value=""; fieldDay.value=""; fieldYear.value=""; fieldMonth.focus();
		return false;
	}

	//Make sure loss date is greater the 	 01/01/1950	
	if ( fieldMonth.name == "efLossDateMonth" && inputDate.getTime() < lossDate.getTime() ) {
		g_oMessage.HandleAlert(g_oMessage.WARN_DATE_INVALIDLOSSDATE);
		fieldMonth.value=""; fieldDay.value=""; fieldYear.value=""; fieldMonth.focus();
		return false;
	}
 
	//2. make sure the date is not in the future if allow future is sent in as false
	if ( allowFuture == false ){
		if ( curDate.getTime() < inputDate.getTime() ){
			g_oMessage.HandleAlert(g_oMessage.WARN_DATE_FUTURE);
			fieldMonth.value=""; fieldDay.value=""; fieldYear.value=""; fieldMonth.focus();
			return false;
		}
	}
 
	//3. make sure the date is not in the past if allow past is sent in as false
	if ( allowPast == false ){
		if (curDate.getMonth() == inputDate.getMonth() && curDate.getDate() == inputDate.getDate() && curDate.getFullYear() == inputDate.getFullYear()){
			//if the current date is the same as the input date, need to check the best time call to.
			var bestTimeCallTo = idNOLForm.efEndTime.value;
			var bestTimeCallToHour = bestTimeCallTo.split(":")[0]; 	if (idNOLForm.selectAMPMEnd.value == "PM") bestTimeCallToHour = parseInt(bestTimeCallToHour) + 12;
			var bestTimeCallToMinute = bestTimeCallTo.split(":")[1];
			
			if (curDate.getHours()> bestTimeCallToHour && curDate.getMinutes()> bestTimeCallToMinute){
				g_oMessage.HandleAlert(g_oMessage.WARN_DATE_PAST);
				fieldMonth.value=""; fieldDay.value=""; fieldYear.value=""; fieldMonth.focus();
				return false;
			}
		}
		else if ( curDate.getTime() > inputDate.getTime() ){
			g_oMessage.HandleAlert(g_oMessage.WARN_DATE_PAST);
			fieldMonth.value=""; fieldDay.value=""; fieldYear.value=""; fieldMonth.focus();
			return false;
		}
	}
	
	//Standard formatting
	//field.value = field.value.replace(/([\\-])/g, "/");		//formtting field
	var month = inputDate.getMonth() + 1;
	var day	 = inputDate.getDate();
	var year  = inputDate.getFullYear();
	if ( month < 10 ) month = "0" + month.toString();
	if ( day   < 10 ) day   = "0" + day.toString(); 	
	fieldMonth.value = month;
	fieldDay.value = day;
	fieldYear.value = year;

	return true;
}

//***************************************************************
//FUNCTION:			formatTime()
//DESCRIPTION:
//this function is called from find Vehicle and find location initially
//as of 02/15/2001
//it will make sure the time is in the format hh:mm and is
//a valid time
//***************************************************************
function formatTime(timeElement)
{
	// Keith CPE 34.0 Fix: Remove all blanks
	// and then do time validation
	if ( timeElement != null ){
		timeElement.value = timeElement.value.replace( /\s*/g, "" );
	}


	//if blank then don't do anything and return
	if ( timeElement.value == "" ) return false;
		
	var tempTime = timeElement.value;
	var arrTime,hh,mm;
	var error = false;
	
	//create time array
	arrTime = tempTime.split(":");
	hh = arrTime[0];	mm = arrTime[1];
			
	if (isNaN(hh) || isNaN(mm)) error = true;														//make sure the values entered around colon is a number
 	else if ( (hh.length != 1 && hh.length != 2) || mm.length != 2 ) error = true;	//make sure that minutes are two characters and hours is either one or two characters
	else if ( hh > 12 || mm >= 60 ) error = true;												//make sure that hours is not great than 12 and minutes not greater then 60
	else if( hh.length < 2 ) {																			//if the time is in the format 1:30 add a 0 to the hours to make 01:30 and set the time
		tempTime = "0" + tempTime.charAt(0) + ":" + tempTime.charAt(2) + tempTime.charAt(3);	
		timeElement.value = tempTime;
    }
				
	//if an error has occured then dispay error
	if ( error ) {	g_oMessage.HandleAlert(g_oMessage.WARN_DATE_INVALIDTIME); 	timeElement.value = "";  timeElement.focus(); }	   
	return error;
}

//***************************************************************
//FUNCTION:			IsPolicyVerified()
//DESCRIPTION:
//This function will check whether policy has been verified
//***************************************************************
function IsPolicyVerified(objForm) {
	if ( idResults.className == "clsHide" && this.TrimAll(objForm.hdnPending.value) != "Y" ) {
		g_oMessage.HandleAlert(g_oMessage.WARN_POLICY_NOTVERIFIED);
		return false;
	}
	return true;														
}

//***************************************************************
//FUNCTION:			ResetPolicyVerification()
//DESCRIPTION:
//This function will alert user to re-verify policy in the case
//of the change of loss date and policy number
//***************************************************************
function ResetPolicyVerification(objForm) {
	if ( idResults.className == "clsShow" && this.TrimAll(objForm.hdnPending.value) != "Y" ) {
		idResults.className = "clsHide";
		if (objForm.hdnChangePolNumber!=null) {
			objForm.hdnChangePolNumber.value="Y";
		}				
		g_oMessage.HandleAlert(g_oMessage.WARN_POLICY_REVERIFY);
	}														
}

/******************************************************************************
* NAME: CheckGISReqFields()
* AUTH:	Li Tan
* DATE: 08/2006
*
* DESC: Check required fields for Locate County and Zip
* MODS: 
*		
******************************************************************************/
function CheckGISReqFields(objForm) {
	var blnRequired = false;
	switch ( objForm.name ) {
		case "frmNOLA": case "frmHONOLA": case "frmWCNOLA":
			if ( objForm.efPHAddress.value == "" ||  objForm.efPHCity.value == "" || objForm.efPHState.value == "" ) {
				blnRequired = true;
			}
			break;
		case "frmNOLB": case "frmHONOLB": case "frmWCNOLB":
			if ( objForm.efLossAddress.value == "" ||  objForm.efLossCity.value == "" || objForm.efLossState.value == "" ) {
				blnRequired = true;
			}
			break;
		case "frmWCNOLC":	
			if ( objForm.efBoatAddress.value == "" ||  objForm.efBoatCity.value == "" || objForm.efBoatState.value == "" ) {
				blnRequired = true;
			}
			break;
		case "frmNOLF":
			if ( objForm.efAssAddress2.value == "" || objForm.efAssCity2.value == "" || objForm.efAssState2.value == "" ) {
				blnRequired = true;
			}
			break;
	}
	
	if ( blnRequired ) {
		g_oMessage.HandleAlert(g_oMessage.WARN_GIS_REQUIREDFIELDS);
		return false;
	}  
	
	return true;
	
	
}

/******************************************************************************
* NAME: isAlliedPolicy()
* DATE: 08/2006
*
* DESC: Checks if we are using an Allied Policy
* MODS: 
*		
******************************************************************************/
function IsAlliedPolicy(strAlliedMinorPfx) {
	if (strAlliedMinorPfx!="") {
		return(true)
	}
	else {
		return(false)
	}
}