
callMsg = "Please call our Defined Benefit Specialists at " + supportPhone + "."

function validatedata() { 
	
	if (ubs == true) {
		if (document.form1.UD24.value == "") { 
			alert("Advisor Number is Required") 
			document.form1.UD24.focus() 
			document.form1.UD24.blur() 
			document.form1.UD24.select() 
			return
		}
		if (document.form1.TITLE.value == "") { 
			alert("Advisor Title is Required") 
			document.form1.TITLE.focus() 
			document.form1.TITLE.blur() 
			document.form1.TITLE.select() 
			return
		}
		if (document.form1.SECR.value == "") { 
			alert("Advisor Branch Name is Required") 
			document.form1.SECR.focus() 
			document.form1.SECR.blur() 
			document.form1.SECR.select() 
			return
		}  
	} else {
		if (document.form1.bd_company.value == "") { 
			alert("Advisor Company Name is Required") 
			document.form1.bd_company.focus() 
			return
		} 
	}
	if (document.form1.broker_name.value == "") { 
		alert("Investment Advisor Name is Required") 
		document.form1.broker_name.focus() 
		return
	} 
	if (document.form1.state.value.length != 2) { 
		alert("State is Required") 
		document.form1.state.focus() 
		return
	} 
	if (document.form1.broker_phone.value == "") { 
		alert("Advisor Phone Number is Required") 
		document.form1.broker_phone.focus() 
		return
	} 

	var msg = emailValidate(document.form1.broker_email.value) 
	if (msg != true) { 
		alert("Advisor E-Mail is invalid.  " + msg + ".") 
		document.form1.broker_email.focus() 
		return
	}
	if (document.form1.client_income.value < 10000) { 
		alert("Please enter client income") 
		document.form1.client_income.focus() 
		return
	}

	if (document.form1.sole.value != "Y" && document.form1.sole.value != "N") {
		alert("Please specify whether or not this is a sole proprietorship")
		document.form1.sole.focus()
		return
	}
		
	if (document.form1.sole.value == "Y" && 
			(GetCurrencyFromText(document.form1.cf1comp.value) > 0 
			|| GetCurrencyFromText(document.form1.cf2comp.value) > 0
			|| GetCurrencyFromText(document.form1.cf3comp.value) > 0
			|| GetCurrencyFromText(document.form1.cf4comp.value) > 0)) {	
		solePropAndEmployeesError();
		return
	}
	
	bizYear = document.form1.busyyyy.value 
	bizMonth = document.form1.busmm.value
	bizDay = document.form1.busdd.value
	cdobYear = document.form1.cdobyyyy.value
	cdobMonth = document.form1.cdobmm.value
	cdobDay = document.form1.cdobdd.value

	if (! validDate(bizYear, bizMonth, bizDay)) {
		alert("Invalid business start date entered.")
		document.form1.busmm.focus()
		return
	}
	if (! validDate(cdobYear, cdobMonth, cdobDay)) {
		alert("Invalid date of birth entered.")
		document.form1.cdobmm.focus()
		return
	}
	
	if (bizYear > new Date().getFullYear()) { 
		alert("Date Business Started Must Not Be Greater Than 2006") 
		document.form1.busyyyy.focus()
		document.form1.busyyyy.blur()
		document.form1.busyyyy.select()
		return
	}
	ageInDays = displayAge(
		cdobYear, cdobMonth, cdobDay,
		"days", 0, "roundup", "from start of year")
	if (ageInDays >= 69.5 * 365.25) {
		alert("If your client is 70 years of age or older, you will need a custom proposal.  " + callMsg)
		document.form1.cdobyyyy.focus()
		return
	}
	if (document.form1.sole.value == "Y" && ageInDays < 45 * 365.25) {
		alert("If your client is a sole proprietor and younger than age 45, you will need a custom proposal.  " + callMsg)
		document.form1.cdobyyyy.focus()
		return
	}
	
	if (ageInDays < 365) {
		alert("Check the client's date of birth.")
		return false;
	}

	if ((document.form1.cf1fname.value != "" && ! validDate(document.form1.cf1dobyr.value, document.form1.cf1dobmo.value, document.form1.cf1dobday.value)) ||
		(document.form1.cf2fname.value != "" && ! validDate(document.form1.cf2dobyr.value, document.form1.cf2dobmo.value, document.form1.cf2dobday.value)) ||
		(document.form1.cf3fname.value != "" && ! validDate(document.form1.cf3dobyr.value, document.form1.cf3dobmo.value, document.form1.cf3dobday.value)) ||
		(document.form1.cf4fname.value != "" && ! validDate(document.form1.cf4dobyr.value, document.form1.cf4dobmo.value, document.form1.cf4dobday.value))) {
		alert("Invalid date specified on employee page.")
		openChild('employee.html','win2')
		return
	}

	document.form1.submit()
} 

function solePropAndEmployeesError() {
	alert("If your client is a sole proprietor with employees, you will need a custom proposal.  " + callMsg)
}

function employeeButtonClick() {
	if (document.form1.sole.value == "Y") {
		solePropAndEmployeesError();
	} else {
		openChild('employee.html','win2')
	}
}


function newImage(arg) { 
if (document.images) { 
rslt = new Image(); 
rslt.src = arg; 
return rslt; 
} 
} 

function changeImages() { 
if (document.images && (preloadFlag == true)) { 
for (var i=0; i<changeImages.arguments.length; i+=2) {

document[changeImages.arguments[i]].src =
changeImages.arguments[i+1]; 
} 
} 
} 

var preloadFlag = false; 
function preloadImages() { 
if (document.images) { 
gn_who_on =
newImage(homeImage);

preloadFlag = true; 
} 

    for (var liCurrent=0; liCurrent < document.form1.state.options.length; liCurrent++) {
      if (document.form1.state.options[liCurrent].text == '<%=Session("state")%>') {
        document.form1.state.selectedIndex = liCurrent;
        break;
}
}

} 

function openChild(file,window) { 
childWindow=open(file,window,'resizable=no,width=700,height=600');

if (childWindow.opener == null) childWindow.opener = self; 
} 

