/* 
 * Filename - legend.js
 * Author   - R. Zupko II
 *  
 * Purpose  - Create a static legend for the map.
 *
 * Source - This code is based upon a response at StackOverflow which can be
 *	found at the following URL: http://stackoverflow.com/questions/36515/fixed-legend-in-google-maps-mashup
 */

// Base definition
function KivaLegend() {}

// Default constructor
KivaLegend.prototype = new GControl;

// Define the initialize function
KivaLegend.prototype.initialize = function(map) {
  var me = this;
  me.panel = document.createElement("div");
  me.panel.style.width = "225px";
  me.panel.style.height = "125px";
  me.panel.style.border = "1px solid gray";
  me.panel.style.background = "white";
  me.panel.innerHTML = 
	"<strong>Legend</strong><br />" +
	"<div style=\"text-align: left;\">" +
	"<img src=\"" + iconLeader + "\" title=\"Fundrasing\" height=\"16px\" width=\"16px\" />Lender<br />" + 
	"<img src=\"" + iconFundrasing + "\" title=\"Fundrasing\" height=\"16px\" width=\"16px\" />Loan Fundraising<br />" +
	"<img src=\"" + iconLoan + "\" title=\"Fundrasing\" height=\"16px\" width=\"16px\" />Loan Funded/In Repayment/Paid<br />" +
	"<img src=\"" + iconDefaulted + "\" title=\"Fundrasing\" height=\"16px\" width=\"16px\" />Loan Defaulted<br />" +
	"<img src=\"" + iconRefunded + "\" title=\"Fundrasing\" height=\"16px\" width=\"16px\" />Loan Refunded" +
	"</div>";
  map.getContainer().appendChild(me.panel);
  return me.panel;
};

// Set the default position for the control
KivaLegend.prototype.getDefaultPosition = function() {
  return new GControlPosition(
      G_ANCHOR_BOTTOM_LEFT, new GSize(10, 50));
};

// Return the panel when requested
KivaLegend.prototype.getPanel = function() {
  return me.panel;
}
