<?php
	/*
	** File: makeStateSelector
	** Description: prints a select for states
	** Version: $Revision: 1.7 $
	** Created: 06/30/1999
	** Author: Leon Atkinson
	** Email: leon@clearink.com
	** CVS Author: $Author: leon $
	** Last Revised: $Date: 1999/12/15 17:23:27 $
	**
	** Log : $Log: makeStateSelector,v $
	** Log : Revision 1.7  1999/12/15 17:23:27  leon
	** Log : Added functionality from Mari Bester to translate displayed StateProv
	** Log : and Country address fields from codes into names.
	** Log :
	** Log : Revision 1.6  1999/10/11 23:04:04  leon
	** Log : Removed all require()'s, added block to stop double include()'s
	** Log :
	** Log : Require wasn't giving any performance advantage because it was always
	** Log : being called with a variable.  Futhermore, using return inside a
	** Log : require()'d file does not work in PHP4.
	** Log :
	** Log : Revision 1.5  1999/09/10 00:14:56  jj
	** Log : Wrapped everything in basically an ifndef.
	** Log :
	** Log : Revision 1.4  1999/09/09 22:44:30  jj
	** Log : Wrapped this script in an "if" statement in order to avoid redeclarations.
	** Log :
	** Log : Revision 1.3  1999/08/18 22:32:06  leon
	** Log : Returning opening PHP tag to XML-friendly tag
	** Log :
	** Log : Revision 1.2  1999/08/09 22:31:11  jj
	** Log : Something really small and unimportant, which I can remember.
	** Log :
	** Log : Revision 1.1  1999/07/28 19:41:07  leon
	** Log : Mass update based on code donation from a live project
	** Log :
	**
	** Copyright (c) 1999 Working Dogs.  All rights reserved.
	*/

	/*
	** Ensure that module isn't included twice
	*/

	$included_flag = 'INCLUDE_' . basename(__FILE__);
	
	if(defined($included_flag))
		//if this module has been included already, then the
		//constant will be defined.  Note the unusual use of
		//the return statement here.  Control will return to
		//the file that included it.
		return;
	
	define($included_flag, TRUE);	


	$States = array(
		"AK"=>"Alaska",
		"AL"=>"Alabama",
		"AZ"=>"Arizona",
		"AR"=>"Arkansas",
		"CA"=>"California",
		"CO"=>"Colorado",
		"CT"=>"Connecticut",
		"DE"=>"Delaware",
		"DC"=>"District of Columbia",
		"FL"=>"Florida",
		"GA"=>"Georgia",
		"HI"=>"Hawaii",
		"IA"=>"Iowa",
		"ID"=>"Idaho",
		"IL"=>"Illinois",
		"IN"=>"Indiana",
		"KS"=>"Kansas",
		"KY"=>"Kentucky",
		"LA"=>"Louisiana",
		"ME"=>"Maine",
		"MA"=>"Massachusetts",
		"MD"=>"Maryland",
		"MI"=>"Michigan",
		"MN"=>"Minnesota",
		"MS"=>"Mississippi",
		"MO"=>"Missouri",
		"MT"=>"Montana",
		"NE"=>"Nebraska",
		"NV"=>"Nevada",
		"NH"=>"New Hampshire",
		"NJ"=>"New Jersey",
		"NM"=>"New Mexico",
		"NY"=>"New York",
		"NC"=>"North Carolina",
		"ND"=>"North Dakota",
		"OH"=>"Ohio",
		"OK"=>"Oklahoma",
		"OR"=>"Oregon",
		"PA"=>"Pennsylvania",
		"RI"=>"Rhode Island",
		"SC"=>"South Carolina",
		"SD"=>"South Dakota",
		"TN"=>"Tennessee",
		"TX"=>"Texas",
		"UT"=>"Utah",
		"VT"=>"Vermont",
		"VA"=>"Virginia",
		"WA"=>"Washington",
		"WV"=>"West Virginia",
		"WI"=>"Wisconsin",
		"WY"=>"Wyoming",
		"AA"=>"AA",
		"AE"=>"AE",
		"AP"=>"AP"
	);


	/*
	** Function: makeStateSelector
	** Input:  STRING name, STRING selected
	** Output: BOOLEAN
	** Description:  Prints a complete selector for choosing
	** a state.  You may name the selector and optionally
	** specify the state to be selected.
	*/
	function makeStateSelector($name, $selected)
	{

		global $States;

		print("<SELECT NAME=\"$name\" SIZE=\"1\">\n");
		print("<OPTION VALUE=\"\">Please Select</OPTION>\n");

		for(reset($States); $key = key($States); next($States))
		{
			print("<OPTION VALUE=\"$key\"");
			if($key == $selected)
			{
				print(" SELECTED");
			}
			print(">$States[$key]</OPTION>\n");
		}

		print("</SELECT>\n");		
	}


	/*
	** Function: getStateName
	** Input:  STRING StateCode
	** Output: STRING
	** Description:  Returns the name of a state or province
	** given its code.
	**
	** Contributed by Mari Bester [Mari@dchip.com]
	*/
	function getStateName($StateCode)
	{
		global $States;
		return($States[$StateCode]);
	}
	
?>
