function GetParams() {
	//alert("called GetParams");
    var sLocation = new String(window.location);     //property contains domain, directory, 
                                                     //filename of the document plus the params (and the "?" before the params).
    var sParamsList = new String(sLocation.substr(sLocation.lastIndexOf("?")+1));
    //var newParamsList =  sParamsList.split('#');
        
    if (sParamsList.search("#") != -1) {	
    	
        var newParamsList =  sParamsList.substring(0, sParamsList.search("#"));
    }
    else { var newParamsList = new String(sParamsList); }
    
    //alert (sParamsList);
    //alert (newParamsList);
            
    return newParamsList.split('&');
}

function changeDataOptions() {
	var VisibleForm = document.UserForm;
	var CurrentGeo = VisibleForm.GeoAreaBox; //will need to be changed to StateBox for other graphs
	var CurrentCancer = VisibleForm.CancerBox; //will need to be changed to StateBox for other graphs
	var CurrentIncdMort = VisibleForm.IncdMortBox;
	
	var CurrentSelectedIndex = CurrentIncdMort.selectedIndex;
	//alert ("CurrentSelectedIndex = "+CurrentSelectedIndex);
	if (CurrentSelectedIndex == -1) {
		CurrentSelectedIndex = 0;
	}
	var CurrentSelected = CurrentIncdMort.options[CurrentSelectedIndex].text;
	
	var CurrentGeoSelectedIndex = CurrentGeo.selectedIndex;
	//alert ("CurrentSelectedIndex = "+CurrentSelectedIndex);
	if (CurrentGeoSelectedIndex == -1) {
		CurrentGeoSelectedIndex = 0;
	}
	var CurrentGeoSelected = CurrentGeo.options[CurrentGeoSelectedIndex].value;
	
	
	var CurrentCancerSelectedIndex = CurrentCancer.selectedIndex;
	//alert ("CurrentSelectedIndex = "+CurrentSelectedIndex);
	if (CurrentCancerSelectedIndex == -1) {
		CurrentCancerSelectedIndex = 0;
	}
	var CurrentCancerSelected = CurrentCancer.options[CurrentCancerSelectedIndex].value;
	
	var reg = CurrentGeoSelected.substring(0, 2); //from 0 to 1
	var state = CurrentGeoSelected.substring(2,4); // from 2 to 3

	CurrentIncdMort.length=0;
	
	CurrentIncdMort.options[0] = new Option(CHOOSE_BEGINNING + "choose data type" + CHOOSE_END);
	CurrentIncdMort.options[0].value = "*";         
	var counter = 1;
	if (reg != "99") {
		CurrentIncdMort.options[counter] = new Option("Incidence");
		CurrentIncdMort.options[counter].value = "1";
		counter++;
	}
	if (state != "99") { // && (CurrentCancerSelected != '400') ) { // can't display mortality for in situ breast
		CurrentIncdMort.options[counter] = new Option("Mortality");
		CurrentIncdMort.options[counter].value = "2";
		counter++;
	}		
	
	CurrentCancer.length=0;
	
	CurrentCancer.options[0] = new Option(CHOOSE_BEGINNING + "choose cancer" + CHOOSE_END);
	CurrentCancer.options[0].value = "***";
	var counter=1;
	
	
	CurrentCancer.options[counter] = new Option("All Cancer Sites");
	CurrentCancer.options[counter].value = "001";
	counter++;
	CurrentCancer.options[counter] = new Option("Bladder");
	CurrentCancer.options[counter].value = "071";
	counter++;
	CurrentCancer.options[counter] = new Option("Brain & ONS");
	CurrentCancer.options[counter].value = "076";
	counter++;
	CurrentCancer.options[counter] = new Option("Breast (Female)");
	CurrentCancer.options[counter].value = "055";
	counter++;
	
	
	if (reg != "99") {
		CurrentCancer.options[counter] = new Option("Breast (Female in situ)");
		CurrentCancer.options[counter].value = "400";
		counter++;
	}
	
	
	CurrentCancer.options[counter] = new Option("Cervix");
	CurrentCancer.options[counter].value = "057";
	counter++;	
	
		//<OPTION VALUE="515">Childhood (Ages <20, All Sites)
		//<OPTION VALUE="516">Childhood (Ages <15, All Sites)
	
	
	CurrentCancer.options[counter] = new Option("Childhood (Ages <15, All Sites)");
	CurrentCancer.options[counter].value = "516";
	counter++;		
	CurrentCancer.options[counter] = new Option("Childhood (Ages <20, All Sites)");
	CurrentCancer.options[counter].value = "515";
	counter++;	
	CurrentCancer.options[counter] = new Option("Colon & Rectum");
	CurrentCancer.options[counter].value = "020";
	counter++;
	CurrentCancer.options[counter] = new Option("Esophagus");
	CurrentCancer.options[counter].value = "017";
	counter++;
	CurrentCancer.options[counter] = new Option("Kidney & Renal Pelvis");
	CurrentCancer.options[counter].value = "072";
	counter++;
	CurrentCancer.options[counter] = new Option("Leukemia");
	CurrentCancer.options[counter].value = "090";
	counter++;
	CurrentCancer.options[counter] = new Option("Liver & Bile Duct");
	CurrentCancer.options[counter].value = "035";
	counter++;
	CurrentCancer.options[counter] = new Option("Lung & Bronchus");
	CurrentCancer.options[counter].value = "047";
	counter++;
	CurrentCancer.options[counter] = new Option("Melanoma of the Skin");
	CurrentCancer.options[counter].value = "053";
	counter++;
	CurrentCancer.options[counter] = new Option("Non-Hodgkin Lymphoma");
	CurrentCancer.options[counter].value = "086";
	counter++;
	CurrentCancer.options[counter] = new Option("Oral Cavity & Pharynx");
	CurrentCancer.options[counter].value = "003";
	counter++;
	CurrentCancer.options[counter] = new Option("Ovary");
	CurrentCancer.options[counter].value = "061";
	counter++;
	CurrentCancer.options[counter] = new Option("Pancreas");
	CurrentCancer.options[counter].value = "040";
	counter++;
	CurrentCancer.options[counter] = new Option("Prostate");
	CurrentCancer.options[counter].value = "066";
	counter++;
	CurrentCancer.options[counter] = new Option("Stomach");
	CurrentCancer.options[counter].value = "018";
	counter++;
	CurrentCancer.options[counter] = new Option("Thyroid");
	CurrentCancer.options[counter].value = "080";
	counter++;
	CurrentCancer.options[counter] = new Option("Uterus");
	CurrentCancer.options[counter].value = "058";
	counter++;
	
		
	for (i = 0; i<CurrentIncdMort.length; i++) {
	//		alert ("AreaObject.options[i] = _"+ AreaObject.options[i].text+"_");//, value = "+AreaObject.options[i].value);
				if (CurrentIncdMort.options[i].text == CurrentSelected) {
					CurrentIncdMort.selectedIndex = i;
					break;
				}
		}	
	for (i = 0; i<CurrentCancer.length; i++) {
	//		alert ("AreaObject.options[i] = _"+ AreaObject.options[i].text+"_");//, value = "+AreaObject.options[i].value);
				if (CurrentCancer.options[i].value == CurrentCancerSelected) { // using value here, not text
					CurrentCancer.selectedIndex = i;
					break;
				}
		}	
}    

