<!--//

//<![CDATA[
if($('map')){
	//alert("ici map");
var Rec;
var lastpoint;
var OV;
var map = new GMap(document.getElementById("map"));                             //create "map" object
map.addControl(new GSmallMapControl());                                         //add small map controls

map.setCenter(new GLatLng(43.702688501414,7.2684135765841), 9);
/*
GEvent.addListener(map, "click", function(marker,point) {
        if (point) {
          ew.hide();
        }
      });
*/

function create_bigmap(my,mx){
	var mx;
	var my;
	if(!mx)mx=260;
	if(!my)my=-260;
	//pos = $('big_map');
	//pos =document.all[big_map_ancre];
        //mx = pos.offsetLeft;
     //   my = pos.offsetWidth;
	//alert(pos.offsetWidth+" "+pos.offsetTop);
	
	new Effect.MoveBy( 'map', my,mx,   {  duration:1.0,queue: {scope:'myscope', position:'front'} });
	//new Effect.MoveBy( 'big_map',0,0    {  x: 0, y: 0,duration:1.0,queue: {scope:'myscope', position:'front'} });
	//new  Effect.Transitions.full( 'big_map');
	//Element.setStyle('map', {top:'-320px',left:'270px',width:'486px',height:'350px'} )
	Element.setStyle('map', {width:'480px',height:'350px'} )
 	Element.hide('show_bigmap');
	Element.hide('divshow_bigmap');
	Element.show('hide_bigmap');
	map_ctrl1=new GOverviewMapControl();
	map_ctrl2=new GMapTypeControl();
	map.addControl(map_ctrl1);
	map.addControl(map_ctrl2);
}

function hide_bigmap(my,mx){
	var mx;
	var my;
	if(!mx)mx=-260;
	if(!my)my=260;
	new Effect.MoveBy( 'map', my,mx, {  duration:1.0,queue: {scope:'myscope', position:'front'} });
	Element.setStyle('map', {width:'222px',height:'220px'} )
 	Element.show('show_bigmap');
	Element.show('divshow_bigmap');
	Element.hide('hide_bigmap');
	map.removeControl(map_ctrl1);
	map.removeControl(map_ctrl2);
}

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 createPOI(point, Txt) {
        var icon = new GIcon();
        icon.image = "http://www.french-riviera-mag.com/images/poi.png";
        icon.iconSize = new GSize(20, 34);
        icon.iconAnchor = new GPoint(10, 34);
        icon.infoWindowAnchor = new GPoint(10,5);

        var marker = new GMarker(point,icon);
       
        GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml("" + Txt + "");
       });
     map.setCenter(point);
        return marker;
}


function createMarker(point,num, Txt) {
	var icon = new GIcon();
	icon.image = "http://www.french-riviera-mag.com/images/iconr"+num+".png";
	icon.iconSize = new GSize(20, 34);
	icon.iconAnchor = new GPoint(10, 34);
	icon.infoWindowAnchor = new GPoint(10,5); 

	var marker = new GMarker(point,icon);
 
/* GEvent.addListener(marker, "click", function() {
		 	marker.openInfoWindowHtml("" + Txt + "");
		 });
		  */
	 GEvent.addListener(marker, "click", function() {
	 		
	 		 if (map.getInfoWindow().getPoint()
           && map.getInfoWindow().getPoint().equals(marker.getPoint())
           && !map.getInfoWindow().isHidden() ) {
         map.closeInfoWindow();
       } else {
         marker.openInfoWindowHtml("" + Txt + "");
       } 
		 		
		 }
		 );		
	return marker;
}
function center(lat,lng){
	point = new GLatLng(lat,lng);
  //marker = new GMarker(point);
	 //map.addOverlay(marker);
   // map.openInfoWindow();    
  // alert(point);
	map.setCenter(point, 15);
	//marker.openInfoWindowHtml(''+txt+'');
}

function centerRectancle(lat_min,lat_max,long_min,long_max){
	//alert("centre map ==>("+lat_min+","+long_min+"), ("+lat_max+","+long_max);
	//map.clearOverlays();
	SouthWest=new GLatLng(lat_max , long_max );
	NorthEast=new GLatLng(lat_min , long_min  );  
	
	//     diffLat=lat_max+(lat_max-lat_min);
	//     diffLogn=long_max+(long_max-long_min);
	     
	//alert("SouthWest = "+ SouthWest +", NorthEast = "+		NorthEast);	
//	alert("diffLat = "+ diffLat +", diffLogn = "+		diffLogn);					    
	var rectBounds = new GLatLngBounds(SouthWest,NorthEast);
	
	//Rec = new Rectangle(rectBounds)
	//map.addOverlay(Rec);
	// point = rectBounds.getCenter();
	// alert(point);
	
	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()
	
	map.setCenter(new GLatLng(lat_c.lat(),center_lng),12);
	
//	map.setCenter(point, 15);
	
}
}
//]]>
//-->

