var map = null;
var geocoder = null;
var infowindow = null;

function draw_map_and_markers(address)
{
	infowindow = new google.maps.InfoWindow();
	geocoder = new google.maps.Geocoder();

	geocoder.geocode({ 'address': address }, 
		function(results, status)
		{
			if(status == google.maps.GeocoderStatus.OK)
			{
				map = new google.maps.Map($("map_canvas"), { center: results[0].geometry.location, mapTypeId: google.maps.MapTypeId.ROADMAP });
				map.fitBounds(results[0].geometry.viewport);
			}
			else
			{
				map = new google.maps.Map($("map_canvas"), { zoom: 2, center: new google.maps.LatLng(34, 0), mapTypeId: google.maps.MapTypeId.ROADMAP });
			}

			for(i = number_of_markers; i >= 1; i--) { eval('marker' + i + '.setMap(map)'); }
		}
	);
}

function draw_map_and_open_marker(content, marker)
{
	infowindow = new google.maps.InfoWindow();
	map = new google.maps.Map($("map_canvas"), { mapTypeId: google.maps.MapTypeId.ROADMAP });
	marker.setMap(map);
	show_content(content, marker);
}

function show_content(content, marker)
{
	infowindow.setContent(content);
	infowindow.open(map, marker);
	map.setCenter(marker.getPosition());
	map.setZoom(13);
}

function submit_form(frm)
{
	if(frm.selected_country.value != 'select')
	{
		frm.action = submit_url + '/' + frm.selected_country.value;
		frm.submit();
	}
}

function redirect_to(hash)
{
	location.href = show_url + '/' + hash;
}