function changeDataOptions2() { // if in situ breast is selected then mortality can't be an option
	
	var VisibleForm = document.UserForm;
	var CurrentGeo = VisibleForm.GeoAreaBox; //will need to be changed to StateBox for other graphs
	var CurrentCancer = VisibleForm.CancerBox; //will need to be changed to StateBox for other graphs
	var CurrentIncdMort = VisibleForm.IncdMortBox;
	
	var CurrentSelectedIndex = CurrentIncdMort.selectedIndex;
	//alert ("CurrentSelectedIndex = "+CurrentSelectedIndex);
	if (CurrentSelectedIndex == -1) {
		CurrentSelectedIndex = 0;
	}
	var CurrentSelected = CurrentIncdMort.options[CurrentSelectedIndex].text;
	
	var CurrentGeoSelectedIndex = CurrentGeo.selectedIndex;
	//alert ("CurrentSelectedIndex = "+CurrentSelectedIndex);
	if (CurrentGeoSelectedIndex == -1) {
		CurrentGeoSelectedIndex = 0;
	}
	var CurrentGeoSelected = CurrentGeo.options[CurrentGeoSelectedIndex].value;
	
	
	var CurrentCancerSelectedIndex = CurrentCancer.selectedIndex;
	//alert ("CurrentSelectedIndex = "+CurrentSelectedIndex);
	if (CurrentCancerSelectedIndex == -1) {
		CurrentCancerSelectedIndex = 0;
	}
	var CurrentCancerSelected = CurrentCancer.options[CurrentCancerSelectedIndex].value;
	
	var reg = CurrentGeoSelected.substring(0, 2); //from 0 to 1
	var state = CurrentGeoSelected.substring(2,4); // from 2 to 3

	CurrentIncdMort.length=0;
	
	CurrentIncdMort.options[0] = new Option(CHOOSE_BEGINNING + "choose data type" + CHOOSE_END);
	CurrentIncdMort.options[0].value = "*";         
	var counter = 1;
	if (reg != "99") {
		CurrentIncdMort.options[counter] = new Option("Incidence");
		CurrentIncdMort.options[counter].value = "1";
		counter++;
	}
	if (  (state != "99")  && (CurrentCancerSelected != '400') ) { // can't display mortality for in situ breast
		CurrentIncdMort.options[counter] = new Option("Mortality");
		CurrentIncdMort.options[counter].value = "2";
		counter++;
	}	
	
	CurrentIncdMort.selectedIndex = CurrentSelectedIndex	;
	
}


   

function verifyCheckBoxes() {
	var formObj = document.UserForm;
	
	
	//var Cancer = formObj.CancerBox.value;
    var list = formObj.CancerBox
	var index = list.selectedIndex;
	var Cancer = list.options[index].value;
	
//	var DataType = formObj.IncdMortBox.value;
    var list = formObj.IncdMortBox
	var index = list.selectedIndex;
	var DataType = list.options[index].value;
	
	//var Geo =      formObj.GeoAreaBox.value;
    var list = formObj.GeoAreaBox
	var index = list.selectedIndex;
	var Geo = list.options[index].value;
	
   //var Race =     formObj.RaceBox.value;
    var list = formObj.RaceBox
	var index = list.selectedIndex;
	var Race = list.options[index].value;
	
//	var Age =      formObj.AgeBox.value;
    var list = formObj.AgeBox
	var index = list.selectedIndex;
	var Age = list.options[index].value;
	
	//var Sex = formObj.GenderBox.value;
    var list = formObj.GenderBox
	var index = list.selectedIndex;
	var Sex = list.options[index].value;
	
	var okToSubmit = 0;
	var listForError = "";
	
	if (Geo == "**") {
		listForError = listForError + "Area\n";
	}
	if (Cancer == "***") {
		listForError = listForError + "Cancer\n";
	}
	//if (Period == "*") {
	//	listForError = listForError + "Period\n";
	//}
	if (DataType == "*") {
		listForError = listForError + "Data\n";
	}
	if (Race == "**") {
		listForError = listForError + "Race\n";
	}
	if (Sex == "*") {
		listForError = listForError + "Sex\n";
	}
	if (Age == "***") {
		listForError = listForError + "Age\n";
	}
	
	//alert (listForError);
	
	//return okToSubmit;
	return listForError;
}


function submitQueryString() {	
	//alert("in submitQueryString");
   var formObj = document.UserForm;
   //var Race =     formObj.RaceBox.value;
    var list = formObj.RaceBox
	var index = list.selectedIndex;
	var Race = list.options[index].value;
	
//	var Age =      formObj.AgeBox.value;
    var list = formObj.AgeBox
	var index = list.selectedIndex;
	var Age = list.options[index].value;
	
	//var Sex = formObj.GenderBox.value;
    var list = formObj.GenderBox
	var index = list.selectedIndex;
	var Sex = list.options[index].value;
	
	//var Sex =      formObj.GenderBox.value;
//	var DataType = formObj.IncdMortBox.value;
    var list = formObj.IncdMortBox
	var index = list.selectedIndex;
	var DataType = list.options[index].value;
	
	//var Geo =      formObj.GeoAreaBox.value;
    var list = formObj.GeoAreaBox
	var index = list.selectedIndex;
	var Geo = list.options[index].value;
	
	var County = 999;//formObj.CountyBox.value;
	var Report = 0;
	var YearGroup = 7599;
	//var Cancer = formObj.CancerBox.value;
    var list = formObj.CancerBox
	var index = list.selectedIndex;
	var Cancer = list.options[index].value;
	
	var Output = 0;
	var Explanation = 0;
	var Period;
	if (Race > 2) {
		Period = 1; //90-99
	}
	//these aren't in there right now because the 90 and 91 data is not dependable
	//else if (Geo == "5299") { 
	//	Period = 1;
	//}
	//else if (Geo == "5199") {
	//	Period = 1;
	//}
	//else if (Geo == "3599") { 
	//	Period = 1;
	//}
	//else if (Geo == "3199") {
	//	Period = 1;
	//}
	else {
		Period = 0; //75-99
	}
	
	//now defaulting to on
	var CurrentPointsVisible = formObj.PointsVisibleBox;
	var pointsVisible = "";
	if (CurrentPointsVisible.checked == true) {
		pointsVisible = 1;
	}
	else {
		pointsVisible = 0;
	}
	//var pointsVisible = 1;//formObj.PointsVisible.checked;
	var numLines = 1;
//alert ("geo = "+Geo);
	var queryString = Report +"&"+Geo+"&"+County+"&"+YearGroup+"&"+Age+"&"+Cancer+"&"+Race+"&"+Sex+"&"+Output+"&"+Explanation+"&"+DataType+"&"+Period+"&"+pointsVisible+"&"+numLines;//+"&"+Scales;
//	alert ("querystring is");
//	alert (queryString);
	formObj.target='_self';
   formObj.action = "joinpoint.withimage.php?"+queryString+"#graph";
 //  alert (formObj.target);
  // alert (formObj.action);
  
   var listForError = verifyCheckBoxes() ;
		
	if (listForError != "") {
		//alert("All variables must have a selection to create this graph.\n\nPlease make a selection for the following variable(s): \n"+listForError);
		alert("Please make a selection for each category before continuing.");
	}
	else {
		//alert ("Geo = "+Geo);
		//var hispProblem = 0;
  		//if (Race == '05' && DataType == '2') {
  		//	if (DataType == '1') {
  				// now seattle and hawaii, not detroit and hawaii - NL 4/5/2006
  		//		if ((Geo == '2599') || (Geo == '2115') ) {  //|| (Geo == '0209') || (Geo == '9940') || (Geo == '9933') || (Geo == '9936') ) {
  		//			hispProblem++;
  		//			//alert ("hispanic problem - " + Geo);
  		//		}
  		//	}
  		//	else if (DataType == '2') {
  			//	if ( (Geo == '0209') || (Geo == '9940') || (Geo == '9933') || (Geo == '9936') ) {
  			//		hispProblem++;
  			//	}
  		//	}
  	//}
	  var genderMixup = 0;
		if ((Cancer == '055') && (Sex != '2')) {
			genderMixup++;
		}
		else if ((Cancer == '057') && (Sex != '2')) {
			genderMixup++;
		}
		else if ((Cancer == '066') && (Sex != '1')) {
			genderMixup++;
		}
	//can't draw if there's a gender mixup	
	//if (hispProblem > 0) {
	 //  	alert ("Hispanic data is not available for the geographic area/data type combination that you have selected.");
	  // }	
	   if (genderMixup > 0) {
	   	alert("The report that you requested is not available.  Please select an appropriate cancer/sex combination.");
	   }
	  else {
	  	formObj.submit();
	}//else no gender mixup or problem with the Hispanic selection
	}// else boxes < 7
}

