/* ####### GENERAL CONVERSION FUNCTIONS ####### */

function trimString(strIn) {
	if (/^\s/.test(strIn)) { strIn = strIn.replace(/^\s{1,}/, ""); }
	if (/\s$/.test(strIn)) { strIn = strIn.replace(/\s{1,}$/, ""); }
	return strIn;
}
function getIntegerString(strIn) {
	return strIn.replace(/[^0-9]/g, "");
}
function getInteger(vNum) {
	vNum = getIntegerString(vNum.toString());
	if (vNum == "") { vNum = 0; }
	return Number(vNum);
}
function getDecimalString(strIn) {
	strIn = strIn.replace(/[^0-9\.]/g, "");
	var iPoint = strIn.indexOf(".");
	if (iPoint > -1) {
		strIn = strIn.substring(0, iPoint + 1) + getIntegerString(strIn.substring((iPoint + 1), strIn.length));
	}
	return strIn;
}
function getParsedPhoneStr(strIn) {
	strIn = strIn.replace(/\.|-| |\(|\)/g,"");
	return strIn;
}

/* ###### GENERAL HELPER FUNCTIONS ######  */
function addCommasToNumString(strIn) {
	var arrTemp = strIn.split("");
	var i = strIn.length - 4;
	var iPoint = strIn.indexOf(".");
	if (iPoint > -1) { i -= (strIn.length - iPoint); }
	for (i; i >= 0; i-=3) { arrTemp[i] += ","; }
	return arrTemp.join("");
}

function validationAlert(strAlert, hField) {
	// Displays an alert, focuses a form field, and returns false.
	alert(strAlert);
	try { hField.focus(); } catch(ex) {}
	return false;
}


function isValueInSelectbox(hSelectbox, strValue) {
	for (var i=0; i < hSelectbox.options.length; i++) {
		if (hSelectbox.options[i].value == strValue) {
			return true;
		}
	}
	return false;
}

function isNotHiddenFormField(form, strName) {
	// Tells you if a non-hidden field exists in a form.
	var type;
	var field = form.elements[strName];
	if (field && (typeof(field) == "object")) {
		try {
			type = field.getAttribute("type");
		} catch(ex) {
			// probably a radio button group (no attribute)
			return true;
		}
		if ((type) && (type.toLowerCase() == "hidden")) {
			return false;
		}
		return true;
	}
	return false;
}

function getFormFieldValue(hField) {
	if (!hField) { return undefined; }
	try {
		if (hField.type) {
			if (hField.type == "radio") {
				return getRadioValue(hField.form.elements[hField.name]);
			} else if (hField.type == "select-multiple") {
				return getMultipleSelectBoxValues(hField);
			} else {
				return hField.value;
			}
		}
	} catch (ex) {}
	try {
		if (hField.length && hField[0] && (hField[0].type == "radio")) {
			return getRadioValue(hField[0].form.elements[hField[0].name]);
		}
	} catch(ex) {}
	return undefined;
}

function getRadioValue(hRadioGroup) {
	// Gets the selected value of a radio button group. If no radio button is selected, returns an empty string.
	for (var i=0; i < hRadioGroup.length; i++) {
		if (hRadioGroup[i].checked) { return hRadioGroup[i].value; }
	}
	return "";
}

function getMultipleSelectBoxValues(hSelect) {
	var i, option, arrSelected = new Array();
	while (hSelect.selectedIndex >= 0) {
		arrSelected[arrSelected.length] = hSelect.selectedIndex;
		hSelect.options[hSelect.selectedIndex].selected = false;
	}
	for (i=0; i < arrSelected.length; i++) {
		option = hSelect.options[arrSelected[i]];
		option.selected = true;
		arrSelected[i] = option.value;
	}
	return arrSelected;
}


/* ####### STRING VALIDATION ####### */

function isValidFirstName(strName) {
	if (/[^A-Za-z -]/.test(strName)) { return false; }
	return true;
}

function isValidLastName(strName) {
	if (/[^A-Za-z -]/.test(strName)) { return false; }
	return true;
}

function isValidStreetAddress(strAddress) {
	if (strAddress.length < 3) { return false; }
	if (strAddress.replace(/[^0-9]/g, "").length < 1) { return false; }
	if (strAddress.replace(/[^A-Za-z]/g, "").length < 1) { return false; }
	return true;
}

