// JScript File

servlet = "RiskAssessment.aspx";
_error_msg_history = "This tool cannot calculate breast cancer risk accurately for women with a medical history of any breast cancer or of DCIS or LCIS.";
_error_msg_current_age = "This tool only calculates risk for women 35 years of age or older.";
_error_msg_hist_age = "This tool cannot calculate breast cancer risk accurately for women with a medical history of breast cancer or of DCIS or LCIS. In addition, the tool only calculates risk for women 35 years of age or older.";
function checkAge() {
  if (document.risk.current_age.selectedIndex==1)
    alert(_error_msg_current_age);
}
function checkHistory() {
  if (document.risk.history.selectedIndex==1)
    alert(_error_msg_history);
}
function checkEthnicity() {
  if (document.risk.race.selectedIndex==2)
    { 
        //alert("Assessments for African American women may underestimate the chance of breast cancer and are subject to greater uncertainty than those for white women. Researchers are conducting additional studies, including studies with minority populations, to gather more data and to increase the accuracy of the tool for women in these populations."); 
        //dec282007 SRamaiah: this has been removed as the new model(CARE) is now in use for african american women
    }
  else if (document.risk.race.selectedIndex==3)  	
    { alert("Assessments for Hispanic women are subject to greater uncertainty than those for white and African American women. Researchers are conducting additional studies, including studies with minority populations, to gather more data and to increase the accuracy of the tool for women in these populations."); }
  else if (document.risk.race.selectedIndex==4)	
    { alert("Assessments for Asian or Pacific Islander women are uncertain and are based on data for white and African American women. Researchers are conducting additional studies, including studies with minority populations, to gather more data and to increase the accuracy of the tool for women in these populations."); }
  else if (document.risk.race.selectedIndex==5) 	
    { alert("Assessments for American Indian or Alaskan Native women are uncertain and are based on data for white women. Researchers are conducting additional studies, including studies with minority populations, to gather more data and to increase the accuracy of the tool for women in these populations."); }
  else if (document.risk.race.selectedIndex==6)
    { alert("This risk assessment was based on data for white females."); }
  //reset it to white female  
  //document.risk.race.selectedIndex=1;
}
function checkBiopsy() {
  if (document.risk.ever_had_biopsy.selectedIndex==1) { // Unknown
    document.risk.previous_biopsies.options.length = 0;
    document.risk.previous_biopsies.options[0] = new Option("n/a");
    document.risk.previous_biopsies.selectedIndex = 0;
    document.risk.previous_biopsies.options[0].value = 99;
    document.risk.biopsy_with_hyperplasia.options.length = 0;
    document.risk.biopsy_with_hyperplasia.options[0] = new Option("n/a");
    document.risk.biopsy_with_hyperplasia.selectedIndex = 0;
    document.risk.biopsy_with_hyperplasia.options[0].value = 99;
  }
  if (document.risk.ever_had_biopsy.selectedIndex==2) { // No
    document.risk.previous_biopsies.options.length = 0;
    document.risk.previous_biopsies.options[0] = new Option("n/a");
    document.risk.previous_biopsies.selectedIndex = 0;
    document.risk.previous_biopsies.options[0].value = 0;
    document.risk.biopsy_with_hyperplasia.options.length = 0;
    document.risk.biopsy_with_hyperplasia.options[0] = new Option("n/a");
    document.risk.biopsy_with_hyperplasia.selectedIndex = 0;
    document.risk.biopsy_with_hyperplasia.options[0].value = 0;
  }
  if (document.risk.ever_had_biopsy.selectedIndex==3) { // Yes
    document.risk.previous_biopsies.options[0] = new Option("Select");
    document.risk.previous_biopsies.options[0].value = 999;
    document.risk.previous_biopsies.options[1] = new Option("1");
    document.risk.previous_biopsies.options[1].value = 1;
    document.risk.previous_biopsies.options[2] = new Option("> 1");
    document.risk.previous_biopsies.options[2].value = 2;
    document.risk.previous_biopsies.selectedIndex = 0;
    document.risk.biopsy_with_hyperplasia.options[0] = new Option("Select");
    document.risk.biopsy_with_hyperplasia.options[0].value = 999;
    document.risk.biopsy_with_hyperplasia.options[1] = new Option("Unknown");
    document.risk.biopsy_with_hyperplasia.options[1].value = 99;
    document.risk.biopsy_with_hyperplasia.options[2] = new Option("No");
    document.risk.biopsy_with_hyperplasia.options[2].value = 0;
    document.risk.biopsy_with_hyperplasia.options[3] = new Option("Yes");
    document.risk.biopsy_with_hyperplasia.options[3].value = 1;
    document.risk.biopsy_with_hyperplasia.selectedIndex = 0;
//    document.reload();
  }
}
function calculateRiskAssessment() {


  if (document.risk.history.selectedIndex==0||
      document.risk.current_age.selectedIndex==0||
      document.risk.age_at_menarche.selectedIndex==0||
      document.risk.age_at_first_live_birth.selectedIndex==0||
      document.risk.related_with_breast_cancer.selectedIndex==0||
      document.risk.ever_had_biopsy.selectedIndex==0||
      document.risk.ever_had_biopsy.selectedIndex==3&&document.risk.previous_biopsies.selectedIndex==0||
      document.risk.ever_had_biopsy.selectedIndex==3&&document.risk.biopsy_with_hyperplasia.selectedIndex==0||
      document.risk.race.selectedIndex==0) {
        alert("All questions must be answered before the patient's risk can be calculated.");
      return;    
  }
  else if (document.risk.current_age.selectedIndex==1 && document.risk.history.selectedIndex==1){
    alert(_error_msg_hist_age);
    return;
  }
  else if (document.risk.history.selectedIndex==1){
    alert(_error_msg_history);
    return;
  }
  else if (document.risk.current_age.selectedIndex==1){
    alert(_error_msg_current_age);
    return;  
  }
  current_age = document.risk.current_age.options[document.risk.current_age.selectedIndex].value;
  age_at_menarche = document.risk.age_at_menarche.options[document.risk.age_at_menarche.selectedIndex].value;
  age_at_first_live_birth = document.risk.age_at_first_live_birth.options[document.risk.age_at_first_live_birth.selectedIndex].value;
  ever_had_biopsy = document.risk.ever_had_biopsy.options[document.risk.ever_had_biopsy.selectedIndex].value;
  previous_biopsies = document.risk.previous_biopsies.options[document.risk.previous_biopsies.selectedIndex].value;
  biopsy_with_hyperplasia = document.risk.biopsy_with_hyperplasia.options[document.risk.biopsy_with_hyperplasia.selectedIndex].value;
  related_with_breast_cancer = document.risk.related_with_breast_cancer.options[document.risk.related_with_breast_cancer.selectedIndex].value;
  race = document.risk.race.options[document.risk.race.selectedIndex].value;

  if (document.risk.race.selectedIndex==4)
    asian = "&asian=" + escape("It has been observed that recent immigrants from rural Asia may have a lower risk of breast cancer than calculated.");
  else
    asian = "";

  document.risk.submit();
}