function Jalan(map,opt_weight, mer,hij,bir,mt) {
	this.mer_=mer;
	this.hij_=hij;
	this.bir_=bir;
	this.weight_ = opt_weight;
	this.map_ = map;
	this.mt_ = mt;
}

Jalan.prototype = new GOverlay();

// Creates the DIV representing this Jalan.
Jalan.prototype.initialize = function(map) {
  // Create the DIV representing our Jalan
	var div = document.createElement("div");
	div.style.border =  "0px" ;
	div.style.position = "absolute";
	//div.style.left = "0px";
	//div.style.top = "0px";
	div.id= "ms";

  // Our Jalan 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)
	switch(this.mt_){
  case 0: document.getElementById("MStreet").appendChild(div); break;
  case 1: document.getElementById("MStreetName").appendChild(div); break;
  }

	this.dotSize =1;
	this.color='red';

 
	this.div_ = div;
	// this.map_ = map;
}

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

// Copy our data to a new Jalan
Jalan.prototype.copy = function() {
	return new Jalan( this.map_,this.weight_, this.mer_,this.hij_,this.bir_, this.mt_);
}

// Redraw the Jalan based on the current projection and zoom level
Jalan.prototype.redraw = function(force) {
  // We only need to redraw if the coordinate system has changed
 if (!force) return;
	var bounds = this.map_.getBounds();
	var southWest = bounds.getSouthWest();
	var northEast = bounds.getNorthEast();
	var pjlng=Math.abs(southWest.lng()-northEast.lng());

	var bbo= '&trLng=' +northEast.lng() + '&trLat=' + northEast.lat() + '&blLng=' + southWest.lng() + '&blLat=' + southWest.lat() ;
	//alert(bbo);
	var warnanya= '&rr=' + this.mer_ + '&gg=' + this.hij_ + '&bb=' + this.bir_ ;
	//alert(warnanya);

	var siz=this.map_.getSize();

	var c1 = this.map_.fromLatLngToDivPixel(bounds.getSouthWest());
	var c2 = this.map_.fromLatLngToDivPixel(bounds.getNorthEast());

	this.div_.style.left = c1.x  +"px";
	this.div_.style.top = c2.y  + "px";
    
	var html = ''; 
	html += '<IMG src="jalan.php?' + 'tb=' +  this.weight_ + warnanya + bbo + '&sw=' + siz.width + '&sh=' + siz.height + '&mt='+ this.mt_ +'" style="filter:alpha(opacity=100);-moz-opacity:1;opacity:1;" >'; 
     
	this.div_.innerHTML=html;

}


function Antena(bounds, radiusnya,dari,ke,util,fill,opt_weight, opt_color) {
  this.bounds_ = bounds;
  this.radius_=radiusnya;
  this.weight_ = opt_weight || 2;
  this.color_ = opt_color || "#ff0000";
  this.dari_=dari-90;
  this.ke_=ke-90;
  this.util_=util;
  this.fill_=fill;
}

Antena.prototype = new GOverlay();

// Creates the DIV representing this Antena.
Antena.prototype.initialize = function(map) {
  // Create the DIV representing our Antena
  var div = document.createElement("div");
  div.style.border =  "0px solid " + this.color_;
  div.style.position = "absolute";
  div.id= "mc";

  // Our Antena 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)
  document.getElementById("MCoverage").appendChild(div);

	this.dotSize =2;
	this.color='red';
	this.da = Math.PI / 360


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

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

// Copy our data to a new Antena
Antena.prototype.copy = function() {
	return new Antena(this.bounds_, this.radius_,this.dari_,this.ke_,this.util_,this.fill_,this.weight_, this.color_,
												this.backgroundColor_, this.opacity_);
}

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

	var siz=this.map_.getSize();     
	var bounds = this.map_.getBounds();
	var southWest = bounds.getSouthWest();
	var northEast = bounds.getNorthEast();
	var pjlng=Math.abs(southWest.lng()-northEast.lng());
  pjj=((((this.radius_/6378137)*180/Math.PI)/pjlng) * siz.width);

  if (pjj>siz.width)  pjj=siz.width;

  // Calculate the DIV coordinates of two opposite corners of our bounds to
  // get the size and position of our Antena
  var c1 = this.map_.fromLatLngToDivPixel(this.bounds_);
  var c2 = this.map_.fromLatLngToDivPixel(this.bounds_);

  // Now position our DIV based on the DIV coordinates of our bounds
  this.div_.style.width = pjj * 2+ "px"; //Math.abs(c2.x - c1.x) + "px";
  this.div_.style.height = pjj * 2 + "px";Math.abs(c2.y - c1.y) + "px";
  this.div_.style.left = c1.x - pjj + "px";
  this.div_.style.top = c1.y - pjj + "px";
    
	var html = ''; 
  html += '<IMG src="circle.php?wid=500&f=' + this.fill_ + '&t=' + this.util_ + '&s=' + Math.round(pjj * 2) + '&aw=' + this.dari_ + '&ak=' + this.ke_ + '" style="filter:alpha(opacity=10);-moz-opacity:0.1;opacity:0.1;" >'; 
	this.div_.innerHTML=html;
}