function isValidCity(strCity) {
	if (strCity.length < 2) { return false; }
	if (/[^A-Za-z -]/.test(strCity)) { return false; }
	return true;
}

function isValidEntirePhone(strPhone) {
	var bparsedStr = trimString(strPhone);
	var parsedStr = getParsedPhoneStr(bparsedStr);
	if (parsedStr.length < 10) { return false; }
	if (parsedStr.length > 17) { return false; }
	if (/^[01]/.test(parsedStr)) { return false; }
	var npa = parsedStr.substring(0,3);
	if (!isValidPhoneNPA(npa)) {
		return false;
	}
	var nxx = parsedStr.substring(3,6);
	if (!isValidPhoneNXX(nxx)) {
		return false;
	}
	
	return true;
}

function isValidPhoneNPA(strNPA) {
	if (strNPA.length < 3) { return false; }
	if (/[^0-9]/.test(strNPA)) { return false; }
	if (/^[01]/.test(strNPA)) { return false; }
	if ("200,222,300,333,400,444,500,555,600,666,700,777,900,999".indexOf(strNPA) != -1) { return false; }
	return true;
}

function isValidPhoneNXX(strNXX) {
	if (strNXX.length < 3) { return false; }
	if (/[^0-9]/.test(strNXX)) { return false; }
	if (/^[01]/.test(strNXX)) { return false; }
	return true;
}

function isValidEmail(strEmail) {
	var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

	if (strEmail.length < 5) { return false; }

	if (!strEmail.match(re)) { return false; }
	
	return true;
}

/* ####### GENERIC FORM VALIDATORS ####### */

function validateInput(hInput, minLength, inputDescription) {
	if (hInput.value.length == 0) {
		return validationAlert("Please enter " + inputDescription + ".", hInput);
	} else if (hInput.value.length < minLength) {
		return validationAlert("Please re-enter " + inputDescription + ".\n(The information you entered is incomplete.)", hInput);
	}
	return true;
}

function validateSelectbox(hSelectbox, strAlert) {
	if (hSelectbox.value.length == 0) {
		return validationAlert(strAlert, hSelectbox);
	}
	return true;
}

function validateComparison(hInput, strCompare, inputDescription, extraDescription) {
	if (hInput.value != strCompare) {
		return validationAlert("Please re-enter " + inputDescription + " " + extraDescription + ".", hInput);
	}
	return true;
}

function validateNumbersOnly(hInput, strAlert) {
	if (/[^0-9]/.test(hInput.value)) {
		return validationAlert(strAlert, hInput);
	}
	return true;
}

function validateIntegerInput(hInput, minLength, inputDescription) {
	if (!validateInput(hInput, minLength, inputDescription)) { return false; }
	if (!validateNumbersOnly(hInput, inputDescription)) { return false; }
	return true;
}


/* ####### FORM VALIDATION STRING CONSTANTS ####### */