function changeSample() {
	//alert ("in change sample");
 	var points = document.UserForm.PointsVisibleBox.checked;
 	//alert ("points = "+points);
   	if (points == true) {
   	  document.images[13].border=0;
   	  document.images[13].src="sample.png";
   	}
   	else {
   	//	alert ("in points == false");
   		document.images[13].border=0;
   		document.images[13].src = "nopoints.sample.png";
   	//	alert ("just switched image");
  	}	
}


function changeSex() {
	//alert("in changeSex()");
	//var cancer = document.UserForm.CancerBox.value;
	
    var list = document.UserForm.CancerBox
	var index = list.selectedIndex;
	var cancer = list.options[index].value;
	
	var genderBox = document.UserForm.GenderBox;
	var current=genderBox.selectedIndex;
	var currentGender = genderBox.options[current].value;
	if (  (cancer == '055') || (cancer == '057') || (cancer == '058') || (cancer == '061') || (cancer == '400')  )  {
		genderBox.length = 0;
		genderBox.options[0] = new Option("Females");
		genderBox.options[0].value = "2";
		genderBox.selectedIndex = 0; //female
		genderBox.disabled = true;
	}
	else if (cancer == '066') {
		genderBox.length = 0;
		genderBox.options[0] = new Option("Males");
		genderBox.options[0].value = "1";
		genderBox.selectedIndex = 0; //male
		genderBox.disabled = true;
	}
	else {
		genderBox.disabled = false;
		genderBox.length = 0;
		genderBox.options[0] = new Option(CHOOSE_BEGINNING + "choose sex" + CHOOSE_END);
		genderBox.options[0].value = "*";
		genderBox.options[1] = new Option("Both Sexes");
		genderBox.options[1].value = "0";
		genderBox.options[2] = new Option("Males");
		genderBox.options[2].value = "1";
		genderBox.options[3] = new Option("Females");
		genderBox.options[3].value = "2";
		
		genderBox.selectedIndex = 0; 
		for (i=0; i<genderBox.length; i++) {
			if (genderBox.options[i].value == currentGender) {
				genderBox.selectedIndex=i;
				break;
			}
		}
	}//else
		
}

function changeAge() {
	//alert("in changeSex()");
	//var cancer = document.UserForm.CancerBox.value;
	
    var list = document.UserForm.CancerBox
	var index = list.selectedIndex;
	var cancer = list.options[index].value;
	
	var ageBox = document.UserForm.AgeBox;
	var current=ageBox.selectedIndex;
	var currentAge = ageBox.options[current].value;
	if   (cancer == '515')  {
		ageBox.length = 0;
		ageBox.options[0] = new Option("<20");
		ageBox.options[0].value = "015";
		ageBox.selectedIndex = 0; //female
		ageBox.disabled = true;
	}
	else if (cancer == '516') {
		ageBox.length = 0;
		ageBox.options[0] = new Option("<15");
		ageBox.options[0].value = "016";
		ageBox.selectedIndex = 0; //male
		ageBox.disabled = true;
	}
	else {
		ageBox.disabled = false;
		ageBox.length = 0;
		ageBox.options[0] = new Option(CHOOSE_BEGINNING + "choose age group" + CHOOSE_END);
		ageBox.options[0].value = "***";
		ageBox.options[1] = new Option("All Ages");
		ageBox.options[1].value = "001";
		ageBox.options[2] = new Option("<50");
		ageBox.options[2].value = "009";
		ageBox.options[3] = new Option("50+");
		ageBox.options[3].value = "136";
		ageBox.options[4] = new Option("<65");
		ageBox.options[4].value = "006";
		ageBox.options[5] = new Option("65+");
		ageBox.options[5].value = "157";
		
		ageBox.selectedIndex = 0; 
		for (i=0; i<ageBox.length; i++) {
			if (ageBox.options[i].value == currentAge) {
				ageBox.selectedIndex=i;
				break;
			}
		}
	}//else
		
}






