<!--//

//<![CDATA[
if(document.getElementById("map")){
	//alert("ici map");
var Rec;
tabPoint = new Array();
tabMarker = new Array();
tabTxt = new Array();
var map = new GMap(document.getElementById("map"));                             //create "map" object
map.addControl(new GSmallMapControl());                                         //add small map controls

map.addControl(new GMapTypeControl());

map.setCenter(new GLatLng(43.702688501414,7.2684135765841), 9);


function Rectangle(bounds, opt_weight, opt_color) {
  this.bounds_ = bounds;
  this.weight_ = opt_weight || 2;
  this.color_ = opt_color || "#888888";
}
Rectangle.prototype = new GOverlay();
Rectangle.prototype.initialize = function(map) {
  var div = document.createElement("div");
  div.style.border = this.weight_ + "px solid " + this.color_;
  div.style.position = "absolute";
  map.getPane(G_MAP_MAP_PANE).appendChild(div);
  this.map_ = map;
  this.div_ = div;
}
Rectangle.prototype.remove = function() {
  this.div_.parentNode.removeChild(this.div_);
}
Rectangle.prototype.copy = function() {
  return new Rectangle(this.bounds_, this.weight_, this.color_,
                       this.backgroundColor_, this.opacity_);
}
Rectangle.prototype.redraw = function(force) {
  if (!force) return;
  var c1 = this.map_.fromLatLngToDivPixel(this.bounds_.getSouthWest());
  var c2 = this.map_.fromLatLngToDivPixel(this.bounds_.getNorthEast());
  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 bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
//var lngDelta = (northEast.lng() - southWest.lng()) / 4;
//var latDelta = (northEast.lat() - southWest.lat()) / 4;

function createMarker(point,num, Txt) {
	var icon = new GIcon();
	icon.image = "images/iconr"+num+".png";
	icon.iconSize = new GSize(20, 34);
	icon.iconAnchor = new GPoint(10, 34);
	icon.infoWindowAnchor = new GPoint(10,34); 

	var marker = new GMarker(point,icon);
 	GEvent.addListener(marker, "click", function() {
	 		if (map.getInfoWindow().getPoint()
           && map.getInfoWindow().getPoint().equals(marker.getPoint())
           && !map.getInfoWindow().isHidden() ) {
         map.closeInfoWindow();
      } else {
      	map.panTo(point);
         marker.openInfoWindowHtml("" + Txt + "");
      } 
		 		
		}
	);		
	
	tabPoint[num] = point;
	tabMarker[num] = marker;
	tabTxt[num] = ""+Txt+"";
	return marker;
}
 
function center(lat,lng,Txt){
	point = new GLatLng(lat,lng);
// Decommenter pour zoomer
//	map.setCenter(point, 17);
	map.panTo(point);
	map.openInfoWindow(point,""+Txt+"");
}

function mvcenter(num){
	map.panTo(tabPoint[num]);
	tabMarker[num].openInfoWindowHtml(""+tabTxt[num]+"");
}

function centerRectancle(lat_min,lat_max,long_min,long_max){
	
//map.clearOverlays();

 map.closeInfoWindow();

	SouthWest=new GLatLng(lat_max , long_max );
	NorthEast=new GLatLng(lat_min , long_min  );  
	
	var rectBounds = new GLatLngBounds(SouthWest,NorthEast);
	
	lat_c=rectBounds.getCenter();
	lng_c=rectBounds.getCenter();
	if (lng_c.lng()<-150)
		center_lng=lng_c.lng() + 180;
	else
		center_lng=lng_c.lng()
	
	pointcentral=new GLatLng(lat_c.lat(),center_lng);
	
	map.setCenter(new GLatLng(lat_c.lat(),center_lng),15);
}
function recentre(){
	
	map.closeInfoWindow();
	map.panTo(pointcentral);

}

}
//]]>
//-->