var ErrorMsg = new Object();
	ErrorMsg.VAR1 = "%VAR1%";
	ErrorMsg.EMPTY_FIRSTNAME = "Please enter your First Name.";
	ErrorMsg.INVALID_FIRSTNAME = "Your First Name may only contain letters, hyphens, or spaces. Please update your entry.";
	ErrorMsg.EMPTY_LASTNAME = "Please enter your Last Name.";
	ErrorMsg.INVALID_LASTNAME = "Your Last Name may only contain letters, hyphens, or spaces. Please update your entry.";
	ErrorMsg.EMPTY_ADDRESS = "Please enter your Address.";
	ErrorMsg.INVALID_ADDRESS = "Your Address must contain letters and numbers. Please update your entry.";
	ErrorMsg.EMPTY_CITY = "Please enter your City.";
	ErrorMsg.INVALID_CITY = "Your City may only contain letters, hyphens, or spaces. Please update your entry.";
	ErrorMsg.UNSELECTED_STATE = "Please select your State.";
	ErrorMsg.EMPTY_ZIPCODE = "Please enter your Zip Code.";
	ErrorMsg.INVALID_ZIPCODE = "Your Zip Code must be at least five numbers. Please update your entry.";
	ErrorMsg.INVALID2_ZIPCODE = "Your Zip Code may only contain numbers. Please update your entry.";
	ErrorMsg.EMPTY_PRI_PHONE = "Please enter your Primary Phone Number";
	ErrorMsg.INVALID_PRI_PHONE = "Please enter your valid Primary Phone Number";
	ErrorMsg.INVALID_SEC_PHONE = "Please enter your valid Secondary Phone Number";
	ErrorMsg.EMPTY_PHONE_NPA = "Please enter your " + ErrorMsg.VAR1 + " Phone Number Area Code";
	ErrorMsg.INVALID_PHONE_NPA = "Your " + ErrorMsg.VAR1 + " Phone Number Area Code must be a valid three-digit area code. Please update your entry.";
	ErrorMsg.EMPTY_PHONE_NXX = "Please enter the first three digits of your " + ErrorMsg.VAR1 + " Phone Number.";
	ErrorMsg.INVALID_PHONE_NXX = "Your " + ErrorMsg.VAR1 + " Phone Number must begin with three numbers. Please update your entry.";
	ErrorMsg.INVALID2_PHONE_NXX = "Your " + ErrorMsg.VAR1 + " Phone Number may not begin with a \"1\" or a \"0\". Please update your entry.";
	ErrorMsg.EMPTY_PHONE_STATION = "Please enter the last four digits of your " + ErrorMsg.VAR1 + " Phone Number.";
	ErrorMsg.INVALID_PHONE_STATION = "Your " + ErrorMsg.VAR1 + " Phone Number must end with four numbers. Please update your entry.";
	ErrorMsg.EMPTY_EMAIL = "Please enter your Email Address.";
	ErrorMsg.INVALID_EMAIL = "You must enter a valid Email Address. Please update your entry.";
	ErrorMsg.EMPTY_STREET_NUMBER = "Please enter your Street Number.";
	ErrorMsg.EMPTY_STREET_NAME = "Please enter your Street Name.";
    ErrorMsg.UNSELECTED_BEST_CALL_TIME = "Please select Best Time to Call.";
    ErrorMsg.EMPTY_PREMATCH_NPA = "Please enter the area code where you currently live.";
    ErrorMsg.INVALID_PREMATCH_NPA = "Please enter the area code where you currently live. No 800 or 888 numbers please.";
    ErrorMsg.RESTRICTED_PREMATCH_NPA = "Please enter the area code where you currently live. No 800 or 888 numbers please.";

/* ####### SPECIFIC-USE FORM VALIDATORS ####### */

function validateFirstNameInput(hInput) {
	if (hInput.value.length == 0) { return validationAlert(ErrorMsg.EMPTY_FIRSTNAME, hInput); }
	if (!isValidFirstName(hInput.value)) { return validationAlert(ErrorMsg.INVALID_FIRSTNAME, hInput); }
	return true;
}

function validateLastNameInput(hInput) {
	if (hInput.value.length == 0) { return validationAlert(ErrorMsg.EMPTY_LASTNAME, hInput); }
	if (!isValidLastName(hInput.value)) { return validationAlert(ErrorMsg.INVALID_LASTNAME, hInput); }
	return true;
}

function validateStreetAddressInput(hInput) {
	if (hInput.value.length == 0) { return validationAlert(ErrorMsg.EMPTY_ADDRESS, hInput); }
	if (!isValidStreetAddress(hInput.value)) { return validationAlert(ErrorMsg.INVALID_ADDRESS, hInput); }
	return true;
}

function validateStreetNumberInput(hInput) {
	if (hInput.value.length == 0) { return validationAlert(ErrorMsg.EMPTY_STREET_NUMBER, hInput); }
	return true;
}

function validateStreetNameInput(hInput) {
	if (hInput.value.length == 0) { return validationAlert(ErrorMsg.EMPTY_STREET_NAME, hInput); }
	return true;
}

function validateCityInput(hInput) {
	if (hInput.value.length == 0) { return validationAlert(ErrorMsg.EMPTY_CITY, hInput); }
	if (!isValidCity(hInput.value)) { return validationAlert(ErrorMsg.INVALID_CITY, hInput); }
	return true;
}

function validateZipCodeInput(hInput) {
	if (hInput.value.length == 0) { return validationAlert(ErrorMsg.EMPTY_ZIPCODE, hInput); }
	if (hInput.value.length < 5) { return validationAlert(ErrorMsg.INVALID_ZIPCODE, hInput); }
	if (/[^0-9]/.test(hInput.value)) { return validationAlert(ErrorMsg.INVALID2_ZIPCODE, hInput); }
	return true;
}

