
function check_email_opt_submit() {

	if (document.evaluation.email_plan.checked == true || document.evaluation.receive_ol_updates.checked == true) {
	
		if (document.evaluation.survey_email.value == '') {
		
			alert("Please enter your Email Address");
			document.evaluation.survey_email.focus();
			
			return false;
			
		}
		
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (!filter.test(document.evaluation.survey_email.value)) {
			
			alert("Please enter a valid Email Address");
			document.evaluation.survey_email.focus();
			return false;
	   }
}
//end function
}



function LTSE_Demographic() {

var missing_answers = "";
var errors = "";
var errors_found = 0;


//Check if user selected a race
if (document.ltse.Gender.selectedIndex == "") {

missing_answers = missing_answers + "Sexo\n";

errors_found++;
}

//Check if user selected a race
if (document.ltse.Race.selectedIndex == 0) {

missing_answers = missing_answers + "Raza\n";

errors_found++;
}

//Check if user selected a race
if (document.ltse.Diagnosis_Age.selectedIndex == 0) {

missing_answers = missing_answers + "Edad en la diagnosis\n";

errors_found++;
}

//Check if user selected a race
if (document.ltse.Current_Age.selectedIndex == 0) {

missing_answers = missing_answers + "Edad actual\n";

errors_found++;
}

//Check if user selected a race
if (document.ltse.Education.selectedIndex == 0) {

missing_answers = missing_answers + "Nivel de educacion mas alto\n";

errors_found++;
}

//Check if the current age is less than the age of diagnosis

if (document.ltse.Current_Age.selectedIndex != 0 && document.ltse.Diagnosis_Age.selectedIndex != 0 && (document.ltse.Current_Age.selectedIndex < document.ltse.Diagnosis_Age.selectedIndex)) {

missing_answers = missing_answers + "Su edad actual no puede ser mas joven que su edad en el momento del diagnostico.\n";

errors_found++;
}


//Check if user selects health care provider other text for managing your healthcare needs

if (document.ltse.Patient_Relationship.options[document.ltse.Patient_Relationship.selectedIndex].value == 3 && document.ltse.Health_Care_Provider.selectedIndex == 0) {

missing_answers = missing_answers + "Tipo de asistencia sanitaria Prodiver\n";

errors_found++;
}

//Check if user selects physician type

if (document.ltse.Health_Care_Provider.options[document.ltse.Health_Care_Provider.selectedIndex].value == 3 && document.ltse.Phsyician_Type.selectedIndex == 0) {

missing_answers = missing_answers + "Tipo Phsyician\n";

errors_found++;
}

//Check if user selects health care provider other text for managing your healthcare needs

if (document.ltse.Patient_Relationship.options[document.ltse.Patient_Relationship.selectedIndex].value == 3 || document.ltse.Patient_Relationship.options[document.ltse.Patient_Relationship.selectedIndex].value == 4) {
	//Check if user selected plan type
	
	var Checked = 0;
	
	for (x = 0; x < document.ltse.LSCP_version.length; x++) {
	
		if (document.ltse.LSCP_version[x].checked == true) {
			Checked = 1;
		}
	}
	if(Checked == 0){
		missing_answers = missing_answers + "Would you like the use the Patient version or the Healthcare Provider version?\n";
		errors_found++;
	}
}

//Check if a option is selected for managing your healthcare needs

if (document.ltse.Managing_Healthcare.selectedIndex == 0) {

missing_answers = missing_answers + "Quien esta actualmente manejando sus necesidades y cuidado medico?\n";

errors_found++;
}

//Check if user entered other text for managing your healthcare needs

if (document.ltse.Managing_Healthcare.options[document.ltse.Managing_Healthcare.selectedIndex].value == 4 && document.ltse.Other_Managing_Healthcare.value == "") {

missing_answers = missing_answers + "Quien esta actualmente manejando sus necesidades y cuidado medico?\n";

errors_found++;
}

//Check if user selected geographical location

var Checked = 0;

for (x = 0; x<document.ltse.Country.length; x++) {

if (document.ltse.Country[x].checked == true) {

Checked = 1;
}

//end for loop
}


if (Checked == 0) {

missing_answers = missing_answers + "Cual es su localidad geografica corrientemente?\n";

errors_found++;
}





//Make sure other geographical information is selected or inputted


//US geographical check

if (document.ltse.Country[0].checked == true) {


if (document.ltse.State.selectedIndex == 0) {

missing_answers = missing_answers + "Seleccione Estado\n";

errors_found++;
}

}


//Canada geographical check

if (document.ltse.Country[1].checked == true && document.ltse.Province.selectedIndex == 0) {

missing_answers = missing_answers + "Seleccione la Provincia\n";

errors_found++;
}

//Other country geographical check

if (document.ltse.Country[2].checked == true && document.ltse.Other_Country.selectedIndex == 0) {

missing_answers = missing_answers + "Seleccione Pais\n";

errors_found++;
}

//Check if user selected Survivor Health
if (document.ltse.Offering_Survivorship_Health.selectedIndex == 0) {

missing_answers = missing_answers + "Ha usted (o el paciente) sido ofrecido informacion sobre la salud del sobreviviente anteriormente?\n";

errors_found++;
}

//Check if user selected Survivor Health
if (document.ltse.Treatment_Summary.selectedIndex == 0) {

missing_answers = missing_answers + "Alguna vez ha recibido un resumen del tratamiento?\n";

errors_found++;
}

//Where do you consider yourself living?  check

if (document.ltse.Living[0].checked == false && document.ltse.Living[1].checked == false  && document.ltse.Living[2].checked == false ) {

missing_answers = missing_answers + "Donde considera usted vive?\n";

errors_found++;
}


// Where have you received most of your cancer care? 

if (document.ltse.CancerCare[0].checked == false && document.ltse.CancerCare[1].checked == false && document.ltse.CancerCare[2].checked == false && document.ltse.CancerCare[3].checked == false) {

missing_answers = missing_answers + "Donde ha recibido la mayor parte de su tratamiento del cancer? \n";

errors_found++;
}


// How far do you live from the cancer center where you received most of your cancer treatment?

if (document.ltse.CancerCenter[0].checked == false && document.ltse.CancerCenter[1].checked == false) {

missing_answers = missing_answers + "Hasta donde vivo desde el centro del cancer?\n";

errors_found++;
}


//Check menopausal status

if (document.ltse.Gender.selectedIndex == "1") {

	if (document.ltse.Menopausal_Status[0].checked == false && document.ltse.Menopausal_Status[1].checked == false && document.ltse.Menopausal_Status[2].checked == false && document.ltse.Menopausal_Status[3].checked == false && document.ltse.Menopausal_Status[4].checked == false && document.ltse.Menopausal_Status[5].checked == false) {

	missing_answers = missing_answers + "Cual es su estado menopausico?\n";
	
	errors_found++;
	}

	if (document.ltse.Menopausal_Status[1].checked == true && (document.ltse.Postmenopausal_Cause[0].checked == false && document.ltse.Postmenopausal_Cause[1].checked == false) ) {

	missing_answers = missing_answers + "Era postmenopousico a la cirugia, quimioterapia o terapia de radiacion?\n";

	errors_found++;
	}
	
	if (document.ltse.Menopausal_Status[1].checked == false) {
	
	document.ltse.Postmenopausal_Cause[0].checked = false;
	document.ltse.Postmenopausal_Cause[1].checked = false;
	}

}

//Display errors if they're any

if (errors_found > 0) {

alert("Please answer the following question(s)?\n\n" + missing_answers);

return false;
}

if (errors != "" && errors_found == 0) {

alert("v\n\n" + errors);

return false;
}


//end function
}