function submitQueryString2() {	
	//alert("in submitQueryString2()");
	var paramArray = GetParams();
	var numLines = paramArray[13];
//	alert ("old number of lines = "+numLines);
	numLines++;
	if (numLines == 11) {
		numLines = 21; // use 21 so it's easy to make it go up to 20 if they want
	}
	else if (numLines == 31) {  // this is kind of like line 10 since we start over at 21
		numLines = 21;
	}
	//alert ("new numLines = "+numLines);
	paramArray[13] = numLines;
   var formObj = document.UserForm;
    var list = formObj.RaceBox
	var index = list.selectedIndex;
	var Race = list.options[index].value;
	
//	var Age =      formObj.AgeBox.value;
    var list = formObj.AgeBox
	var index = list.selectedIndex;
	var Age = list.options[index].value;
	
	//var Sex = formObj.GenderBox.value;
    var list = formObj.GenderBox
	var index = list.selectedIndex;
	var Sex = list.options[index].value;
	
	//var Sex =      formObj.GenderBox.value;
//	var DataType = formObj.IncdMortBox.value;
    var list = formObj.IncdMortBox
	var index = list.selectedIndex;
	var DataType = list.options[index].value;
	
	//var Geo =      formObj.GeoAreaBox.value;
    var list = formObj.GeoAreaBox
	var index = list.selectedIndex;
	var Geo = list.options[index].value;
//	var County =     999;//formObj.CountyBox.value;
//	var Report = 0;
//	var YearGroup = 7599;
	//var CancerSite = formObj.CancerBox.value;//999;
    var list = formObj.CancerBox
	var index = list.selectedIndex;
	var Cancer = list.options[index].value;
	//var Period = formObj.PeriodBox.value;
	var Period;
	if (Race > 2) {
		Period = 1; //90-99
	}
	else if (Geo == "5299") { 
		Period = 1;
	}
	else if (Geo == "5199") {
		Period = 1;
	}
	else if (Geo == "3599") {
		Period = 1;
	}
	else if (Geo == "3199") {
		Period = 1;
	}
	else {
		Period = 0; //75-99
	}
	
//	var Output = 0;
//	var Explanation = 0;
//alert ("geo = "+Geo);
	//var queryString = Report +"&"+Geo+"&"+County+"&"+YearGroup+"&"+Age+"&"+CancerSite+"&"+Race+"&"+Sex+"&"+Output+"&"+Explanation+"&"+Type;//+"&"+Scales;
	var paramString = paramArray.join('&');
   var lineToDraw = Geo+"!"+Age+"!"+Cancer+"!"+Race+"!"+Sex+"!"+DataType+"!"+Period;
	var queryString = paramString+"&"+lineToDraw;
	
	 var listForError = verifyCheckBoxes() ;
		
	if (listForError != "") {
		//alert("All variables must have a selection to create this graph.\n\nPlease make a selection for the following variable(s): \n"+listForError);
		alert("Please make a selection for each category before continuing.");
	}
	else {
	
		//check for same line
		var line1 = paramArray[1]+"!"+paramArray[4]+"!"+paramArray[5]+"!"+paramArray[6]+"!"+paramArray[7]+"!"+paramArray[10]+"!"+paramArray[11];
		//1 and 3 are the two different incidence numbers
		if (   (paramArray[10] == "1") || (paramArray[10] == "3") ) {
			var line1a = paramArray[1]+"!"+paramArray[4]+"!"+paramArray[5]+"!"+paramArray[6]+"!"+paramArray[7]+"!1!"+paramArray[11];
			var line1b = paramArray[1]+"!"+paramArray[4]+"!"+paramArray[5]+"!"+paramArray[6]+"!"+paramArray[7]+"!3!"+paramArray[11];
		}
		else {
			var line1a = "";
			var line1b = "";
		}
		
		var duplicateWarning =0;
		numLinesToCheck = numLines;
		
		if (numLinesToCheck > 20) {
			numLinesToCheck = numLinesToCheck - 20;
		}
		//now numLinesToCheck is one greater than the number of spots we have to check in paramArray
		
		//alert ("line 1 = " + line1 + "\n" + "line 1a = "+line1a+"\n"+"line 1b = "+line1b+"\n"+"line to draw = "+lineToDraw);
		
		
		if (line1 == lineToDraw) {
			duplicateWarning++;
		}
		else if (line1a == lineToDraw) {
			duplicateWarning++; 
		}
		else if (line1b == lineToDraw) {
			duplicateWarning++;
		}
		var paramNum = 14; //first line
		for (var i = 0; i<numLinesToCheck; i++) {
			if (lineToDraw == paramArray[paramNum]) {
				duplicateWarning++;
			}
			paramNum++;
		}
		formObj.target='_self';
	   formObj.action = "joinpoint.withimage.php?"+queryString+"#graph";
   
   	//var hispProblem = 0;
  	//	if (Race == '05') {
  	//		if (DataType == '1') {
  	//			// now seattle and hawaii, not detroit and hawaii - NL 4/5/2006
  	//			if ((Geo == '2599') || (Geo == '2115') ) {  //|| (Geo == '0209') || (Geo == '9940') || (Geo == '9933') || (Geo == '9936') ) {
  	//				hispProblem++;
  	//				//alert ("hispanic problem - " + Geo);
  	//			}
  	//		}
  		//	else if (DataType == '2') {
  		//		if ( (Geo == '0209') || (Geo == '9940') || (Geo == '9933') || (Geo == '9936') ) {
  		//			hispProblem++;
  		//		}
  		//	}
  		//}
   
	     var genderMixup = 0;
		if ((Cancer == '055') && (Sex != '2')) {
			genderMixup++;
		}
		else if ((Cancer == '057') && (Sex != '2')) {
			genderMixup++;
		}
		else if ((Cancer == '066') && (Sex != '1')) {
			genderMixup++;
		}
	//can't draw if there's a gender mixup	
		//if (hispProblem > 0) {
	  // 	alert ("Hispanic data is not available for the geographic area/data type combination that you have selected.");
	  // }
		 if (duplicateWarning > 0) {
	   	alert("You are trying to draw a line that already exists.  Please either make another selection or clear the graph and start over.");
	   }
	   
	   else if (genderMixup > 0) {
	   	alert("The report that you requested is not available.  Please select an appropriate cancer/sex combination.");
	   }//can't draw if it's a duplicate line
	   else {
	   	if  (numLines > 10)  {
	   		//if (numLines == 21) {
	   			alert ("Maximum number of lines for this graph has been exceeded.  \nUse either Undo Last or Clear All to display new selection.");

	   			//baccept=window.confirm('You have reached the maximum number of lines that this graph can handle.  If you click ok, from this point forward new lines will replace the old ones (in the order in which they were drawn).  If you click cancel you will go back and be allowed to clear the graph.');
	   	   	//accept=(baccept)?1:0;
	   	 //  }
	   	   //else {
	   	   //	accept = 1;
	   	   //}
	   	   //alert (accept);
	   	   //if (accept) {
	   	   //	lineString = numLines+"";
	   	   //	lineNumber = lineString.substring(1,2);
	   	   //	//alert(lineNumber);
	   	   //	//var line1 = paramArray[1]+"!"+paramArray[4]+"!"+paramArray[5]+"!"+paramArray[6]+"!"+paramArray[7];
	   	   //	//var lineToDraw = Geo+"!"+Age+"!"+CancerSite+"!"+Race+"!"+Sex;
				//	if (lineNumber == "1") {
				//		paramArray[1] = Geo;
				//		paramArray[4] = Age;
				//		paramArray[5] = Cancer;
				//		paramArray[6] = Race;
				//		paramArray[7] = Sex;
				//		paramArray[10] = DataType;
				//		paramArray[11] = Period;
				//	}
				//	else {
				//		//2 -> 13, 3->14 therefore add 11
				//		var paramIndex = lineNumber*1 + 12; //moved this up to 12 to see if that fixes the numline situation
				//		paramArray[paramIndex] = Geo+"!"+Age+"!"+Cancer+"!"+Race+"!"+Sex+"!"+DataType+"!"+Period;
				//	}
				//	
				//	
				//	var queryString = paramArray.join('&');
				//	formObj.target='main';
	  			//	formObj.action = "joinpoint.withimage.php?"+queryString;
				//	formObj.submit();
				//}
				//else {
				//	//do nothing
				//}
	   	}
	   	else {
	   		formObj.submit();
	   	}
	   }// else no duplicate warning
	   
	   
	  // alert (formObj.target);
	  // alert (formObj.action);
	   //formObj.submit();
	}//checkboxes
}
/*
function changeSex() {
	var cancer = document.UserForm.CancerBox.value;
	var genderBox = document.UserForm.GenderBox;
	if (cancer == '055') {
		genderBox.selectedIndex = 3; //female
		//changeToFemale();
	}
	else if (cancer == '057') {
		genderBox.selectedIndex = 3; //female
		//changeToFemale();
	}
	else if (cancer == '066') {
		genderBox.selectedIndex = 2; //male
		//changeToMale();
	}
}
*/
function changeCurrentPoints() {
//	alert("in changeCurrentPoints()");
	UpdateSelectedNoPoints();
	var formObj = document.UserForm;
	var pointsVisible = formObj.PointsVisibleBox;
	
	paramArray = GetParams();
	//paramArray[12] = paramArray[12] + 1;
	var numLines = paramArray[13];
	
	//var queryString = Report +"&"+Geo+"&"+County+"&"+YearGroup+"&"+Age+"&"+CancerSite+"&"+Race+"&"+Sex+"&"+Output+"&"+Explanation+"&"+Type;//+"&"+Scales;
	var CurrentPointsVisibleHidden = paramArray[12];//formObj.pointsvisible;
	if ( (CurrentPointsVisibleHidden == 0)  && (pointsVisible.checked == true) ) { // they were off and the person clicked to have them on
		paramArray[12] = 1;
	}
	else if  ( (CurrentPointsVisibleHidden == 1)  && (pointsVisible.checked == false) ) { // they were on and the person clicked to have them off
		paramArray[12] = 0;
		}
	//formObj.changingPoints.value = true;
	var paramString = paramArray.join('&');
	var queryString = paramString;//+"&"+Geo+"!"+Age+"!"+CancerSite+"!"+Race+"!"+Sex;
	
	
	formObj.action = "joinpoint.withimage.php?"+queryString;
	var CurrentPointsVisible = formObj.PointsVisibleBox;
	//paramArray = GetParams();
	
	formObj.target='_self';
	formObj.submit(); //doing it here instead of in drawOnClick because we know we have a duplicate
}
	
	
function clearGraph() {	
   //document.location="joinpoint.cleargraph.html";
   document.location="joinpoint.noimage.html";
}




/*
$Report 	=  @lst_data[0]; 
$State	 	=  @lst_data[1]; 
$County	 	=  @lst_data[2]; 
$YearGroup	=  @lst_data[3]; 
$Age	 	=  @lst_data[4]; 
$CancerSite 	=  @lst_data[5]; 
$Race	 	=  @lst_data[6]; 
$Sex	 	=  @lst_data[7]; 
$Output 	=  @lst_data[8]; 
$Explanation 	=  @lst_data[9]; 
$Type = @lst_data[10];
$Period = @lst_data[11];
*/

