function SubForm(html,index,element){
  this.rawHTML=html;
  this.lineIndex=index;
  this.parentElement=element; 
  this.parsedHTML = function() {
    return this.rawHTML.replace(/INDEX/g, ++this.lineIndex);
  };
  this.add = function() {
    $(this.parentElement).append(this.parsedHTML());
  };
}



function showGeocodedAddress(color, map,lat,lng,text,focus){
  var point = new GLatLng(lat,lng);

	// will need to make this much more modular
	// Create our "color" marker icons
	var iconOne = new GIcon(G_DEFAULT_ICON);
	var iconTwo = new GIcon(G_DEFAULT_ICON);
	var iconThree = new GIcon(G_DEFAULT_ICON);
	iconOne.image = "/images/gmap/green-dot-norm.png";
	iconTwo.image = "/images/gmap/blue-dot-norm.png";
	iconThree.image = "/images/gmap/red-dot-norm.png";
	markerOneOptions = { icon:iconOne };
	markerTwoOptions = { icon:iconTwo };
	markerThreeOptions = { icon:iconThree };

  if (focus){
//    map.setCenter(point, 15);
  }
 if (color == "making_ayp") {
	var marker = new GMarker(point, markerOneOptions);
} else if (color == "not_making_ayp") {
	var marker = new GMarker(point, markerTwoOptions);
} else if (color == "insufficient_data") {
	var marker = new GMarker(point, markerThreeOptions);
} else { 
	var marker = new GMarker(point);
}

  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(text);
  });
  map.addOverlay(marker);
}


// for google maps
function showAddress(map, geocoder, address, name, focus) {
geocoder.getLatLng(
    address,
    function(latlng) {
      if (latlng) {
        if (focus == true){
          map.setCenter(latlng, 15);
        }
        var marker = new GMarker(latlng);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml("<strong>"+name+"</strong><br/>"+address);
        }
      );
      map.addOverlay(marker);
      }
    }
  );
}

function getStateWideResources(state) {
	new Ajax.Request('/get_state_wide_resources/'+state,
	{
		asynchronous: true
	});
}