function Check_Age() {


if (document.ltse.Current_Age.selectedIndex == 1) {

var agree=confirm("b");

if (agree) {

location.href='questions.cfm?Page=7';
}

else {

return false;
}


}


if (document.ltse.Diagnosis_Age.selectedIndex == 1) {


var agree=confirm("Que realmente fueron diagnosticadas antes de la edad de menores de 18 anos?");

if (agree) {

location.href='questions.cfm?Page=7';
}

else {

return false;
}


}

//end function
}

function Change_Patient_Relationship() {


if (document.ltse.Patient_Relationship.options[document.ltse.Patient_Relationship.selectedIndex].value == 3 || document.ltse.Patient_Relationship.options[document.ltse.Patient_Relationship.selectedIndex].value == 4) 
{
var el=document.getElementById('Health_Care_Providers');el.style.display='';
var el=document.getElementById('Health_Care_Providers1');el.style.display='';
} else {
var el=document.getElementById('Health_Care_Providers');el.style.display='none';
var el=document.getElementById('Health_Care_Providers1');el.style.display='none';
var el=document.getElementById('Phsyician_Types');el.style.display='none';
}


//end function
}


function Change_Survivorship_Who() {


if (document.ltse.Offering_Survivorship_Health.options[document.ltse.Offering_Survivorship_Health.selectedIndex].value == 1) 
{
var el=document.getElementById('survivorship_who');el.style.display='';
} else {
var el=document.getElementById('survivorship_who');el.style.display='none';
}

//end function
}


