var CompteClick=0;
function Rectangle(bounds, opt_weight, opt_color) {
  this.bounds_ = bounds;
  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.style.border = this.weight_ + "px solid " + this.color_;
  div.style.position = "absolute";

  // 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_ = map;
  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.bounds_, 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
  var c1 = this.map_.fromLatLngToDivPixel(this.bounds_.getSouthWest());
  var c2 = this.map_.fromLatLngToDivPixel(this.bounds_.getNorthEast());

  // Now position our DIV based on the DIV coordinates of our bounds
  this.div_.style.width = Math.abs(c2.x - c1.x) + "px";
  this.div_.style.height = Math.abs(c2.y - c1.y) + "px";
  this.div_.style.left = (Math.min(c2.x, c1.x) - this.weight_) + "px";
  this.div_.style.top = (Math.min(c2.y, c1.y) - this.weight_) + "px";
}

var MarketTest;
function Situ2(Lati,longi,latiperso,longiperso,obj,poi,CoefZoom) {
	if (CompteClick==0){CompteClick=CoefZoom}
	Shw(obj);
					  if (GBrowserIsCompatible()) {
					    var map = new GMap2(ls_getObj(obj));
					    map.addControl(new GLargeMapControl()); // NAVIGATION MAXI
					    map.addControl(new GMapTypeControl());
					    map.addControl(new GOverviewMapControl());
					    if(latiperso!='' && longiperso!=''){Lati=latiperso;longi=longiperso;}
					    map.setCenter(new GLatLng(Lati, longi), CoefZoom );
					    
					    GEvent.addListener(map, "zoomend", function(oldLevel,newLevel) {CompteClick=newLevel;ls_getObj("coefZoom").value=CompteClick;})
							GEvent.addListener(map, "click", function(marker, point) {
								
														CompteClick=CompteClick+1
														if(CompteClick>17){CompteClick=17}
													  latiperso=point.lat();longiperso=point.lng();
														map.setCenter(new GLatLng(latiperso, longiperso), CompteClick );		
														
													
													  //ls_getObj('b_departement').value="";ls_getObj('b_departementName').value="";
													  //ls_getObj('b_region').value="";ls_getObj('b_regionName').value="";															
																									  
														if(poi==1){		
																					if(CompteClick>=16){
																					ls_getObj("b_longiperso").value = ""; ls_getObj("b_latiperso").value = "";
																					if(MarketTest){map.removeOverlay(MarketTest);}
																					var center = map.getCenter();
																				  map.addOverlay(MarketTest=new GMarker(center,icon,true));				    
																				  ls_getObj("b_longiperso").value = longiperso; 
																				  ls_getObj("b_latiperso").value = latiperso; 
																				  Shw('BTNBASGGV');
																					}else{
																					
																					map.removeOverlay(MarketTest);		
																					Hide('BTNBASGGV');																			
																					}
																					
								}	
																				 
														ls_getObj("coefZoom").value=CompteClick;		
													  //UpdateLocalisation(latiperso,longiperso,CompteClick, '');																  																								  						  
							});					    
			
			    							
								if(latiperso!='' && longiperso!=''){
										if(poi==1){var center = map.getCenter();
										
																  map.addOverlay(MarketTest=new GMarker(center,icon,true));				    
										
																  ls_getObj("b_longiperso").value = center.lng(); //point.toString();
																  ls_getObj("b_latiperso").value = center.lat(); //point.toString(); 
																  
																  }
								}
					  }

}


function SituDetail(Lati,longi,latiperso,longiperso,obj,poi,CoefZoom) {
	Shw(obj);
					  if (GBrowserIsCompatible()) {
					    var map = new GMap2(ls_getObj(obj));map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl());
					    if(latiperso!='' && longiperso!=''){Lati=latiperso;longi=longiperso;};
					    map.setCenter(new GLatLng(Lati, longi), CoefZoom );											  
							if(poi==1){		
								var center = map.getCenter();
							  map.addOverlay(MarketTest=new GMarker(center,icon,true));				    
							}	
					  }
}