function UpdateSelectedNoPoints() {
	//alert ("in UpdateSelectedNoPoints");

   	paramArray = GetParams();
	
   var VisibleForm = document.UserForm;
	
	var CurrentRace = VisibleForm.RaceBox;
	var CurrentAge = VisibleForm.AgeBox;
	var CurrentGender = VisibleForm.GenderBox;
	var CurrentIncdMort = VisibleForm.IncdMortBox;
	var CurrentGeo = VisibleForm.GeoAreaBox;
	var CurrentCancer = VisibleForm.CancerBox;
	var CurrentPointsVisible = VisibleForm.PointsVisibleBox;
//	var CurrentPeriod = VisibleForm.PeriodBox;
	
	if (paramArray[13] == 1) {
		var CurrentRaceHidden = paramArray[6];
		var CurrentAgeHidden = paramArray[4];
		var CurrentGenderHidden = paramArray[7];
		var CurrentGeoHidden = paramArray[1];
		var CurrentCancerHidden = paramArray[5];
		var CurrentIncdMortHidden = paramArray[10];
//		var CurrentPeriodHidden = paramArray[11];
	}
	else {
		var dataString = paramArray[paramArray.length - 1];
		var poundArray = dataString.split('#');
		var dataString = poundArray[0];
		var dataArray = dataString.split('!');
		//var queryString = paramString+"&"+Geo+"!"+Age+"!"+CancerSite+"!"+Race+"!"+Sex;
		//												  0		1				2				3			4
		var CurrentRaceHidden =   dataArray[3];
		var CurrentAgeHidden =    dataArray[1];
		var CurrentGenderHidden = dataArray[4];
		var CurrentGeoHidden =  dataArray[0];
		var CurrentCancerHidden = dataArray[2];
		var CurrentIncdMortHidden = dataArray[5];
//		var CurrentPeriodHidden =dataArray[6];
	}
		
		
	var CurrentPointsVisibleHidden = paramArray[12];
	
	
	//for (var i=0; i<CurrentPeriod.length; i++) {
	//  if (CurrentPeriodHidden == CurrentPeriod.options[i].value) {
	//    CurrentPeriod.selectedIndex=i;
	//    if (i ==0) { SwitchToOldRaces(); }
	//    else { SwitchToNewRaces();}
	//    break;
	//  }
	//}
	
	
			if (CurrentGeoHidden.length == 2) {
		//alert ("short geo");
		for (var i=0; i<CurrentGeo.length; i++) {
			if (CurrentIncdMortHidden == 1) {
	//			alert ("incd");
		  		if (CurrentGeoHidden == CurrentGeo.options[i].value.substring(0,2) )  {
		  		  CurrentGeo.selectedIndex=i;
		  		  break;
		  		}
		  	} // if incd.
		  	else {
		//		alert ("mort");
		  		if (CurrentGeoHidden == CurrentGeo.options[i].value.substring(2,4) )  {
		  		  CurrentGeo.selectedIndex=i;
		  		  break;
		  		}
		  	}//not incd
		}  //for
	} // if length = 2
	else {
		for (var i=0; i<CurrentGeo.length; i++) {
		  if (CurrentGeoHidden == CurrentGeo.options[i].value)  {
		    CurrentGeo.selectedIndex=i;
		    break;
		  }
		}  
	}
	changeDataOptions();
	
	for (var i=0; i<CurrentCancer.length; i++) {
	  if (CurrentCancerHidden == CurrentCancer.options[i].value) {
	    CurrentCancer.selectedIndex=i;
	    break;
	  }
	}
	changeDataOptions2();
	changeSex();
	changeAge();
	
	
	for (var i=0; i<CurrentIncdMort.length; i++) {
	  if (CurrentIncdMortHidden == CurrentIncdMort.options[i].value)  {
	    CurrentIncdMort.selectedIndex=i;
	    break;
	  }
	}
	
	for (var i=0; i<CurrentGender.length; i++) {
	  if (CurrentGenderHidden == CurrentGender.options[i].value) {
	    CurrentGender.selectedIndex=i;
	    break;
	  }
	}
	
	
	
	for (var i=0; i<CurrentRace.length; i++) {
	  if (CurrentRaceHidden == CurrentRace.options[i].value) {
	    CurrentRace.selectedIndex=i;
	    break;
	  }
	}
	for (var i=0; i<CurrentAge.length; i++) {
	  if (CurrentAgeHidden == CurrentAge.options[i].value)  {
	    CurrentAge.selectedIndex=i;
	    break;
	  }
	}
	

	
	
	
	/*
	for (var i=0; i<CurrentCancer.length; i++) {
	  if (CurrentCancerHidden == CurrentCancer.options[i].value)  {
	    CurrentCancer.selectedIndex=i;
	    break;
	  }
	}
	
	
	for (var i=0; i<CurrentGender.length; i++) {
	  if (CurrentGenderHidden == CurrentGender.options[i].value) {
	    CurrentGender.selectedIndex=i;
	    break;
	  }
	}
	for (var i=0; i<CurrentRace.length; i++) {
	  if (CurrentRaceHidden == CurrentRace.options[i].value) {
	    CurrentRace.selectedIndex=i;
	    break;
	  }
	}
	for (var i=0; i<CurrentAge.length; i++) {
	  if (CurrentAgeHidden == CurrentAge.options[i].value) {
	    CurrentAge.selectedIndex=i;
	    break;
	  }
	}
	for (var i=0; i<CurrentGeo.length; i++) {
	  if (CurrentGeoHidden == CurrentGeo.options[i].value) {
	    CurrentGeo.selectedIndex=i;
	    break;
	  }
	}
	changeDataOptions();
	for (var i=0; i<CurrentIncdMort.length; i++) {
	  if (CurrentIncdMortHidden == CurrentIncdMort.options[i].value) {
	    CurrentIncdMort.selectedIndex=i;
	    break;
	  }
	}*/
	
		
	
}

function undoLast() {
	//alert ("in undoLast()");
	var paramArray = GetParams();
	var arrayLength =paramArray.length;
	if (arrayLength >14) { // spot 13 is numlines, so that's a length of 14
		paramArray[13] = paramArray[13] - 1;
//		if (paramArray[13] == 10) { // was 11, 6th line, now it's 10 and has to go down to 5
			//paramArray[13] = 4;
		//}
		paramArray[arrayLength - 1] = "";
		var paramString = paramArray.join('&');
	//	alert (paramString);
		var stringLength = paramString.length;
	//	alert (stringLength);
		var queryString = paramString.substring(0, stringLength-1); //one because length is one too big, one to get rid of that last &
	//	alert (queryString);
		formObj = document.UserForm;
		formObj.target='_self';
	  	formObj.action = "joinpoint.withimage.php?"+queryString;
		formObj.submit();
	}
	else {
		clearGraph();
	}	
}