function Change_Menopausal_Status() {

if (document.ltse.Gender.selectedIndex == "1") {

var el=document.getElementById('MenopausalStatusBlock');el.style.display='';
}

else {

var el=document.getElementById('MenopausalStatusBlock');el.style.display='none';
}

//end function
}

function Change_Health_Care_Provider() {

if (document.ltse.Health_Care_Provider.options[document.ltse.Health_Care_Provider.selectedIndex].value == 3) {

var el=document.getElementById('Phsyician_Types');el.style.display='';
}

else {

var el=document.getElementById('Phsyician_Types');el.style.display='none';
}

//end function
}

function Change_Hidden_Check_Boxes(SpanName) {

var el=document.getElementById(SpanName);

if (el.style.display == 'block') {

el.style.display='none';
}

else {

el.style.display = 'block';
}

//end function
}


//Define function to validate each page of the questionnaire

function LTSE(Page) {

var missing_answers = "";
var errors = "";
var errors_found = 0;

if (Page == 2) {

	//Determine how many chemotherapies were selected
	
	var items_checked = 0;
	for (i = 0; i < document.ltse.Type_Of_Cancer.length; i++) {
		if (document.ltse.Type_Of_Cancer[i].checked == true) {
			items_checked++;
		}
		//end for loop
	}
	
	
	//If user answered yes to having IV administered, check to see if they selected a chemotherapy
	
	if (items_checked == 0) {
		missing_answers = missing_answers + "Que tipo de cancer/s has tenido?\n";
		errors_found++;
	}
	
	var items_checked = 0;
	for (i = 0; i < document.ltse.Type_of_Cancer_detail.length; i++) {
		if (document.ltse.Type_of_Cancer_detail[i].checked == true) {
			items_checked++;
		}
		//end for loop
	}
	//If user answered yes to having cancer, give us detail
	
	if (items_checked == 0) {
		missing_answers = missing_answers + "Alguna de las siguientes opciones describe su situacion?\n";
		errors_found++;
	}
	
}
	
if (Page == 3) {

if (document.ltse.Diagnosis_Age) 
	{
	//Check if user selected an Age at Diagnosis
	if (document.ltse.Diagnosis_Age.selectedIndex == 0) 
		{
			missing_answers = missing_answers + "Cual era su edad al diagnostico?\n";
			errors_found++;
		} 
	else 
		{
		//Check if the current age is less than the age of diagnosis
		if (document.ltse.Current_Age.value < document.ltse.Diagnosis_Age.value)
			{
				missing_answers = missing_answers + "Su edad de diagnostico no puede ser mayor que su edad actual.\n";
				errors_found++;
			}		
		}		
	}

//Check if user answered whether they had surgery for cancer
if (document.ltse.Had_Surgery[0].checked == false && document.ltse.Had_Surgery[1].checked == false) {

missing_answers = missing_answers + "Se someten a cirugia para este tipo de cancer?\n";

errors_found++;
}

//Determine how many sugeries were selected

var items_checked = 0;
var subsurgeries_found = 0;

for (i = 0; i < document.ltse.Surgeries.length; i++) {

	if (document.ltse.Surgeries[i].checked == true) {
		items_checked++;
		if (document.ltse.Surgeries[i].value == 3) {
			subsurgeries_found++;
		}
	}
	
	//end for loop
}


//If user answered yes to having surgery for cancer, check to see if they selected a surgery

if (document.ltse.Had_Surgery[1].checked == true && items_checked == 0) {

missing_answers = missing_answers + "Que tecnica quirurgica que ha?\n";

errors_found++;
} else {
	var items_checked = 0;
	if (subsurgeries_found > 0) {
		for (i = 0; i < document.ltse.SurgeriesSubType.length; i++) {
			if (document.ltse.SurgeriesSubType[i].checked == true) {
				items_checked++;
			}
		}
		if (items_checked == 0) {
			missing_answers = missing_answers + "Que procedimiento quirurgico en particular se hizo?\n";
			errors_found++;
		}
	}
}


//Make sure user doesn't select any surgeries if they answered no to undergoing surgery

if (document.ltse.Had_Surgery[0].checked == true && items_checked > 0) {

errors = errors + "Usted no puede elegir a cualquier cirugias.\n";
}


}


if (Page == 4) {

//Check if user answered whether they had IV administered
if (document.ltse.Had_IV_Chemotherapy[0].checked == false && document.ltse.Had_IV_Chemotherapy[1].checked == false) 
{
missing_answers = missing_answers + "Recibio usted IV (administrado en una vena) u oral (por la boca) de quimioterapia?\n";
errors_found++;
}



//Determine how many chemotherapies were selected

var items_checked = 0;
for(i=0; i<document.ltse.Chemotherapies.length; i++) 
{
	if (document.ltse.Chemotherapies[i].checked == true) 
	{
	items_checked++;
	}
//end for loop
}


//If user answered yes to having IV administered, check to see if they selected a chemotherapy

if (document.ltse.Had_IV_Chemotherapy[1].checked == true && items_checked == 0 && document.ltse.Other_Therapy.value == "") 
{
missing_answers = missing_answers + "Que hizo usted recibe quimioterapia?\n";
errors_found++;
}


//Make sure user doesn't select any chemotherapies if they answered no to having IV administered

if (document.ltse.Had_IV_Chemotherapy[0].checked == true && (items_checked > 0 || document.ltse.Other_Therapy.value != "") ) 
{
errors = errors + "Usted no puede elegir a cualquier quimioterapias o escribir en otras quimioterapias para el tratamiento recibido.\n";
}

if (document.ltse.Had_Hormone_Therapy) {
	//Check if user answered whether they had IV administered
	if (document.ltse.Had_Hormone_Therapy[0].checked == false && document.ltse.Had_Hormone_Therapy[1].checked == false) {
		missing_answers = missing_answers + "Did you receive hormone therapy medication, for treatment of this cancer?\n";
		errors_found++;
	}
	
	var items_checked = 0;
	for (i = 0; i < document.ltse.HormoneTherapies.length; i++) {
		if (document.ltse.HormoneTherapies[i].checked == true) {
			items_checked++;
		}
		//end for loop
	}
	
	
	//If user answered yes to having IV administered, check to see if they selected a chemotherapy
	
	if (document.ltse.Had_Hormone_Therapy[1].checked == true && items_checked == 0) {
		missing_answers = missing_answers + "Que terapias hormonales recibio?\n";
		errors_found++;
	}
	
	
	//Make sure user doesn't select any chemotherapies if they answered no to having IV administered
	
	if (document.ltse.Had_Hormone_Therapy[0].checked == true && items_checked > 0) {
		errors = errors + "Usted no puede seleccionar ninguna terapia hormonal o escribir en otro tipo de terapia recibida de las terapias hormonales.\n";
	}
}




//First make sure the form element exists on the page because a field may not exist due to not meeting specified requirements
if (document.ltse.Had_Intrathecal_Chemotherapy) 
{
//Check if user answered whether received intrathecal chemotherapies
if (document.ltse.Had_Intrathecal_Chemotherapy[0].checked == false && document.ltse.Had_Intrathecal_Chemotherapy[1].checked == false) 
{
missing_answers = missing_answers + "Ha recibido quimioterapia intratecal (administrada en el liquido cefalorraquideo)?\n";
errors_found++;
}



//Determine how many intrathecal chemotherapies were selected

var items_checked = 0;
for(i=0; i<document.ltse.Intrathecal_Chemotherapies.length; i++) 
{
if (document.ltse.Intrathecal_Chemotherapies[i].checked == true) 
	{
	items_checked++;
	}
//end for loop
}


//If user answered yes to having received intrathecal chemotherapies, check to see if they selected a intrathecal chemotherapy
	if (document.ltse.Had_Intrathecal_Chemotherapy[1].checked == true && items_checked == 0 && document.ltse.Other_Intrathecal.value == "") 
	{
	missing_answers = missing_answers + "Que quimioterapia intratecal recibio usted?\n";
	errors_found++;
	}

	//Make sure user doesn't select any intrathecal chemotherapies if they answered no to having IV administered

	if (document.ltse.Had_Intrathecal_Chemotherapy[0].checked == true && (items_checked > 0 || document.ltse.Other_Intrathecal.value != "") ) 
	{
	errors = errors + "Usted no puede elegir a cualquier quimioterapia intratecal o escribir en otros recibieron la terapia de quimioterapia intratecal.\n";
	}
}


//First make sure the form element exists on the page because a field may not exist due to not meeting specified requirements
if (document.ltse.Had_Intravesicular_Chemotherapy) 
{
//Check if user answered whether received intrathecal chemotherapies
if (document.ltse.Had_Intravesicular_Chemotherapy[0].checked == false && document.ltse.Had_Intravesicular_Chemotherapy[1].checked == false) 
{
missing_answers = missing_answers + "Recibio intravesicular quimioterapia (administrados directamente en la vejiga)?\n";
errors_found++;
}



//Determine how many intrathecal chemotherapies were selected
var items_checked = 0;
for(i=0; i<document.ltse.Intravesicular_Chemotherapies.length; i++) 
{
if (document.ltse.Intravesicular_Chemotherapies[i].checked == true) 
	{
	items_checked++;
	}
//end for loop
}


//If user answered yes to having received intrathecal chemotherapies, check to see if they selected a intrathecal chemotherapy
	if (document.ltse.Had_Intravesicular_Chemotherapy[1].checked == true && items_checked == 0 && document.ltse.Other_Intravesicular.value == "") {

	missing_answers = missing_answers + "Lo que la quimioterapia intravesical recibio?\n";

	errors_found++;
	}

	//Make sure user doesn't select any intrathecal chemotherapies if they answered no to having IV administered

	if (document.ltse.Had_Intravesicular_Chemotherapy[0].checked == true && (items_checked > 0 || document.ltse.Other_Intravesicular.value != "") ) {

	errors = errors + "Usted no puede elegir a cualquier quimioterapia intravesicular o escribir en otros recibieron la terapia de quimioterapia intravesicular.\n";
	}
}
}

//First make sure the form element exists on the page because a field may not exist due to not meeting specified requirements
if (document.ltse.Had_Stem_Cell) 
{
//Check if user answered whether received intrathecal chemotherapies
if (document.ltse.Had_Stem_Cell[0].checked == false && document.ltse.Had_Stem_Cell[1].checked == false && document.ltse.Had_Stem_Cell[2].checked == false) 
{
missing_answers = missing_answers + "Se someten a un trasplante de medula osea o de celulas madre?\n";
errors_found++;
}
}

if (Page == 5) {


//Check if user answered whether they had radiation therapy
if (document.ltse.Had_Radiation[0].checked == false && document.ltse.Had_Radiation[1].checked == false) {

missing_answers = missing_answers + "Ha recibido terapia de radiacion?\n";

errors_found++;
}



var items_checked = 0;

var types_checked = 0;

var subtypes_checked = 0;

var type_value = "";

//Determine how many radiation types were selected
for(i=0; i<document.ltse.DiagnosisType.length; i++) {

if (document.ltse.DiagnosisType[i].checked == true) {

types_checked++;
}

//end for loop
}


//If user answered yes to having X-ray based radiation

if (types_checked > 0) 
{
for (var i=0; i < document.ltse.DiagnosisType.length; i++)
   {
   if (document.ltse.DiagnosisType[i].checked)
	  {
	  if (document.ltse.DiagnosisType[i].value == 1 && document.ltse.DiagnosisSubType[0].checked == false && document.ltse.DiagnosisSubType[1].checked == false && document.ltse.DiagnosisSubType[2].checked == false) 
		{

		missing_answers = missing_answers + "Que tipo de radiacion basada en rayos-x recibio?\n";
		errors_found++;

		}
	  }
   }
}


//If user answered yes to having radiation or radioiodine therapy, check to see if they selected areas areas of the body were included in the radiation fields

if (document.ltse.Had_Radiation[1].checked == true && types_checked == 0) {

missing_answers = missing_answers + "Que tipo de tratamiento recibio?\n";

errors_found++;
}


//Determine how many radiations were selected
for(i=0; i<document.ltse.Diagnosis.length; i++) {

if (document.ltse.Diagnosis[i].checked == true) {

items_checked++;
}

//end for loop
}





//If user answered yes to having radiation or radioiodine therapy, check to see if they selected areas areas of the body were included in the radiation fields

if (document.ltse.Had_Radiation[1].checked == true && items_checked == 0) 
{
	if (document.ltse.Other_Radiation.value == "")
	{
	missing_answers = missing_answers + "Que es el cancer / area fue su terapia de tratamiento?\n";
	errors_found++;
	}
}




//First make sure the form element exists on the page because a field may not exist due to not meeting specified requirements
if (document.ltse.Had_Radiation_Radioiodine_Therapy) 
	{

		//Check if user answered whether they had radioiodine therapy
		if (document.ltse.Had_Radiation_Radioiodine_Therapy[0].checked == false && document.ltse.Had_Radiation_Radioiodine_Therapy[1].checked == false) {
		
		missing_answers = missing_answers + "Ha recibido tratamiento con yodo radioactivo (I-131)?\n";
		
		errors_found++;
		}

//Make sure user doesn't select any radiations if they answered no to having radiation and radioiodine therapy

if (document.ltse.Had_Radiation_Radioiodine_Therapy[1].checked == true && document.ltse.Had_Radiation[0].checked == true && items_checked > 0) {

errors = errors + "Usted no puede seleccionar que tipo de tratamiento que recibio.\n";
}


}

if (document.ltse.Had_Genetic_Abnormality_Or_Syndrome)  
	{
		//Check if user answered whether they have been told the yhave a genetic abnormality or syndrome
		if (document.ltse.Had_Genetic_Abnormality_Or_Syndrome[0].checked == false && document.ltse.Had_Genetic_Abnormality_Or_Syndrome[1].checked == false) 
		{
		missing_answers = missing_answers + "Le han dicho que tienen una anomalía genética o el sindrome de?\n";
		errors_found++;
		}
	}
	
}


//Display errors if they're any

if (errors_found > 0) {

alert("Por favor, responda la siguiente pregunta (s)?\n\n" + missing_answers);

return false;
}

if (errors != "" && errors_found == 0) {

alert("Se encontro el siguiente error (s)?\n\n" + errors);

return false;
}


//end function
}

