// A Rectangle is a simple overlay that outlines a lat/lng bounds on the
// map. It has a border of the given weight and color and can optionally
// have a semi-transparent background color.
function Rectangle(label,latlng, opt_weight, opt_color) {
  this.label_  = label;
  this.latlng_ = latlng;
	this.opacity_  = 70;
  this.weight_ = opt_weight || 2;
  this.color_ = opt_color || "#888888";
}
Rectangle.prototype = new GOverlay();

// Creates the DIV representing this rectangle.
Rectangle.prototype.initialize = function(map) {
  // Create the DIV representing our rectangle
  var div = document.createElement("div");
 // div.appendChild(document.createTextNode(this.label_));
  // Our rectangle is flat against the map, so we add our selves to the
  // MAP_PANE pane, which is at the same z-index as the map itself (i.e.,
  // below the marker shadows)
  map.getPane(G_MAP_MAP_PANE).appendChild(div);

  this.map_ = map1;
  this.div_ = div;
}

// Remove the main DIV from the map pane
Rectangle.prototype.remove = function() {
  this.div_.parentNode.removeChild(this.div_);
}

// Copy our data to a new Rectangle
Rectangle.prototype.copy = function() {
  return new Rectangle(this.label_,this.latlng_, this.weight_, this.color_,
                       this.backgroundColor_, this.opacity_);
}

// Redraw the rectangle based on the current projection and zoom level
Rectangle.prototype.redraw = function(force) {
  // We only need to redraw if the coordinate system has changed
  if (!force) return;

  // Calculate the DIV coordinates of two opposite corners of our bounds to
  // get the size and position of our rectangle
  c1 = this.latlng_;
  // Now position our DIV based on the DIV coordinates of our bounds
  c1=this.map_.fromLatLngToDivPixel(this.latlng_);
  //this.div_.style.width = "100px";
  //this.div_.style.height = "0px";
  this.div_.style.left = (c1.x+8)+"px";
	if(this.label_=='249'||this.label_=='76'||this.label_=='138'||this.label_=='199'){
	  this.div_.style.top = (c1.y-27)+"px";
		this.div_.style.left = (c1.x-20-(3*this.label_.length))+"px";
	}
  else this.div_.style.top = (c1.y-20)+"px";
	this.div_.style.position   = "absolute";
	this.div_.style.background = "none";
	this.div_.style.padding    = "0";
	this.div_.style.margin     = "0";
	this.div_.id="label";
  this.div_.innerHTML= '<p>'+this.label_+'</p>' ;
}