//<script>
/******************************************************************************
* NAME: CPropertyForm()
* AUTH:	Li Tan
* DATE: 08/2006
*
* DESC: This JavaScript class will handle functions needed for property forms.
* MODS: 
*		
******************************************************************************/
function CPropertyForm() {
	// member variables
	
	// member functions
	this.Navigate				  = Navigate;					// Handles page transition
	this.HandleEvents			  = HandleEvents;				// Handles all the onclick, onblur events
	this.HandleScreenerEvents	  = HandleScreenerEvents;		// Handles all the onclick, onblur events on screener page
	this.HandlePolicyEvents		  = HandlePolicyEvents;			// Handles all the onclick, onblur events on policy info page
	this.OnPageLoad				  = OnPageLoad;					// Handles all the onclick, onblur events on onload event 
	this.SetCallerInfo			  = SetCallerInfo;				// Copy PH Info to caller 
	this.ResetLossAddress		  = ResetLossAddress;			// Clears the loss address
	this.HandleLossCauseSelection = HandleLossCauseSelection;	// Prefill lossdesc from loss cause drop down
	this.PostForm				  = PostForm;					// Post forms
	this.HandlePolicySelections	  = HandlePolicySelections;		// Handles the selection of location and scheduled items
}
CPropertyForm.prototype			= new CForm();

/******************************************************************************
* NAME: Navigate(objForm)
* AUTH:	Li Tan
* DATE: 08/2006
*
* DESC: Handles the page transition
* MODS: 
*		
******************************************************************************/
function Navigate(objForm, strAction) {

	this.confirmExit = false;
	// Check required fields
	if ( !g_oValidateProperty.CheckReqFields(objForm, strAction) ) {
		// Check whether any errors occurred on the page and redirect to error page
		if ( this.HandleEvents(objForm) ) {
			objForm.action = "/eclaims/error.asp";
			objForm.submit();
			//window.location="/eclaims/error.asp";
		// navigate to the next page
		} else {
			if (objForm.hdnButtonClicked)
				objForm.hdnButtonClicked.value = "CONTINUE";
			objForm.action = strAction;
			//using the id so that it can be used to all the pages
			idNOLForm.submit();
		}
	} else { 
		return false;
	}
	
}


/******************************************************************************
* NAME: HandleEvents()
* AUTH:	Li Tan
* DATE: 08/2006
*
* DESC: Handles all the onclick, onblur events
* MODS: 
*		
******************************************************************************/
function HandleEvents(objForm) {

	switch ( objForm.name ) {
		case "frmHOBegin": return this.HandleScreenerEvents(objForm);
		case "frmHOPolicy": return this.HandlePolicyEvents(objForm);
		

	}
	

}

/******************************************************************************
* NAME: HandleScreenerEvents()
* AUTH:	Li Tan
* DATE: 08/2006
*
* DESC: Handles events on screener page
* MODS: 
*		
******************************************************************************/
function HandleScreenerEvents(objForm) {

	if ( objForm.rbHomeInjured[0].checked || 
	     objForm.rbHomeDamage[0].checked || 
	     objForm.rbHomeLiveable[1].checked || 
	     objForm.rbIdTheft[0].checked ) {
	     
	     g_oValidateProperty.RaiseError("Not qualified");
	     
	     return true;
	
	} else { return false; }
}

/******************************************************************************
* NAME: HandleScreenerEvents()
* AUTH:	Li Tan
* DATE: 08/2006
*
* DESC: Handles events on screener page
* MODS: 
*		
******************************************************************************/
function HandlePolicyEvents(objForm) {

	if ( ( objForm.cbxLOCNotListed != null && objForm.cbxLOCNotListed.checked ) || 
	     ( objForm.cbxSINotListed != null && objForm.cbxSINotListed.checked ) ) {
	     
	     g_oValidateProperty.RaiseError("Not qualified");
	     
	     return true;
	
	} else { return false; }
}


/******************************************************************************
* NAME: OnPageLoad()
* AUTH:	Li Tan
* DATE: 08/2006
*
* DESC: Handles onload events on all pages
* MODS: 
*		
******************************************************************************/
function OnPageLoad() {

	//DPL introduced the first form in our pages
	//to avoid error in case they remove the form later
	var objForm = document.forms[document.forms.length-1];
	switch ( objForm.name ) {
		case "frmHOBegin":
			objForm.rbHomeInjured[0].focus();
			break;
		case "frmHOPolicy": 	
			objForm.efLossDateMonth.focus();
			if ( objForm.cbxLossTimeUnknown.checked ) { objForm.cbxLossTimeUnknown.onclick(); } 
			/*if ( objForm.efPolicyNumber ) {
				if ( objForm.efPolicyNumber.selectedIndex != 0 ) {
					g_oPropertyForm.parsePolicyNumber(frmHOPolicy);
				}
			}*/
			break;
		case "frmHONOLA": 	
			objForm.efFPHFirstName.focus();
			break;
		case "frmHONOLB": 	
			objForm.efLossAddress.focus();
			if ( objForm.rbLossPolice[0].checked ) { objForm.rbLossPolice[0].onclick(); } 
			else if ( objForm.rbLossPolice[1].checked ) { objForm.rbLossPolice[1].onclick(); } 
			break;
		case "frmHONOLC": 	
			objForm.efWitness.focus();
			break;
		
	}

}