function validatePropZipCodeInput(hInput) {
	if (hInput.value.length == 0) { return true; }
	if (hInput.value.length < 5) { return validationAlert(ErrorMsg.INVALID_ZIPCODE, hInput); }
	if (/[^0-9]/.test(hInput.value)) { return validationAlert(ErrorMsg.INVALID2_ZIPCODE, hInput); }
	return true;
}

function validatePrematchNPAInput(hInput) {
	if (hInput.value.length == 0) { return validationAlert(ErrorMsg.EMPTY_PREMATCH_NPA, hInput); }
	if (hInput.value.length < 3) { return validationAlert(ErrorMsg.INVALID_PREMATCH_NPA, hInput); }
	if (!isValidPhoneNPA(hInput.value)) { return validationAlert(ErrorMsg.INVALID_PREMATCH_NPA, hInput); }
	if ((hInput.value == "800") || (hInput.value == "888")) { return validationAlert(ErrorMsg.RESTRICTED_PREMATCH_NPA, hInput); }
	return true;
}

function validatePhoneNPAInput(hInput, strPhoneType) {
	if (hInput.value.length == 0) { return validationAlert(ErrorMsg.EMPTY_PHONE_NPA.replace(ErrorMsg.VAR1, strPhoneType), hInput); }
	if (hInput.value.length < 3) { return validationAlert(ErrorMsg.INVALID_PHONE_NPA.replace(ErrorMsg.VAR1, strPhoneType), hInput); }
	if (!isValidPhoneNPA(hInput.value)) { return validationAlert(ErrorMsg.INVALID_PHONE_NPA.replace(ErrorMsg.VAR1, strPhoneType), hInput); }
	return true;
}

function validatePhoneNXXInput(hInput, strPhoneType) {
	if (hInput.value.length == 0) { return validationAlert(ErrorMsg.EMPTY_PHONE_NXX.replace(ErrorMsg.VAR1, strPhoneType), hInput); }
	if (hInput.value.length < 3) { return validationAlert(ErrorMsg.INVALID_PHONE_NXX.replace(ErrorMsg.VAR1, strPhoneType), hInput); }
	if (/[^0-9]/.test(hInput.value)) { return validationAlert(ErrorMsg.INVALID_PHONE_NXX.replace(ErrorMsg.VAR1, strPhoneType), hInput); }
	if (/^[01]/.test(hInput.value)) { return validationAlert(ErrorMsg.INVALID2_PHONE_NXX.replace(ErrorMsg.VAR1, strPhoneType), hInput); }
	return true;
}

function validatePhoneStationInput(hInput, strPhoneType) {
	if (hInput.value.length == 0) { return validationAlert(ErrorMsg.EMPTY_PHONE_STATION.replace(ErrorMsg.VAR1, strPhoneType), hInput); }
	if (hInput.value.length < 4) { return validationAlert(ErrorMsg.INVALID_PHONE_STATION.replace(ErrorMsg.VAR1, strPhoneType), hInput); }
	if (/[^0-9]/.test(hInput.value)) { return validationAlert(ErrorMsg.INVALID_PHONE_STATION.replace(ErrorMsg.VAR1, strPhoneType), hInput); }
	return true;
}

function validateEmailInput(hInput) {
	hInput.value = trimString(hInput.value);
	if (hInput.value.length == 0) { return validationAlert(ErrorMsg.EMPTY_EMAIL, hInput); }
	if (!isValidEmail(hInput.value)) { return validationAlert(ErrorMsg.INVALID_EMAIL, hInput); }
	return true;
}

function validatePrimaryPhoneInput(hInput) {
	if (hInput.value.length == 0) { return validationAlert(ErrorMsg.EMPTY_PRI_PHONE, hInput); }
	if (!isValidEntirePhone(hInput.value)) { return validationAlert(ErrorMsg.INVALID_PRI_PHONE, hInput); }
	return true;
}

function validateSecondaryPhoneInput(hInput) {
	if (hInput.value.length == 0) { return true; }
	if (!isValidEntirePhone(hInput.value)) { return validationAlert(ErrorMsg.INVALID_SEC_PHONE, hInput); }
	return true;
}
	

