// Copyright (C) 2008 Robert W. Clarke Consulting, all rights reserved.// do not remove this copyright notice// Map XML --------------------------------------------------------------------------------------function updateMap(ary_selected_states){ // called by selectState function every time user clicks on a state	// this function generates the xml to configure the map based the array of selected states	var ary_colors = new Array();	ary_colors['normal'] = "CCCC99"; // beige for not selected	ary_colors['selected'] = "FF0000"; // red for selected		var state_code, xml_state, re, color;	var xml_state_tmpl = '<state id="_ID_" ncolor="_COLOR_" rcolor="333333" action="javascript:selectState(\'_ID_\')" />';		// start the xml	var xml = '<?xml version="1.0" encoding="iso-8859-1" ?><MT1022>'; // start the xml	xml += '<global state_initials="on" state_name="on" action_target="_self" />';		var selected_states = " _" + ary_selected_states.join("_") + "_ ";		for(state_code in ary_state){		xml_state = xml_state_tmpl; // set to state template xml		// perform replacements		re = /_ID_/g;		xml_state = xml_state.replace(re,state_code); // replace id		// make color selection and replace		re = /_COLOR_/g;		if(selected_states.indexOf("_"+state_code+"_") > 0){ // this state is in the hidden field			xml_state = xml_state.replace(re,ary_colors['selected']);		} else {			xml_state = xml_state.replace(re,ary_colors['normal']);		}		xml += xml_state; // append xml	}		xml += '</MT1022>'; // finish xml		// update the map	sendXML(xml);}function sendXML(xml){	// this function sends the xml to the map	// the map receives the xml and configures itself automatically	if(window.maptron){		window.document["maptron"].SetVariable("jxml", xml);	}	if(document.maptron){		document.maptron.SetVariable("jxml", xml);	}}// Selection --------------------------------------------------------------------------------------function selectState(state_code){ // called by map when user clicks on a state	// get data in hidden field	var selected_states = document.forms.mapselect.states.value;	if((selected_states == null)||(selected_states.length < 2)){		selected_states = "";		var ary = new Array();	} else {		var ary = selected_states.split(",");	}		var i;	var ary_selected_states = new Array();	var found_flag = false;		for(i=0;i<ary.length;i++){		if(state_code == ary[i]){ 			found_flag = true; // state already selected, will deselect		} else {			ary_selected_states.push(ary[i]); // keep non matching states		}	}		if(!found_flag){ // state not already in array, select it		ary_selected_states.push(state_code);	}	ary_selected_states.sort();		// update the form hidden field	document.forms.mapselect.states.value = ary_selected_states.join(","); 	updateMap(ary_selected_states); // makes the xml then sends it to map}// Form Checking --------------------------------------------------------------------------------------function validateForm(form_obj){ // called when submit button is pressed	// check that at least one checkbox has been selected	var check_obj = document.forms.mapselect.type;	var i;	var flag_checkboxes = false;	var ary_types = new Array();	for(i=0;i<check_obj.length;i++){		if(check_obj[i].checked){			ary_types.push(check_obj[i].value)		}	}	if(ary_types.length == 0){		document.forms.mapselect.types.value = "";		alert("Please select at least one checkbox.");		return false;	} else {		document.forms.mapselect.types.value = ary_types.join(",");	}		// check that at least one state has been selected	var selected_states = document.forms.mapselect.states.value;	if((selected_states == null)||(selected_states.length < 2)){		alert("Please select at least one state.");		return false;	}	return true;}// Data --------------------------------------------------------------------------------------// make array for state namesvar ary_state = new Array();ary_state['AL']="Alabama";ary_state['AK']="Alaska";ary_state['AZ']="Arizona";ary_state['AR']="Arkansas";ary_state['CA']="California";ary_state['CO']="Colorado";ary_state['CT']="Connecticut";ary_state['DE']="Delaware";ary_state['DC']="District of Columbia";ary_state['FL']="Florida";ary_state['GA']="Georgia";ary_state['HI']="Hawaii";ary_state['ID']="Idaho";ary_state['IL']="Illinois";ary_state['IN']="Indiana";ary_state['IA']="Iowa";ary_state['KS']="Kansas";ary_state['KY']="Kentucky";ary_state['LA']="Louisiana";ary_state['ME']="Maine";ary_state['MD']="Maryland";ary_state['MA']="Massachusetts";ary_state['MI']="Michigan";ary_state['MN']="Minnesota";ary_state['MS']="Mississippi";ary_state['MO']="Missouri";ary_state['MT']="Montana";ary_state['NE']="Nebraska";ary_state['NV']="Nevada";ary_state['NH']="New Hampshire";ary_state['NJ']="New Jersey";ary_state['NM']="New Mexico";ary_state['NY']="New York";ary_state['NC']="North Carolina";ary_state['ND']="North Dakota";ary_state['OH']="Ohio";ary_state['OK']="Oklahoma";ary_state['OR']="Oregon";ary_state['PA']="Pennsylvania";ary_state['RI']="Rhode Island";ary_state['SC']="South Carolina";ary_state['SD']="South Dakota";ary_state['TN']="Tennessee";ary_state['TX']="Texas";ary_state['UT']="Utah";ary_state['VT']="Vermont";ary_state['VA']="Virginia";ary_state['WA']="Washington";ary_state['WV']="West Virginia";ary_state['WI']="Wisconsin";ary_state['WY']="Wyoming";