/******************************************************************************
* NAME: SetCallerInfo()
* AUTH:	Li Tan
* DATE: 08/2006
*
* DESC: Copy PH Information to Caller
* MODS: 
*		
******************************************************************************/
function SetCallerInfo() {
	var objForm = window.document.frmHONOLA;
	objForm.efCallerFirstName.value		= objForm.efFPHFirstName.value;
	objForm.efCallerLastName.value		= objForm.efFPHLastName.value;
	objForm.efCallerHomePhone1.value	= objForm.efFPHHomePhone1.value;
	objForm.efCallerHomePhone2.value	= objForm.efFPHHomePhone2.value;
	objForm.efCallerHomePhone3.value	= objForm.efFPHHomePhone3.value;
	objForm.efCallerWorkPhone1.value	= objForm.efFPHWorkPhone1.value;
	objForm.efCallerWorkPhone2.value	= objForm.efFPHWorkPhone2.value;
	objForm.efCallerWorkPhone3.value	= objForm.efFPHWorkPhone3.value;
	objForm.efCallerExt.value			= objForm.efFPHWorkPhoneExt.value;
}

/******************************************************************************
* NAME: ResetLossAddress()
* AUTH:	Li Tan
* DATE: 08/2006
*
* DESC: Clear the loss address on the incident page
* MODS: 
*		
******************************************************************************/
function ResetLossAddress() {
	var objForm = window.document.frmHONOLB;
	objForm.efLossAddress.value	= "";
	objForm.efLossCity.value	= "";
	objForm.efLossState.value	= "";
	objForm.efLossZip.value		= "";
	objForm.efLossCounty.value	= "";
}

/******************************************************************************
* NAME: PostForm()
* AUTH:	Li Tan
* DATE: 08/2006
*
* DESC: Generic function for posting a form
* MODS: 
*		
******************************************************************************/
function PostForm(objForm, strAction){
	if (objForm.hdnButtonClicked){
		if (objForm.hdnButtonClicked.value != "CONTINUE"){
			objForm.hdnButtonClicked.value = "PREVIOUS";
		}
	}
	this.confirmExit = false;
	objForm.action = strAction;
	objForm.submit();
} 


/******************************************************************************
* NAME: HandlePolicySelections()
* AUTH:	Li Tan
* DATE: 08/2006
*
* DESC: Handles the selection of location and scheduled items on the policy page
* MODS: 
*		
******************************************************************************/
function HandlePolicySelections(objForm, objField) {

	switch ( objField.name ) {
	
		case "lbSFTable": 	
			if ( objForm.cbxLOCNotListed.checked ) objForm.cbxLOCNotListed.checked = false;
			break;
			
		case "cbxLOCNotListed":
			var oSFTable = document.getElementsByName("lbSFTable");
			for ( var i = 0; i < oSFTable.length; i ++ ) {
				oSFTable[i].checked = false;
			}
			break;
			
		case "lbSITable":
			if ( objForm.cbxSINotListed.checked ) objForm.cbxSINotListed.checked = false;
			break;
		
		case "cbxSINotListed":
			var oSITable = document.getElementsByName("lbSITable");
			for ( var i = 0; i < oSITable.length; i ++ ) {
				oSITable[i].checked = false;
			}
			break;

	}
	
} 

/******************************************************************************
* NAME: HandleLossCauseSelection()
* AUTH:	Li Tan
* DATE: 08/2006
*
* DESC: used on the loss cause dropdown, when a selection is made. it should
*		prefill the loss desc except for selection other
*		Also, check to see if 113 or 128 are selected when used answered  
*		question rbOtherItems as yes
* MODS: 
*		
******************************************************************************/
function HandleLossCauseSelection(objForm) {
	//If scheduled item were selected
	if ( g_oValidateProperty.TrimAll(objForm.lbSITable.value) != "" ) {
		if ((objForm.ddlbLossCause.options[objForm.ddlbLossCause.selectedIndex].value == "113" ||
		    objForm.ddlbLossCause.options[objForm.ddlbLossCause.selectedIndex].value == "128") &&
		    objForm.rbOtherItems[0].checked && g_oValidateProperty.TrimAll(objForm.hdnPolicyType.value) == "RF") {
		    g_oMessage.HandleAlert(g_oMessage.WARN_LOSSCAUSE_INVALID);  // comment this line ( fix for #71017 )
			objForm.ddlbLossCause.selectedIndex = 0;                    // comment this line ( fix for #71017 )
		    objForm.efNOLLossDesc.value = '';
		    return false;
		} 
	}
	
	if ( objForm.ddlbLossCause.options[objForm.ddlbLossCause.selectedIndex].text.toUpperCase().indexOf('OTHER') != 0 ) {
		objForm.efNOLLossDesc.value = objForm.ddlbLossCause.options[objForm.ddlbLossCause.selectedIndex].text; 
	} else {
		objForm.efNOLLossDesc.value = '';
	}
	
} 



//</script>
