<?xml version="1.0" encoding="UTF-8"?>
<Module>
  <ModulePrefs title="South Australia Daily Roadworks"
  description="Daily report of todays and tomorrows roadworks for South Australia, care of the Department for Transport, Energy and Infrastructure."
  author="Jason Stangroome"
  author_email="roadworks@codeassassin.com"
  height="150">
    <Require feature="sharedmap"/>
  </ModulePrefs>
  <Content type="html">
    <![CDATA[
<h3>SA Roadworks</h3>
<script>
  // Center the map in the Mediterranean and zoom out to a world view  
  var map = new GMap2();  
  var point = new GLatLng(-34.928674, 138.599975);  
  map.setCenter(point, 11);  

// Add a marker to the center of the map  
//  var marker = new GMarker(point);  
//  map.addOverlay(marker);  
// Open a "Hello World" info window  
  // var message = "Hello World!";
    //marker.openInfoWindowHtml(message);

  var geocoder = new GClientGeocoder();
  var url = "http://www.transport.sa.gov.au/quicklinks/metro_country_roadworks.asp";
  _IG_FetchContent(url, function (response) {
//    message = response;
    var re = new RegExp("&middot; (.+?) / (.+?) - (.+?)<br>", "i");
    var m;
    do {
      m = re.exec(response);
      if (m == null) {
        // alert("No match");
      } else {
        if (m[3] == "---") m[3] = "";
        var addr = "corner " + m[1] + " and " + m[2] + " " + m[3] + "south australia";
        // alert ("Found: " + addr);
        showAddress(addr);
        response = response.substring(m.index + m.length);
      }
    } while (m != null);

  });
  
function showAddress(address) {
  geocoder.getLatLngAsync(
    address,
    function(latlng) {
      if (!latlng) {
        // alert(address + " not found");
      } else {
        // map.setCenter(latlng, 15);
        var marker = new GMarker(latlng);        
        map.addOverlay(marker);        
        // marker.openInfoWindowHtml(address);
      }    
    }  
  );
}  

</script>
]]></Content>
</Module>