/* ####### DYNAMIC FORM FIELD FUNCTIONS ####### */


function initOtherField(hHidden, hSelectbox, hTextbox, strOtherFormBlock) {
	// Initialize an "other value" selectbox/textbox combo (on page load).
	hSelectbox.value = hHidden.value;
	if (hSelectbox.value == hHidden.value) {
		hTextbox.value = "";
	} else {
		hSelectbox.value = "other";
		hTextbox.value = hHidden.value;
	}
	toggleOtherField(hSelectbox, strOtherFormBlock);
}

function toggleOtherField(hSelectbox, strOtherFormBlock) {
	// Shows another form block if an option with value "other" is selected in a SELECT form element.
	if (hSelectbox.value == "other") {
		showElement(strOtherFormBlock);
	} else {
		hideElement(strOtherFormBlock);
	}
}

function focusOtherField(hSelectbox, hTextbox) {
	// Focuses the appropriate field in a selectbox/textbox combo (for "other value" form validation).
	if (hSelectbox.value != "other") {
		hSelectbox.focus();
	} else {
		hTextbox.focus();
	}
}

function focusFirstEmptyField(form) {
	var hField;
	for (var i=0; i < form.elements.length; i++) {
		hField = form.elements[i];
		try {
			if (isNotHiddenFormField(form, hField.name) && (getFormFieldValue(hField) == "")) {
				hField.focus();
				return;
			}
		} catch(ex) {}
	}
}

function toggleElementBasedOnField(element, field, listOfValues) {
	// Toggles the visibility of the specified element, checking the value of the specified field against
	// the list of specified values.  If any values in the list match the field value, the field is made
	// visible--otherwise, the field is hidden
	var fieldValue = getFormFieldValue(field);
	var show = false;
	for (var i=0;i<listOfValues.length;i++) {
		if (listOfValues[i] == fieldValue) {
			show = true;
			break;
		}
	}
	
	if (show) {
		showElement(element);
	}
	else {
		hideElement(element);
	}
}

function setFieldNumbers(nextNum) {
	if (arguments.length < 2) { return nextNum; }
	var element;
	for (var i=1; i < arguments.length; i++) {
		element = document.getElementById(arguments[i]);
		if (!element) { continue; }
		try {
			element.innerHTML = nextNum;
			nextNum++;
		} catch(ex) {}
	}
	return nextNum;
}


