function CallAjax ( in_element, in_func, in_admin ) {
	
	var	url = "ajax_getcounties.php?";
	
	url += in_element.id+"=" + in_element.value;
	
	if ( in_admin ) {
		url += "&_admin=1";
		in_func += "Admin";
	}
	eval ( "var func_ptr = "+in_func+";" );
	var	ajax_obj = new c_ajax_object;
	
	if ( in_element.id == 'new_location_state' && document.getElementById ( 'new_location_county' ).options ){
		document.getElementById ( 'new_location_county' ).options.length = 0;
		document.getElementById ( 'new_location_county' ).options[0] = new Option ( "Updating...", "" );
	} else {
		if ( in_element.id == 'new_location_county' && document.getElementById ( 'new_location_town' ).options ){
			document.getElementById ( 'new_location_town' ).options.length = 0;
			document.getElementById ( 'new_location_town' ).options[0] = new Option ( "Updating...", "" );
		} else {
			if ( in_element.id == 'new_author' ){
			} else {
				if ( in_element.id == 'select_area' ){
				}
			}
		}
	}

	ajax_obj.CallXMLHTTPObjectGET ( url, func_ptr );
};

function SetCounties ( in_string, inparam ) {
	eval ( "var county_array = new Array ("+in_string+");" );
	
	var counter = county_array.length - 1;
	
	document.getElementById('new_location_county').options.length = 0;
	
	for ( c = 0; c < counter; c++ ) {
		value_st = county_array[c];
		if ( value_st == "Any Town, in any County" ) {
			value_st = "";
		}
		document.getElementById('new_location_county').options[c] = new Option ( county_array[c], value_st );
	}
	
	document.getElementById('new_location_town').options.length = 0;
	
	document.getElementById('new_location_town').options[0] = new Option ( county_array[c], "" );
	
	if ( ForceAddress ) ForceAddress ();
};

function SetCountiesAdmin ( in_string, inparam ) {
	eval ( "var county_array = new Array ("+in_string+");" );
	
	var counter = county_array.length - 1;
	
	document.getElementById('new_location_county').options.length = 0;
	
	ct = 0;
	document.getElementById('new_location_county').options[ct++] = new Option ( "Select A County", "" );
	for ( c = 0; c < counter; c++ ) {
		value_st = county_array[c];
		if ( value_st == "Any Town, in any County" ) {
			value_st = "";
		}
		if ( value_st ) {
			document.getElementById('new_location_county').options[ct++] = new Option ( county_array[c], value_st );
		}
	}
	
	document.getElementById('add_town').disabled = true;
	
	document.getElementById('sel_town').options.length = 0;
	
	document.getElementById('sel_town').options[0] = new Option ( "Select A County First", "" );
	
	if ( ForceAddress ) ForceAddress ();
};

function SetASCAuthorAdmin ( in_string, inparam ) {
	var val_int = parseInt ( in_string );
	if ( val_int ) {
		var counter = document.getElementById('new_author').options.length;
		for ( c = 0; c < counter; c++ ) {
			document.getElementById('new_author').options[c].selected = false;
		}
	
		for ( c = 0; c < counter; c++ ) {
			value_st = parseInt ( document.getElementById('new_author').options[c].value );
			if ( value_st == val_int ) {
				document.getElementById('new_author').options[c].selected = true;
				break;
			}
		}
	}
};

function SetASCAdmin ( in_string, inparam ) {
	var val_int = parseInt ( in_string );
	if ( val_int ) {
		var counter = document.getElementById('select_area').options.length;
		for ( c = 0; c < counter; c++ ) {
			document.getElementById('select_area').options[c].selected = false;
		}
	
		for ( c = 0; c < counter; c++ ) {
			value_st = parseInt ( document.getElementById('select_area').options[c].value );
			if ( value_st == val_int ) {
				document.getElementById('select_area').options[c].selected = true;
				break;
			}
		}
	}
};

function SetTowns ( in_string, inparam ) {
	eval ( "var town_array = new Array ("+in_string+");" );
	
	var counter = town_array.length;
	
	document.getElementById('new_location_town').options.length = 0;
	
	ct = 0;
	for ( c = 0; c < counter; c++ ) {
		value_st = town_array[c];
		if ( value_st == "Any Town, in any County" ) {
			document.getElementById('new_location_town').options[0] = new Option ( "Any Town", "" );
			break;
		}
		if ( value_st == "Any Town" ) {
			value_st = "";
		}
		if ( !value_st && (counter == 2) ) {
			continue;
		}
		document.getElementById('new_location_town').options[ct++] = new Option ( town_array[c], value_st );
	}
	
	if ( ForceAddress ) ForceAddress ();
};

function SetTownsAdmin ( in_string, inparam ) {
	eval ( "var town_array = new Array ("+in_string+");" );
	
	var counter = town_array.length;
	
	document.getElementById('sel_town').options.length = 0;
	
	ct = 0;
	for ( c = 0; c < counter; c++ ) {
		value_st = town_array[c];
		if ( value_st == "Any Town, in any County" ) {
			continue;
		}
		if ( value_st == "Any Town" ) {
			continue;
		}
		if ( value_st ) {
			document.getElementById('sel_town').options[ct++] = new Option ( town_array[c], value_st );
		}
	}
	
	if ( !document.getElementById('sel_town').options.length ) {
		document.getElementById('sel_town').options[0] = new Option ( "No Towns", "" );
		document.getElementById('add_town').disabled = false;
		document.getElementById('new_location_town').value = "";
	} else {
		if ( document.getElementById('new_location_county').value && (document.getElementById('sel_town').value != "New York") ) {
			document.getElementById('add_town').disabled = false;
		} else {
			document.getElementById('add_town').disabled = true;
		}
	}
	
	if ( document.getElementById('sel_town').value ) {
		document.getElementById('new_location_town').value = document.getElementById('sel_town').value;
	}
	
	if ( ForceAddress ) ForceAddress ();
};

