
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 + "Sex\n";

errors_found++;
}

//Check if user selected a race
if (document.ltse.Race.selectedIndex == 0) {

missing_answers = missing_answers + "Race\n";

errors_found++;
}

//Check if user selected a race
if (document.ltse.Diagnosis_Age.selectedIndex == 0) {

missing_answers = missing_answers + "Age at Diagnosis\n";

errors_found++;
}

//Check if user selected a race
if (document.ltse.Current_Age.selectedIndex == 0) {

missing_answers = missing_answers + "Current Age\n";

errors_found++;
}

//Check if user selected a race
if (document.ltse.Education.selectedIndex == 0) {

missing_answers = missing_answers + "Highest Education Level\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 + "Your current age can't be younger than your age at diagnosis.\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 + "Healthcare Prodiver Type\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 + "Phsyician Type\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 + "Who is currently managing your healthcare needs?\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 + "Specify who is currently managing your healthcare needs\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 + "What is your geographical location?\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 + "Select State\n";

errors_found++;
}

}


//Canada geographical check

if (document.ltse.Country[1].checked == true && document.ltse.Province.selectedIndex == 0) {

missing_answers = missing_answers + "Select Province\n";

errors_found++;
}

//Other country geographical check

if (document.ltse.Country[2].checked == true && document.ltse.Other_Country.selectedIndex == 0) {

missing_answers = missing_answers + "Please Select Country\n";

errors_found++;
}

//Check if user selected Survivor Health
if (document.ltse.Offering_Survivorship_Health.selectedIndex == 0) {

missing_answers = missing_answers + "Have you (or the patient) ever been offered survivorship health information before?\n";

errors_found++;
}

//Check if user selected Survivor Health
if (document.ltse.Treatment_Summary.selectedIndex == 0) {

missing_answers = missing_answers + "Have you ever received a treatment summary?\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 + "Where do you consider yourself living?\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 + "Where have you received most of your cancer care? \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 + "How far do you live from the cancer center?\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 + "What is your menopausal status?\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 + "Was postmenopausal due to surgery, chemotherapy or radiation therapy?\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("We found the following error(s)?\n\n" + errors);

return false;
}


//end function
}

function Check_Age() {


if (document.ltse.Current_Age.selectedIndex == 1) {

var agree=confirm("Are you really under 18?");

if (agree) {

location.href='questions.cfm?Page=7';
}

else {

return false;
}


}


if (document.ltse.Diagnosis_Age.selectedIndex == 1) {


var agree=confirm("Were you really diagnosed earlier than the age of under 18?");

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) 
{
var el=document.getElementById('Health_Care_Providers');el.style.display='block';
var el=document.getElementById('Patient_Family_Plan_Created');el.style.display='none';
} else {
var el=document.getElementById('Health_Care_Providers');el.style.display='none';
var el=document.getElementById('Phsyician_Types');el.style.display='none';
var el=document.getElementById('Patient_Family_Plan_Created');el.style.display='block';
}


//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='block';
} 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='block';
}

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='block';
}

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 + "What type of cancer/s did you have?\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 + "What was your Age at Diagnosis?\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 + "Your Diagnosis Age cannot be older than your Current Age.\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 + "Did you undergo surgery for this cancer?\n";

errors_found++;
}

//Determine how many sugeries were selected

var items_checked = 0;

for(i=0; i<document.ltse.Surgeries.length; i++) {

if (document.ltse.Surgeries[i].checked == true) {

items_checked++;
}

//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 + "Which surgical procedure did you have?\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 + "*You may not select any surgeries.\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 + "Did you receive IV (administered into your vein) or oral (by mouth) chemotherapy?\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 + "What chemotherapies did you receive?\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 + "You may not select any chemotherapies or write in other therapy received for chemotherapies.\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 + "Did you receive intrathecal chemotherapy (administered into your spinal fluid)?\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 + "What intrathecal chemotherapies did you receive?\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 + "*You may not select any intrathecal chemotherapies or write in other therapy received for intrathecal chemotherapies.\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 + "Did you receive Intravesicular Chemotherapy (Given directly into the bladder)?\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 + "What intravesicular chemotherapies did you receive?\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 + "*You may not select any intravesicular chemotherapies or write in other therapy received for intravesicular chemotherapies.\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 + "Did you undergo a bone marrow or stem cell transplant?\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 + "Did you receive radiation therapy?\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 + "What type of X-ray based Radiation did you receive?\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 + "What type of treatment did you receive?\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 + "What cancer / area was your therapy treating?\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 + "Did you receive radioiodine therapy (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 + "*You may not select what type of treatment you received.\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 + "Have you been told you have a genetic abnormality or syndrome?\n";
		errors_found++;
		}
	}
	
}


//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("We found the following error(s)?\n\n" + errors);

return false;
}


//end function
}
