function loadStateSelect()
{
	new Ajax.Request('ajaxws.php',
	{
		method:'get',
		parameters: {countryID: getSelectBoxValue('country'), action: 'loadStates'},
		onSuccess: function(transport){
			$('statesContainer').innerHTML = transport.responseText
		}		
	});	
}

var marker = null;



function focusMap(lat, lng)
{

	var stateID = getSelectBoxValue('state');
	
	// get the state/country string
	
	new Ajax.Request('ajaxws.php',
	{
		method:'get',
		parameters: {stateID: stateID, action: 'getStateString'},
		onSuccess: function(transport){
			
			// remove the old marker
			if(marker) map.removeOverlay(marker);			
			
			// center the map at this state
			geocoder.getLatLng(transport.responseText,
         		function(point){
              		map.setCenter(point, 5);
              		
              		if(lat)
	              		var markerPoint = new GLatLng(lat, lng);
              		else
              			var markerPoint = point;
              		
              		// create a marker that the user can drag
              		marker = new GMarker(markerPoint, {draggable: true});
              		
              		// when the marker stops, update the lat and long values
              		GEvent.addListener(marker, "dragend", function() {
			          var coords = marker.getLatLng();
			          $("l_latitude").value = coords.lat();
			          $("l_longitude").value = coords.lng();
			        });
			        
			        map.addOverlay(marker);
			        $('maphelper').style.display = "block";
          	});
		}
	});	
		
}


function getSelectBoxValue(id)
{
	
	return $(id).options[$(id).selectedIndex].value;
	
}