function validateForm(form) {

	var fieldName;
	/* validate only the fields defined in the form */
	for (var i=0; i < form.elements.length; i++) {
		
		fieldName = form.elements[i].name.toUpperCase();

		if (fieldName == "EST_VAL") {
			if (!validateSelectbox(form.elements[i], "Please select the Estimated Property Value.")) {
        		return false;
			}else if(form.elements[i].value<80000){
				return validationAlert("Minimum Estimated Value must be at least $80,000.", form.elements[i]);
			}
		} else if (fieldName == "PROP_ZIP") {
			if (!validatePropZipCodeInput(form.elements[i])) {
        		return false;
			}
		} else if (fieldName == "FNAME") {
			if (!validateFirstNameInput(form.elements[i])) {
				return false;
			}
		} else if (fieldName == "LNAME") {
			if (!validateLastNameInput(form.elements[i])) {
				return false;
			}
		} else if (fieldName == "ZIP") {
			if (!validateZipCodeInput(form.elements[i])) {
				return false;
			}
		} else if (fieldName == "EMAIL") {
			if (!validateEmailInput(form.elements[i])) {
				return false;
			}
		} else if (fieldName == "ADDRESS") {
			if (!validateStreetAddressInput(form.elements[i])) {
				return false;
			}
		} else if (fieldName == "CITY") {
			if (!validateCityInput(form.elements[i])) {
				return false;
			}
		} else if (fieldName == "STATE") {
			if (!validateSelectbox(form.elements[i], "Please select the State.")) {
				return false;
			}
		} else if (fieldName == "PROP_ST") {
			
			var productElement = form.PRODUCT;

			if (productElement != null && productElement.type == "select-one" && productElement.options[productElement.selectedIndex].value == "PP_NEWHOME") {
				if (!validateSelectbox(form.elements[i], "Please select the Property State.")) {
					return false;
				}
			} 
		} else if (fieldName == "BAL_ONE") {

			var productElement = form.PRODUCT;
			
			if (productElement != null && ((productElement.type == "select-one" && productElement.options[productElement.selectedIndex].value != "PP_NEWHOME") || (productElement.type == "hidden" && productElement.value != "PP_NEWHOME"))) {
			
				if (!validateSelectbox(form.elements[i], "Please select the Mortgage Balance.")) {
					return false;
				}
			}
		} else if (fieldName == "MTG_ONE_INT") {
			
			var productElement = form.PRODUCT;
			
			if (productElement != null && ((productElement.type == "select-one" && productElement.options[productElement.selectedIndex].value != "PP_NEWHOME") || (productElement.type == "hidden" && productElement.value != "PP_NEWHOME"))) {
			
				if (!validateSelectbox(form.elements[i], "Please select the Interest Rate.")) {
					return false;
				}
			}
		} else if (fieldName == "CRED_GRADE") {
			if (!validateSelectbox(form.elements[i], "Please select the Credit Profile.")) {
				return false;
			}
		} else if (fieldName == "LOAN_TYPE") {
			if (!validateSelectbox(form.elements[i], "Please select the Rate Type.")) {
				return false;
			}
		} else if (fieldName == "PROP_DESC") {
			if (!validateSelectbox(form.elements[i], "Please select the Property Description.")) {
				return false;
			}
		} else if (fieldName == "PREF_CALLTIME") {
			if (!validateSelectbox(form.elements[i], "Please select the Best Contact Time.")) {
				return false;
			}
		} else if (fieldName == "PROP_PURP") {
			if (!validateSelectbox(form.elements[i], "Please select the Purpose of Property.")) {
				return false;
			}
		} else if (fieldName == "PRI_PHON") {
			if (!validatePrimaryPhoneInput(form.elements[i])) {
				return false;
			}
		} else if (fieldName == "SEC_PHON") {
			if (!validateSecondaryPhoneInput(form.elements[i])) {
				return false;
			}
		} else if (fieldName == "DOWN_PMT") {
		
			var productElement = form.PRODUCT;
			
			if (productElement != null && ((productElement.type == "select-one" && productElement.options[productElement.selectedIndex].value == "PP_NEWHOME") || (productElement.type == "hidden" && productElement.value != "PP_NEWHOME"))) {
				if (!validateSelectbox(form.elements[i], "Please select Your Down Payment amount.")) {
					return false;
				}
			}
		}
	}
	
	// remove elements from the dhtml when using dynamic display to avoid 
	// multiple values of the same element name
	if (form.PRODUCT != null) {
		typeEle = form.PRODUCT;
		loanType = typeEle.options[typeEle.selectedIndex].value;
		if (loanType == 'PP_NEWHOME') {
			// remove all field from the GEN_MORT table
			var tableElem = document.getElementById("GEN_MORT");
			if (tableElem != null) {
				tableElem.parentElement.removeChild(tableElem);
			}
		} else {
			// remove all fields from the NEWHOME table
			var tableElem = document.getElementById("NEWHOME");
			if (tableElem != null) {
				tableElem.parentElement.removeChild(tableElem);
			}
		}
		
		return true;
	}		
}


// shows pertinent parts of the form based on the
// product value
function loanParams() {
	typeEle = document.forms[0].PRODUCT;
	loanType =  typeEle.options[typeEle.selectedIndex].value;

	if( document.getElementById ) {
		if (loanType == 'PP_NEWHOME') {
			// show option2
			document.getElementById('NEWHOME').style.display = "";
			//hide option 1
			document.getElementById('GEN_MORT').style.display = "none";
		} else {
			// show option1
			document.getElementById('GEN_MORT').style.display = "";
			// hide option2
			document.getElementById('NEWHOME').style.display = "none";
		}
	}
}

function loanParams2(select) {
	
	if( document.getElementById ) {
		if (select.value == 'PP_NEWHOME') {
			// show option2
			document.getElementById('NEWHOME').style.display = "";
			//hide option 1
			document.getElementById('GEN_MORT').style.display = "none";
		} else {
			// show option1
			document.getElementById('GEN_MORT').style.display = "";
			// hide option2
			document.getElementById('NEWHOME').style.display = "none";
		}
	}
}