function UpdateSelected() {
	//alert ("in UpdateSelected");
   	paramArray = GetParams();
	//alert ("got param array back");
		var paramString = paramArray.join('&');
//alert ("newest param string = "+paramString);
   var VisibleForm = document.UserForm;
	
	var CurrentRace = VisibleForm.RaceBox;
	var CurrentAge = VisibleForm.AgeBox;
	var CurrentGender = VisibleForm.GenderBox;
	var CurrentCancer = VisibleForm.CancerBox;
	var CurrentPointsVisible = VisibleForm.PointsVisibleBox;
	//var CurrentPeriod = VisibleForm.PeriodBox;
	
	var CurrentIncdMort = VisibleForm.IncdMortBox;
	var CurrentGeo = VisibleForm.GeoAreaBox;
	
	//var CurrentIncdMortHidden = paramArray[10];
	
	
	
	if ((paramArray[13] == 1) || (paramArray[13] == 21)) {
		var CurrentRaceHidden = paramArray[6];
		var CurrentAgeHidden = paramArray[4];
		var CurrentGenderHidden = paramArray[7];
		var CurrentGeoHidden = paramArray[1];
		var CurrentCancerHidden = paramArray[5];
		var CurrentIncdMortHidden = paramArray[10];
	//	var CurrentPeriodHidden = paramArray[11];
	}
	else {
		var numLines = paramArray[13]+"";
		//alert(numLines);
		if (numLines > 10) {
			var lineString = numLines.substring(1,2);
		}
		else {
			lineString = numLines;
		}
		//alert (lineString);
		var lineNum = lineString*1;
		var paramIndex = lineNum + 12; //2->14, 3->15...
		//alert (paramIndex);
		var dataString = paramArray[paramIndex];
		//alert ("line 761" + dataString);
		var poundArray = dataString.split('#');
		//var dataArray = dataString.split('!');
		var dataString = poundArray[0];
		var dataArray = dataString.split('!');
		//var queryString = paramString+"&"+Geo+"!"+Age+"!"+CancerSite+"!"+Race+"!"+Sex;
		//												  0		1				2				3			4
		var CurrentRaceHidden =   dataArray[3];
		var CurrentAgeHidden =    dataArray[1];
		var CurrentGenderHidden = dataArray[4];
		var CurrentGeoHidden =  dataArray[0];
		var CurrentCancerHidden = dataArray[2];
		var CurrentIncdMortHidden = dataArray[5];
	//	var CurrentPeriodHidden = dataArray[6];
	}
		
		
	var CurrentPointsVisibleHidden = paramArray[12];
	
//	alert (CurrentPeriodHidden);
	//for (var i=0; i<CurrentPeriod.length; i++) {
	//  if (CurrentPeriodHidden == CurrentPeriod.options[i].value) {
	//    CurrentPeriod.selectedIndex=i;
	//    if (i ==0) { SwitchToOldRaces(); }
	//    else { SwitchToNewRaces();}
	//    break;
	//  }
	//}
	
		if (CurrentGeoHidden.length == 2) {
		//alert ("short geo");
		for (var i=0; i<CurrentGeo.length; i++) {
			if (CurrentIncdMortHidden == 1) {
	//			alert ("incd");
		  		if (CurrentGeoHidden == CurrentGeo.options[i].value.substring(0,2) )  {
		  		  CurrentGeo.selectedIndex=i;
		  		  break;
		  		}
		  	} // if incd.
		  	else {
		//		alert ("mort");
		  		if (CurrentGeoHidden == CurrentGeo.options[i].value.substring(2,4) )  {
		  		  CurrentGeo.selectedIndex=i;
		  		  break;
		  		}
		  	}//not incd
		}  //for
	} // if length = 2
	else {
		for (var i=0; i<CurrentGeo.length; i++) {
		  if (CurrentGeoHidden == CurrentGeo.options[i].value)  {
		    CurrentGeo.selectedIndex=i;
		    break;
		  }
		}  
	}
	changeDataOptions();
	
	for (var i=0; i<CurrentCancer.length; i++) {
	  if (CurrentCancerHidden == CurrentCancer.options[i].value) {
	    CurrentCancer.selectedIndex=i;
	    break;
	  }
	}
	changeDataOptions2();
	changeSex();
	changeAge();
	
	
	for (var i=0; i<CurrentIncdMort.length; i++) {
	  if (CurrentIncdMortHidden == CurrentIncdMort.options[i].value)  {
	    CurrentIncdMort.selectedIndex=i;
	    break;
	  }
	}
	
	for (var i=0; i<CurrentGender.length; i++) {
	  if (CurrentGenderHidden == CurrentGender.options[i].value) {
	    CurrentGender.selectedIndex=i;
	    break;
	  }
	}
	
	
	
	for (var i=0; i<CurrentRace.length; i++) {
	  if (CurrentRaceHidden == CurrentRace.options[i].value) {
	    CurrentRace.selectedIndex=i;
	    break;
	  }
	}
	for (var i=0; i<CurrentAge.length; i++) {
	  if (CurrentAgeHidden == CurrentAge.options[i].value)  {
	    CurrentAge.selectedIndex=i;
	    break;
	  }
	}
	

	
	
		
	
	//alert ("CurrentPointsVisibleHidden = "+CurrentPointsVisibleHidden);
//	alert ("CurrentPointsVisible = "+CurrentPointsVisible.checked);
//	alert ("about to change...");
	if (CurrentPointsVisibleHidden == "1") {
//		alert ("in loop to change it to true");
	    CurrentPointsVisible.checked=true;
	}
	else {
//		alert ("in loop to change it to false");
		CurrentPointsVisible.checked=false;
	}
	
	//alert ("leaving Update Selected");
}


function build_URL(){
	 
	//alert ("In build_URL")
	var baseRef = location.href.substring(0, location.href.lastIndexOf("#"));
	var newRef = baseRef + "#graph";
	
	//alert (baseRef);
	//alert (newRef);
		
	window.location.href = newRef;
	
}

/*
function changePeriods(){
	var period = document.UserForm.PeriodBox;
	var incdMort = document.UserForm.IncdMortBox;
	var area = document.UserForm.GeoAreaBox;
	var currentPeriod = period.SelectedIndex;
	var currentIncdMort = incdMort.SelectedIndex;
	
	if (period.options[currentPeriod].value == 0) { //75-99
		SwitchToOldRaces();
	}
	else if (period.options[currentPeriod].value == 1) { //90-99
		SwitchToNewRaces();
	}
	
	if (incdMort.options[currentIncdMort].value == 1) { //incidence
		SwitchToIncidence();
	}	
}

function SwitchToOldRaces() {
	var RaceObject = document.UserForm.RaceBox;	 
	var current = RaceObject.selectedIndex;
   
	RaceObject.length = 0;
	RaceObject.options[0] = new Option("choose race group");
	RaceObject.options[0].value = "**";
	RaceObject.options[1] = new Option("All Races");   
	RaceObject.options[1].value = "00";                                     
	RaceObject.options[2] = new Option("White");                                        
	RaceObject.options[2].value = "01";                                       
	RaceObject.options[3] = new Option("Black");                                 
	RaceObject.options[3].value = "02";       
	if (current < 3) {
		RaceObject.selectedIndex = current;
	}
	else {    
		RaceObject.selectedIndex = 0;
	}
}

//<option value="00" >All Races</option>
//				<option value="01">White</option>
//				<option value="02">Black</option>
//				<option value="03">Amer. Indian / AK Native</option>
//				<option value="04">Asian / Pacific Islander</option>
//				<option value="05">Hispanic</option>
function SwitchToNewRaces() {
	var RaceObject = document.UserForm.RaceBox;	 
	var current = RaceObject.selectedIndex;
   
	RaceObject.length = 0;
	RaceObject.options[0] = new Option("choose race group");
	RaceObject.options[0].value = "**";
	RaceObject.options[1] = new Option("All Races");   
	RaceObject.options[1].value = "00";                                     
	RaceObject.options[2] = new Option("White");                                        
	RaceObject.options[2].value = "01";                                       
	RaceObject.options[3] = new Option("Black");                                 
	RaceObject.options[3].value = "02";                                
	RaceObject.options[4] = new Option("Amer. Indian / AK Native");                                 
	RaceObject.options[4].value = "03";
	RaceObject.options[5] = new Option("Asian / Pacific Islander");                                 
	RaceObject.options[5].value = "04";                                     
	RaceObject.options[6] = new Option("Hispanic");                                 
	RaceObject.options[6].value = "05";          

	RaceObject.selectedIndex = current;
}


function changeAreas()
{
	//alert("change areas");
	//var AreaObject = document.UserForm.GeoAreaBox;
	var DataObject = document.UserForm.IncdMortBox;
	if (DataObject.options[DataObject.selectedIndex].value == "2") //2=mort
	  SwitchToMortality();
	else if (DataObject.options[DataObject.selectedIndex].value == "1") //1=incd
	  SwitchToIncidenceByState();	
	 else if (DataObject.options[DataObject.selectedIndex].value == "3") // incidence by registry
	   SwitchToIncidenceByReg();
}

function SwitchToIncidenceByState()
{
	var AreaObject = document.UserForm.GeoAreaBox;	 
	
   	var current = AreaObject.selectedIndex;
 //  	alert ("current selected index = "+current);
   	var currentValue = AreaObject.options[current].value;
   	var currentName = AreaObject.options[current].text;
   //	alert ("currentName - _"+currentName+"_");
  // 	alert ("current value = "+currentValue;
   	
   	AreaObject.length = 0;
	
	if ( document.UserForm.PeriodBox.value == 1 ) {
		AreaObject.options[0] = new Option("choose geography");
		AreaObject.options[0].value = "**";         
		AreaObject.options[1] = new Option("Total US (12 SEER Registries)");   
		AreaObject.options[1].value = "52";     
		AreaObject.options[2] = new Option("Total US (9 SEER Registries)");   
		AreaObject.options[2].value = "50";                                   
		AreaObject.options[3] = new Option("   Connecticut");                                 
		AreaObject.options[3].value = "02";                                        
		AreaObject.options[4] = new Option("   Hawaii");                               
		AreaObject.options[4].value = "21";                                      
		AreaObject.options[5] = new Option("   Iowa");                             
		AreaObject.options[5].value = "22";                                    
		AreaObject.options[6] = new Option("   New Mexico");                               
		AreaObject.options[6].value = "23";                   
		AreaObject.options[7] = new Option("   Utah");                               
		AreaObject.options[7].value = "26";                       
		AreaObject.selectedIndex = 0;
		
	}
	else {
		AreaObject.options[0] = new Option("choose geography");
		AreaObject.options[0].value = "**";   
		AreaObject.options[1] = new Option("Total US (9 SEER Registries)");   
		AreaObject.options[1].value = "50";                                   
		AreaObject.options[2] = new Option("   Connecticut");                                 
		AreaObject.options[2].value = "02";                                        
		AreaObject.options[3] = new Option("   Hawaii");                               
		AreaObject.options[3].value = "21";                                      
		AreaObject.options[4] = new Option("   Iowa");                             
		AreaObject.options[4].value = "22";                                    
		AreaObject.options[5] = new Option("   New Mexico");                               
		AreaObject.options[5].value = "23";                   
		AreaObject.options[6] = new Option("   Utah");                               
		AreaObject.options[6].value = "26";                       
		AreaObject.selectedIndex = 0;
	}	
		for (i = 0; i<AreaObject.length; i++) {
	//		alert ("AreaObject.options[i] = _"+ AreaObject.options[i].text+"_");//, value = "+AreaObject.options[i].value);
			//if (AreaObject.options[i].value == currentValue) {
				if (AreaObject.options[i].text == currentName) {
					AreaObject.selectedIndex = i;
					break;
				}
			//}
		}	
}

function SwitchToIncidenceByReg()
{
	var AreaObject = document.UserForm.GeoAreaBox;	 
	
   	var current = AreaObject.selectedIndex;
 //  	alert ("current selected index = "+current);
   	var currentValue = AreaObject.options[current].value;
   	var currentName = AreaObject.options[current].text;
   //	alert ("currentName - _"+currentName+"_");
  // 	alert ("current value = "+currentValue;
   	
   	AreaObject.length = 0;
	if (document.UserForm.PeriodBox.value == 1) {
		//alert("switch to incidence");
		AreaObject.options[0] = new Option("choose geography");
		AreaObject.options[0].value = "**";
		AreaObject.options[1] = new Option("12 SEER Registries");   
		AreaObject.options[1].value = "52";     
		AreaObject.options[2] = new Option(" 11 SEER Registries");   
		AreaObject.options[2].value = "51";     
		AreaObject.options[3] = new Option("  9 SEER Registries");   
		AreaObject.options[3].value = "50";                                     
		AreaObject.options[4] = new Option("   Atlanta");                                        
		AreaObject.options[4].value = "27";                                         
		AreaObject.options[5] = new Option("   Connecticut");                                 
		AreaObject.options[5].value = "02";                                          
		AreaObject.options[6] = new Option("   Detroit");                                
		AreaObject.options[6].value = "20";                                          
		AreaObject.options[7] = new Option("   Hawaii");                               
		AreaObject.options[7].value = "21";                                        
		AreaObject.options[8] = new Option("   Iowa");                             
		AreaObject.options[8].value = "22";                                      
		AreaObject.options[9] = new Option("   New Mexico");                               
		AreaObject.options[9].value = "23";            
		AreaObject.options[10] = new Option("   SF-Oak");                                
		AreaObject.options[10].value = "01";                                      
		AreaObject.options[11] = new Option("   Seattle");                            
		AreaObject.options[11].value = "25";                                     
		AreaObject.options[12] = new Option("   Utah");                               
		AreaObject.options[12].value = "26";                                      
		AreaObject.options[13] = new Option("  San Jose-Monterey");                               
		AreaObject.options[13].value = "31";                                      
		AreaObject.options[14] = new Option("  Los Angeles");                               
		AreaObject.options[14].value = "35";  
		AreaObject.selectedIndex = 0;
		//alert("switch to incidence");
		
		for (i = 0; i<AreaObject.length; i++) {
	//		alert ("AreaObject.options[i] = _"+ AreaObject.options[i].text+"_");//, value = "+AreaObject.options[i].value);
			//if (AreaObject.options[i].value == currentValue) {
				if (AreaObject.options[i].text == currentName) {
					AreaObject.selectedIndex = i;
					break;
				}
			//}
		}
	}
	else {
		AreaObject.options[0] = new Option("choose geography");
		AreaObject.options[0].value = "**";
		AreaObject.options[1] = new Option("  9 SEER Registries");   
		AreaObject.options[1].value = "50";                                     
		AreaObject.options[2] = new Option("   Atlanta");                                        
		AreaObject.options[2].value = "27";                                       
		AreaObject.options[3] = new Option("   Connecticut");                                 
		AreaObject.options[3].value = "02";                                        
		AreaObject.options[4] = new Option("   Detroit");                                
		AreaObject.options[4].value = "20";                                        
		AreaObject.options[5] = new Option("   Hawaii");                               
		AreaObject.options[5].value = "21";                                      
		AreaObject.options[6] = new Option("   Iowa");                             
		AreaObject.options[6].value = "22";                                    
		AreaObject.options[7] = new Option("   New Mexico");                               
		AreaObject.options[7].value = "23";          
		AreaObject.options[8] = new Option("   SF-Oak");                                
		AreaObject.options[8].value = "01";                                    
		AreaObject.options[9] = new Option("   Seattle");                            
		AreaObject.options[9].value = "25";                                   
		AreaObject.options[10] = new Option("   Utah");                               
		AreaObject.options[10].value = "26";                       
		AreaObject.selectedIndex = 0;
		
		for (i = 0; i<AreaObject.length; i++) {
		//	if (AreaObject.options[i].value == currentValue) {
				if (AreaObject.options[i].text == currentName) {
					AreaObject.selectedIndex = i;
					break;
				}
		//	}
		}
	}
	//alert("Leaving switch to incd");
	
}

function SwitchToIncidence()
{
	var AreaObject = document.UserForm.GeoAreaBox;	 
	
   	var current = AreaObject.selectedIndex;
 //  	alert ("current selected index = "+current);
   	var currentValue = AreaObject.options[current].value;
   	var currentName = AreaObject.options[current].text;
   //	alert ("currentName - _"+currentName+"_");
  // 	alert ("current value = "+currentValue;
   	
   	AreaObject.length = 0;
	if (document.UserForm.PeriodBox.value == 0) {
		//alert("switch to incidence");
		AreaObject.options[0] = new Option("choose geography");
		AreaObject.options[0].value = "**";
		AreaObject.options[1] = new Option("  9 SEER Registries");   
		AreaObject.options[1].value = "50";                                     
		AreaObject.options[2] = new Option("   Atlanta");                                        
		AreaObject.options[2].value = "27";                                       
		AreaObject.options[3] = new Option("   Connecticut");                                 
		AreaObject.options[3].value = "02";                                        
		AreaObject.options[4] = new Option("   Detroit");                                
		AreaObject.options[4].value = "20";                                        
		AreaObject.options[5] = new Option("   Hawaii");                               
		AreaObject.options[5].value = "21";                                      
		AreaObject.options[6] = new Option("   Iowa");                             
		AreaObject.options[6].value = "22";                                    
		AreaObject.options[7] = new Option("   New Mexico");                               
		AreaObject.options[7].value = "23";          
		AreaObject.options[8] = new Option("   SF-Oak");                                
		AreaObject.options[8].value = "01";                                    
		AreaObject.options[9] = new Option("   Seattle");                            
		AreaObject.options[9].value = "25";                                   
		AreaObject.options[10] = new Option("   Utah");                               
		AreaObject.options[10].value = "26";                       
		AreaObject.selectedIndex = 0;
		
		for (i = 0; i<AreaObject.length; i++) {
	//		alert ("AreaObject.options[i] = _"+ AreaObject.options[i].text+"_");//, value = "+AreaObject.options[i].value);
			//if (AreaObject.options[i].value == currentValue) {
				if (AreaObject.options[i].text == currentName) {
					AreaObject.selectedIndex = i;
					break;
				}
			//}
		}
	}
	else {
		//alert("switch to incidence");
		AreaObject.options[0] = new Option("choose geography");
		AreaObject.options[0].value = "**";
		AreaObject.options[1] = new Option("12 SEER Registries");   
		AreaObject.options[1].value = "52";     
		AreaObject.options[2] = new Option(" 11 SEER Registries");   
		AreaObject.options[2].value = "51";     
		AreaObject.options[3] = new Option("  9 SEER Registries");   
		AreaObject.options[3].value = "50";                                     
		AreaObject.options[4] = new Option("   Atlanta");                                        
		AreaObject.options[4].value = "27";                                         
		AreaObject.options[5] = new Option("   Connecticut");                                 
		AreaObject.options[5].value = "02";                                          
		AreaObject.options[6] = new Option("   Detroit");                                
		AreaObject.options[6].value = "20";                                          
		AreaObject.options[7] = new Option("   Hawaii");                               
		AreaObject.options[7].value = "21";                                        
		AreaObject.options[8] = new Option("   Iowa");                             
		AreaObject.options[8].value = "22";                                      
		AreaObject.options[9] = new Option("   New Mexico");                               
		AreaObject.options[9].value = "23";            
		AreaObject.options[10] = new Option("   SF-Oak");                                
		AreaObject.options[10].value = "01";                                      
		AreaObject.options[11] = new Option("   Seattle");                            
		AreaObject.options[11].value = "25";                                     
		AreaObject.options[12] = new Option("   Utah");                               
		AreaObject.options[12].value = "26";                                      
		AreaObject.options[13] = new Option("  San Jose-Monterey");                               
		AreaObject.options[13].value = "31";                                      
		AreaObject.options[14] = new Option("  Los Angeles");                               
		AreaObject.options[14].value = "35";  
		AreaObject.selectedIndex = 0;
		
		for (i = 0; i<AreaObject.length; i++) {
		//	if (AreaObject.options[i].value == currentValue) {
				if (AreaObject.options[i].text == currentName) {
					AreaObject.selectedIndex = i;
					break;
				}
		//	}
		}
	}
	//alert("Leaving switch to incd");
	
}

function SwitchToMortality()
{
	//This is the NUMBER version, not the state version
	//alert("switch to mort");
	var AreaObject = document.UserForm.GeoAreaBox;
	 	var current = AreaObject.selectedIndex;
   	var currentName = AreaObject.options[current].text;
   	
        AreaObject.length = 0;
		AreaObject.options[0] = new Option("choose geography");
		AreaObject.options[0].value = "**";
     AreaObject.options[1] = new Option("U.S. (Total)");   
	AreaObject.options[1].value = "00";         
	AreaObject.options[2] = new Option("   Alabama");                                
	AreaObject.options[2].value = "01";                                         
	AreaObject.options[3] = new Option("   Alaska");                                 
	AreaObject.options[3].value = "02";                                          
	AreaObject.options[4] = new Option("   Arizona");                                
	AreaObject.options[4].value = "04";                                         
	AreaObject.options[5] = new Option("   Arkansas");                               
	AreaObject.options[5].value = "05";                                        
	AreaObject.options[6] = new Option("   California");                             
	AreaObject.options[6].value = "06";                                      
	AreaObject.options[7] = new Option("   Colorado");                               
	AreaObject.options[7].value = "08";                                        
	AreaObject.options[8] = new Option("   Connecticut");                            
	AreaObject.options[8].value = "09";                                     
	AreaObject.options[9] = new Option("   Delaware");                               
	AreaObject.options[9].value = "10";                                     
	AreaObject.options[10] = new Option("   District of Columbia");                                        
	AreaObject.options[10].value = "11";                                   
	AreaObject.options[11] = new Option("   Florida");                                       
	AreaObject.options[11].value = "12";            	                               
	AreaObject.options[12] = new Option("   Georgia");                                   
	AreaObject.options[12].value = "13";                                          
	AreaObject.options[13] = new Option("   Hawaii");                                      
	AreaObject.options[13].value = "15";                                               
	AreaObject.options[14] = new Option("   Idaho");                                   
	AreaObject.options[14].value = "16";                                            
	AreaObject.options[15] = new Option("   Illinois");                                      
	AreaObject.options[15].value = "17";                                          
	AreaObject.options[16] = new Option("   Indiana");                                  
	AreaObject.options[16].value = "18";                                           
	AreaObject.options[17] = new Option("   Iowa");                                     
	AreaObject.options[17].value = "19";                                              
	AreaObject.options[18] = new Option("   Kansas");                                   
	AreaObject.options[18].value = "20";                                            
	AreaObject.options[19] = new Option("   Kentucky");                                 
	AreaObject.options[19].value = "21";                                          
	AreaObject.options[20] = new Option("   Louisiana");                                
	AreaObject.options[20].value = "22";           
	AreaObject.options[21] = new Option("   Maine");                                    
	AreaObject.options[21].value = "23";                                             
	AreaObject.options[22] = new Option("   Maryland");                                 
	AreaObject.options[22].value = "24";                                          
	AreaObject.options[23] = new Option("   Massachusetts");                               
	AreaObject.options[23].value = "25";                                     
	AreaObject.options[24] = new Option("   Michigan");                                 
	AreaObject.options[24].value = "26";                                          
	AreaObject.options[25] = new Option("   Minnesota");                                
	AreaObject.options[25].value = "27";                                         
	AreaObject.options[26] = new Option("   Mississippi");                              
	AreaObject.options[26].value = "28";                                       
	AreaObject.options[27] = new Option("   Missouri");                                 
	AreaObject.options[27].value = "29";                                          
	AreaObject.options[28] = new Option("   Montana");
	AreaObject.options[28].value = "30";                                       
	AreaObject.options[29] = new Option("   Nebraska");                              
	AreaObject.options[29].value = "31";     
	AreaObject.options[30] = new Option("   Nevada");                               
	AreaObject.options[30].value = "32";                                        
	AreaObject.options[31] = new Option("   New Hampshire");                              
	AreaObject.options[31].value = "33";                                       
	AreaObject.options[32] = new Option("   New Jersey");                           
	AreaObject.options[32].value = "34";                                    
	AreaObject.options[33] = new Option("   New Mexico");                              
	AreaObject.options[33].value = "35";                                       
	AreaObject.options[34] = new Option("   New York");                             
	AreaObject.options[34].value = "36";                                      
	AreaObject.options[35] = new Option("   North Carolina");                                
	AreaObject.options[35].value = "37";                                         
	AreaObject.options[36] = new Option("   North Dakota");                             
	AreaObject.options[36].value = "38";                                      
	AreaObject.options[37] = new Option("   Ohio");                                     
	AreaObject.options[37].value = "39";                                              
	AreaObject.options[38] = new Option("   Oklahoma");                                 
	AreaObject.options[38].value = "40";                                          
	AreaObject.options[39] = new Option("   Oregon");                                   
	AreaObject.options[39].value = "41";                                            
	AreaObject.options[40] = new Option("   Pennsylvania");                             
	AreaObject.options[40].value = "42";                                      
	AreaObject.options[41] = new Option("   Rhode Island");                                                         
	AreaObject.options[41].value = "44";
	AreaObject.options[42] = new Option("   South Carolina");                                                      
	AreaObject.options[42].value = "45";    
	AreaObject.options[43] = new Option("   South Dakota");
	AreaObject.options[43].value = "46";    
	AreaObject.options[44] = new Option("   Tennessee");
	AreaObject.options[44].value = "47";    
	AreaObject.options[45] = new Option("   Texas");
	AreaObject.options[45].value = "48";    
	AreaObject.options[46] = new Option("   Utah");
	AreaObject.options[46].value = "49";    
	AreaObject.options[47] = new Option("   Vermont");
	AreaObject.options[47].value = "50";    
	AreaObject.options[48] = new Option("   Virginia");
	AreaObject.options[48].value = "51";    
	AreaObject.options[49] = new Option("   Washington");
	AreaObject.options[49].value = "53";    
	AreaObject.options[50] = new Option("   West Virginia");
	AreaObject.options[50].value = "54";    
	AreaObject.options[51] = new Option("   Wisconsin");
	AreaObject.options[51].value = "55";    
	AreaObject.options[52] = new Option("   Wyoming");
	AreaObject.options[52].value = "56";
	
	AreaObject.selectedIndex = 0;
	for (i = 0; i<AreaObject.length; i++) {
		//	if (AreaObject.options[i].value == currentValue) {
				if (AreaObject.options[i].text == currentName) {
					AreaObject.selectedIndex = i;
					break;
				}
		//	}
		}
	//alert("leaving switchToMort");
	//WriteCountySelectBox();
}
*/
