var dejaAffiche = false;
var nbreMarqueurs = 0;
var nbreMarqueursAffiches = 0;
var MAX_DUMP_DEPTH = 2;
function dumpObj(obj, name, indent, depth) {
if (depth > MAX_DUMP_DEPTH) {
return indent + name + ": <Maximum Depth Reached>\n";
}
if (typeof obj == "object") {
var child = null;
var output = indent + name + "<br />\n";
indent += "\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
for (var item in obj)
{
try {
child = obj[item];
} catch (e) {
child = "<br /><Unable to Evaluate><br />";
}
if (typeof child == "object") {
output += dumpObj(child, item, indent, depth + 1);
} else {
output += indent + item + ": " + child + "<br />\n";
}
}
return output;
} else {
return obj;
}
}
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var map;
var gLang = lang;
var c_value = new Array();
var s_value = new Array();
var legendImg;
defaultLat ? defaultLat : 45.557273;
defaultLng ? defaultLng : -73.549320;
defaultZoom ? defaultZoom : 7;
defaultMunid ? defaultMunid : 0;
defaultSID ? defaultSID : 0;
defaultBaseURL ? defaultBaseURL : 'icimamaison.ca';
defaultPrint ? defaultPrint : false;
var customTitre;
var ListeLateralArray = new Array();
function initListeLateral(){
if (!document.getElementsByTagName){ return; }
var lesDiv = document.getElementsByTagName("div");
for (var i=0; i<lesDiv.length; i++){
var _div = lesDiv[i];
if ( (_div.getAttribute('class') == 'resultatVedette') || ( isIE && (_div.getAttributeNode('class').value == 'resultatVedette') ) ){
ListeLateralArray.push(_div.getAttribute("id"));
_div.onmouseover = function(){
this.style.backgroundColor='#b0e2f9';
return true;
};
_div.onmouseout = function(){
this.style.backgroundColor='#e2e7e0';
return true;
};
}
}
}
var ListeServiceArray = new Array();
function initListeService(){
if (!document.getElementsByTagName){ return; }
var lesRow = document.getElementsByTagName("tr");
for (var i=0; i<lesRow.length; i++){
var _row = lesRow[i];
if ( (_row.getAttribute('class') == 'serviceVedette') || ( isIE && (_row.getAttributeNode('class').value == 'serviceVedette') ) ){
ListeServiceArray.push(_row.getAttribute("id"));
}
}
}
function addLoadEvent(func)
{	
var oldonload = window.onload;
if (typeof window.onload != 'function'){
window.onload = func;
} else {
window.onload = function(){
oldonload();
func();
}
}
}
addLoadEvent(initListeLateral);
function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft;
curtop = obj.offsetTop;
}
return curtop;
}
function replaceOverListe(id){
for(i=1;i<=ListeLateralArray.length;i++){
var leDivId = ListeLateralArray[i-1];
var obj = document.getElementById(leDivId);
if(leDivId==id){
obj.style.background="#b0e2f9";
obj.onmouseover = function(){
return true;
};
obj.onmouseout = function(){
return true;
};
obj.onclick = function(){
return false;
}
var h = findPos(obj);
document.getElementById("ListeLateralScroll").scrollTop = h;
}else{
obj.style.background="#e2e7e0";
obj.onmouseover = function(){
this.style.backgroundColor='#b0e2f9';
return true;
};
obj.onmouseout = function(){
this.style.backgroundColor='#e2e7e0';
return true;
};
obj.onclick = function(){
return true;
}
}			
}
}
function servicesOverListe(id){
for(i=1;i<=ListeServiceArray.length;i++){
var leRowId = ListeServiceArray[i-1];
var obj = document.getElementById(leRowId);
if(leRowId=="Serv"+id ){
obj.style.background="#b0e2f9";
obj.onmouseover = function(){
return true;
};
obj.onmouseout = function(){
return true;
};
}else{
obj.style.background="#e2e7e0";
obj.onmouseover = function(){
this.style.backgroundColor='#b0e2f9';
return true;
};
obj.onmouseout = function(){
this.style.backgroundColor='#e2e7e0';
return true;
};
}			
}
}
function createHtmlBulle(type, id, pic, tB, tBid, titre, description, marker){
var HTMLBulle;
var btnDetail='';
var banniere='';
var imgIns='';
var descriptionF = '';
if(type>=1 && type<=3){
	if(gLang=="en"){
		btnDetail = "<br clear=\"all\" />";
		btnDetail += "<div class=\"GmapBtnFicheDetail\"><div class=\"GmapBtnFicheDetailIn\"><a href=\"http://" + defaultBaseURL + "/main.cfm?l=en&p=00_100&s=inscription-carte2&sid="+id+"\">View detail</a></div></div>";
	}else{
		btnDetail = "<br clear=\"all\" />";
		btnDetail += "<div class=\"GmapBtnFicheDetail\"><div class=\"GmapBtnFicheDetailIn\"><a href=\"./main.cfm?l=fr&p=00_100&s=inscription-carte2&sid="+id+"\">Voir la fiche d&eacute;tail</a></div></div>";
		}
	if(tB==1){
		banniere = '<img src="http://24.122.77.205/membres/'+tBid+'_logo.jpg" width="74" border="0"  style="display:block;float:right;width:74px;margin:0 0 0 5px;">';
	}else{
		banniere = '<img src="http://24.122.77.205/banniere/'+tBid+'.jpg" width="74" border="0"  style="display:block;float:right;width:74px;margin:0 0 0 5px;">';
	}
	imgIns='<img src="http://24.122.77.205/Pic450/'+pic+'" alt="'+pic+'" border="0" style="width:290px;height:203px;margin:10px 0 0 0;">';
}else if(type==29){
	imgIns='<img src="http://' + defaultBaseURL + '/Data/SERVICE_ICI/'+id+'_logo.png" alt="" border="0" style="width:290px;height:203px;margin:10px 0 0 0;">';
}
if(description != "" && description != "null" && description != null){
descriptionF = description;
}
HTMLBulle = "<div id=\"GmapBulle\">";
HTMLBulle += "<h1 id=\"GmapHUn\">"+titre+"</h1>";
HTMLBulle += banniere+descriptionF+'<br clear="all" />'+imgIns+'<br />'+btnDetail+'<br />';
HTMLBulle += "</div>";

HTMLBulle = "<iframe style='margin-top:10px;' width='250' height='130'frameborder='0' src='http://" +defaultWidgetURL + "/sutton/popBulle.cfm?type=1&sid=" + id + "' ></iframe>";
return HTMLBulle;
}
function panGmap(lat, lng, type, typeTemp, id, pic, tB, tBid, titre, description, liste){
var myMarker = createMarker(new GLatLng(lat, lng), type, typeTemp, id, 0, pic, tB, tBid, titre, description, true);
map.addOverlay(myMarker);

//var HTMLBulle = createHtmlBulle(type, id, pic, tB, tBid, titre, description);
myMarker.openInfoWindowHtml("<iframe style='margin-top:10px;' width='250' height='130'frameborder='0' src='http://" +defaultWidgetURL + "/sutton/popBulle.cfm?type=" + type + "&sid=" + id + "' ></iframe>");
map.setCenter(new GLatLng(lat+0.015, lng));
if(liste){
replaceOverListe(id);
}
}
function GmapMAJ(){
s_value = new Array();
for (var i=0; i < document.formChecked.servicesCat.length; i++){
if (document.formChecked.servicesCat[i].checked){
s_value.push(document.formChecked.servicesCat[i].value);
}
}
GmapXmlRequest(true);
}
function GmapXmlRequest(extraParamOk){
var extraParam = "";
if(extraParamOk){
extraParam += "&servicesCat="
if(s_value.length){
extraParam += s_value.toString();
}
}
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var lngSpan = northEast.lng() - southWest.lng();
var latSpan = northEast.lat() - southWest.lat();
var boundsExtendSouth;
var boundsExtendWest;
var boundsExtendNorth;
var boundsExtendEast;
var center = map.getCenter();
var zoom = map.getZoom();
var oldZoom = zoom;
if(defaultPrint==false){
if(zoom >= 13){
//document.getElementById("mapAddMarkers").style.display="block";
initListeService();
}else{
//document.getElementById("mapAddMarkers").style.display="none";
}
/*if( !document.getElementById("LegendGMap").hasChildNodes() ){
legendImg = document.createElement("img");
document.getElementById("LegendGMap").appendChild(legendImg);
}*/
/*if(zoom >= 13){
document.getElementById("LegendGMapVille").style.display = 'block';
document.getElementById("LegendGMapRegion").style.display = 'none';
//legendImg.src= "http://" + defaultBaseURL + "/inc/Gmap/gx/legendVille_" + gLang + ".gif";
}else{
document.getElementById("LegendGMapVille").style.display = 'none';
document.getElementById("LegendGMapRegion").style.display = 'block';
//legendImg.src= "http://" + defaultBaseURL + "/inc/Gmap/gx/legendRegion_" + gLang + ".gif";
}*/
}
boundsExtendSouth = southWest.lat() - 180;
boundsExtendWest = southWest.lng() - 360;
boundsExtendNorth = northEast.lat() + 180;
boundsExtendEast = northEast.lng() + 360;
var lngDelta = (northEast.lng() - southWest.lng()) / 4;
var latDelta = (northEast.lat() - southWest.lat()) / 4;
var rectBounds = new GLatLngBounds(new GLatLng(southWest.lat() + latDelta, southWest.lng() + lngDelta),new GLatLng(northEast.lat() - latDelta, northEast.lng() - lngDelta));
map.addOverlay(new Loading(rectBounds));
//if(defaultMunid!=0 && zoom > 10){
if(defaultMunid!=0){
extraParam += "&munid="+defaultMunid;
}
if(defaultRegionid!=0){ /* && zoom > 7 */
extraParam += "&regionid="+defaultRegionid;
}
if(defaultSID!=0){ /*  && zoom >= 15 */
extraParam += "&sid="+defaultSID;
}
	GDownloadUrl("http://" + defaultWidgetURL + "/sutton/inc/Gmap/getMarkers.cfm?l="+gLang+"&zoom="+zoom+"&center="+center+"&idIns="+idIns + extraParam, function(data, responseCode) {
		if(responseCode==200){
			map.clearOverlays();
			if(defaultSID!=0 && zoom >= 15){
				map.addOverlay(createMarker(new GLatLng(defaultLat, defaultLng), 25, 25));
			}
			var xml = GXml.parse(data);
			
			var markers = xml.documentElement.getElementsByTagName("marker");
			nbreMarqueurs = markers.length;
			for (var i = 0; i < markers.length; i++) {
			//alert('x');
				if( markers[i].getAttribute("lat") && markers[i].getAttribute("lng") ){
					var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng")));
					map.addOverlay(createMarker(point, markers[i].getAttribute("type"), markers[i].getAttribute("type"), markers[i].getAttribute("id"), markers[i].getAttribute("nbr"), markers[i].getAttribute("pic"), markers[i].getAttribute("tB"), markers[i].getAttribute("tBid"), markers[i].getAttribute("titre"), markers[i].getAttribute("description"), markers[i].getAttribute("fromPanFlag"), markers[i].getAttribute("source"), markers[i].getAttribute("urlVars")));
				}
			}
		}
		else{
			map.clearOverlays();
			alert('Une erreur s\'est produite lors du chargement de la carte\nErreur de type : '+responseCode);
		}
	});	


	
}
var IconType1 = new GIcon();
IconType1.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/1.png";
IconType1.iconSize = new GSize(21, 19);
IconType1.iconAnchor = new GPoint(11, 10);
IconType1.infoWindowAnchor = new GPoint(10, 16);
var IconType2 = new GIcon();
IconType2.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/2.png";
IconType2.iconSize = new GSize(21, 19);
IconType2.iconAnchor = new GPoint(11, 10);
IconType2.infoWindowAnchor = new GPoint(10, 16);
var IconType3 = new GIcon();
IconType3.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/3.png";
IconType3.iconSize = new GSize(21, 19);
IconType3.iconAnchor = new GPoint(11, 10);
IconType3.infoWindowAnchor = new GPoint(10, 16);
var IconType25 = new GIcon();
IconType25.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/25.png";
IconType25.iconSize = new GSize(21, 19);
IconType25.iconAnchor = new GPoint(11, 10);
IconType25.infoWindowAnchor = new GPoint(10, 16);
var IconType26 = new GIcon();
IconType26.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/26.png";
IconType26.iconSize = new GSize(20, 19);
IconType26.iconAnchor = new GPoint(10, 10);
IconType26.infoWindowAnchor = new GPoint(10, 10);
var IconType27 = new GIcon();
IconType27.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/27.png";
IconType27.iconSize = new GSize(14, 14);
IconType27.iconAnchor = new GPoint(7, 7);
IconType27.infoWindowAnchor = new GPoint(5, 5);
var IconType28 = new GIcon();
IconType28.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/28.png";
IconType28.iconSize = new GSize(14, 14);
IconType28.iconAnchor = new GPoint(7, 7);
IconType28.infoWindowAnchor = new GPoint(5, 5);
var IconType51 = new GIcon();
IconType51.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/51.png";
IconType51.iconSize = new GSize(14, 16);
IconType51.iconAnchor = new GPoint(7, 8);
IconType51.infoWindowAnchor = new GPoint(50, -15);
var IconType52 = new GIcon();
IconType52.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/52.png";
IconType52.iconSize = new GSize(21, 24);
IconType52.iconAnchor = new GPoint(11, 12);
IconType52.infoWindowAnchor = new GPoint(50, -15);
var IconType53 = new GIcon();
IconType53.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/53.png";
IconType53.iconSize = new GSize(28, 32);
IconType53.iconAnchor = new GPoint(14, 16);
IconType53.infoWindowAnchor = new GPoint(50, -15);
var IconType54 = new GIcon();
IconType54.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/54.png";
IconType54.iconSize = new GSize(29, 30);
IconType54.iconAnchor = new GPoint(15, 15);
IconType54.infoWindowAnchor = new GPoint(50, -15);
var IconType55 = new GIcon();
IconType55.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/55.png";
IconType55.iconSize = new GSize(43, 43);
IconType55.iconAnchor = new GPoint(22, 22);
IconType55.infoWindowAnchor = new GPoint(50, -15);
var IconType61 = new GIcon();
IconType61.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/61.png";
IconType61.iconSize = new GSize(14, 16);
IconType61.iconAnchor = new GPoint(7, 8);
IconType61.infoWindowAnchor = new GPoint(50, -15);
var IconType62 = new GIcon();
IconType62.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/62.png";
IconType62.iconSize = new GSize(21, 21);
IconType62.iconAnchor = new GPoint(11, 12);
IconType62.infoWindowAnchor = new GPoint(50, -15);
var IconType63 = new GIcon();
IconType63.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/63.png";
IconType63.iconSize = new GSize(28, 32);
IconType63.iconAnchor = new GPoint(14, 16);
IconType63.infoWindowAnchor = new GPoint(50, -15);
var IconType64 = new GIcon();
IconType64.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/64.png";
IconType64.iconSize = new GSize(29, 30);
IconType64.iconAnchor = new GPoint(15, 15);
IconType64.infoWindowAnchor = new GPoint(50, -15);
var IconType65 = new GIcon();
IconType65.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/65.png";
IconType65.iconSize = new GSize(43, 43);
IconType65.iconAnchor = new GPoint(22, 22);
IconType65.infoWindowAnchor = new GPoint(50, -15);
var IconType29 = new GIcon();
IconType29.iconSize = new GSize(25, 25);
IconType29.iconAnchor = new GPoint(0, 25);
IconType29.infoWindowAnchor = new GPoint(0, 25);
var IconType100 = new GIcon();
IconType100.image = "http://" + defaultWidgetURL + "/sutton/inc/Gmap/gx/Icones/100.gif";
IconType100.iconSize = new GSize(18, 22);
IconType100.iconAnchor = new GPoint(9, 11);
IconType100.infoWindowAnchor = new GPoint(9, 11);
function createMarker(point, type, typeTemp, id, NbrInscrip, pic, tB, tBid, titre, description, fromPanFlag, source, urlVars) {
	if(type==29){
		IconType29.image = "http://" + defaultBaseURL + "/DATA/SERVICE_ICI/"+id+".png";
	}
	var icon = new GIcon( eval("IconType"+type) );
	var marker = new GMarker(point, icon);
	if(type!=25){
		GEvent.addListener(marker, "click", function() {
			if(type>=51 && type<=60){
				window.location = 'http://' + defaultWidgetURL + '/' + prefixPath  + 'widget-page.cfm?l='+gLang+'&regionid='+id;
			}else if (type>=61 && type<=70){
				window.location = 'http://' + defaultWidgetURL + '/' + prefixPath  + 'widget-page.cfm?l='+gLang+'&munid='+id;
			}else if (type != 100){
				var HTMLBulle = createHtmlBulle(type, id, pic, tB, tBid, titre, description, marker);
				if(type==1){
					map.removeOverlay(marker);
					map.addOverlay(new createMarker(point, 2, typeTemp, id, NbrInscrip, pic, tB, tBid, titre, description))

					//marker.openInfoWindowHtml("<iframe style='margin-top:10px;' width='250' height='130'frameborder='0' src='http://" +defaultWidgetURL + "/sutton/popBulle.cfm?type=" + type + "&sid=" + id + "' ></iframe>");
					replaceOverListe(id);
				}else if(type==2 && typeTemp==1){
					map.removeOverlay(marker);
					map.addOverlay(new createMarker(point, 1, typeTemp, id, NbrInscrip, pic, tB, tBid, titre, description));
					replaceOverListe(id);
				}else if(type==2 && typeTemp==3){
					map.removeOverlay(marker);
					map.addOverlay(new createMarker(point, 3, typeTemp, id, NbrInscrip, pic, tB, tBid, titre, description));
					replaceOverListe(id);
				}else if(type==3){
					map.removeOverlay(marker);
					map.addOverlay(new createMarker(point, 2, typeTemp, id, NbrInscrip, pic, tB, tBid, titre, description));
					//marker.openInfoWindowHtml("<iframe style='margin-top:10px;' width='250' height='130'frameborder='0' src='http://" +defaultWidgetURL + "/sutton/popBulle.cfm?type=" + type + "&sid=" + id + "' ></iframe>");
					replaceOverListe(id);
				}
				else if (type >= 26 && type <= 29){
					marker.openInfoWindowHtml("<iframe style='margin-top:10px' width='340' height='150'frameborder='0' src='http://" +defaultWidgetURL + "/sutton/popBulle.cfm?type=" + type + "&id=" + id + "&source=" + source + "&" + urlVars + "' ></iframe>");
				
				}else{
					marker.openInfoWindowHtml(HTMLBulle);
				}
			}			
		});
	}
	if(type>=51 && type<=70){
		marker.infoTitre = '<div class="infoTitre" style="text-align:center;">'+titre+' ('+NbrInscrip+')</div>';
		marker.icon = icon;
		GEvent.addListener(marker, "mouseover", function() {
			showInfoTitre(marker);
		});
		GEvent.addListener(marker, "mouseout", function() {
			hideInfoTitre();
		});		
	}
	if(type>=1 && type<=3){
		GEvent.addListener(marker, "infowindowbeforeclose", function() {
			if(type==1){
				map.addOverlay(new createMarker(point, 1, 1, id, NbrInscrip, pic, tB, tBid, titre, description));
				replaceOverListe(0);
			}else if(type==2 && typeTemp==1){
				map.addOverlay(new createMarker(point, 1, 1, id, NbrInscrip, pic, tB, tBid, titre, description));
				replaceOverListe(0);
			}else if(type==2 && typeTemp==3 && fromPanFlag==1){
				map.addOverlay(new createMarker(point, 3, 3, id, NbrInscrip, pic, tB, tBid, titre, description));
				replaceOverListe(0);
				fromPanFlag=2;
			}else if(type==2 && typeTemp==3){
				map.addOverlay(new createMarker(point, 3, 3, id, NbrInscrip, pic, tB, tBid, titre, description));
				replaceOverListe(0);
			}else if(type==3){
				map.addOverlay(new createMarker(point, 3, 3, id, NbrInscrip, pic, tB, tBid, titre, description));
				replaceOverListe(0);
			}
		});
	}
	
	nbreMarqueursAffiches++;
	//on fait le pan seulement une fois qu'on a affiché le dernier marqueur.
	if (nbreMarqueurs == nbreMarqueursAffiches && afficherInscriptionDefaut == true){
		panGmap(bulleDefautPosY, bulleDefautPosX, 2, 3,bulleDefautId,'','','','','', 1);
	}
	return marker;
}
var flagInfoTitreOuvert;
flagInfoTitreOuvert = false;
function hideInfoTitre(){
infoTitre.style.visibility="hidden";
flagInfoTitreOuvert=false;
}
function showInfoTitre(marker) {
infoTitre.innerHTML = marker.infoTitre;
var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());
var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
var anchor=marker.icon.iconAnchor;
var width=marker.icon.iconSize.width;
var height=marker.icon.iconSize.height;
var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x - anchor.x + width - width/2,- offset.y + point.y +anchor.y -height/8));
pos.apply(infoTitre);
infoTitre.style.visibility="visible";
flagInfoTitreOuvert = true;
}
function Loading(bounds, opt_weight, opt_color, opt_backgroundColor, opt_opacity) {
this.bounds_ = bounds;
this.weight_ = opt_weight || 0;
this.color_ = opt_color || "#888888";
this.backgroundColor_ = opt_backgroundColor || '#FFFFFF';
this.opacity_ = opt_opacity || 100;
}
Loading.prototype = new GOverlay();
Loading.prototype.initialize = function(map) {
var div = document.createElement("div");
div.setAttribute('id','Gmapoverlay');
div.style.position = "absolute";
div.style.textAlign = "center";
var objImage = document.createElement("img");
objImage.setAttribute('id','loadingImageGmap');
objImage.setAttribute('src','http://' + defaultBaseURL + '/inc/Gmap/Gx/indicator_square.gif');
div.appendChild(objImage);
map.getPane(G_MAP_FLOAT_PANE).appendChild(div);
this.map_ = map;
this.div_ = div;
}
Loading.prototype.remove = function() {
this.div_.parentNode.removeChild(this.div_);
}
Loading.prototype.copy = function() {
return new Rectangle(this.bounds_, this.weight_, this.color_,this.backgroundColor_, this.opacity_);
}
Loading.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 = "40px";
this.div_.style.left = (Math.min(c2.x, c1.x) - this.weight_) + "px";
this.div_.style.top = ( c2.y + ( (c1.y-c2.y)/2 ) - 20 ) + "px";	
}
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
if(defaultPrint==false){
map.addControl(new GMapTypeControl());
map.addControl(new GSmallZoomControl());
//GEvent.addListener(map,'load',function(){panGmap(bulleDefautPosY, bulleDefautPosX, 2, 3,bulleDefautId,'','','','','', 1);});
//panGmap(bulleDefautPosY, bulleDefautPosX, 2, 3,bulleDefautId,'','','','','', 1);

}
map.setCenter(new GLatLng(defaultLat,defaultLng), defaultZoom);
if(defaultPrint==false){
infoTitre = document.createElement("div");
document.getElementById("map").appendChild(infoTitre);
infoTitre.style.visibility="hidden";
var geocoder = new GClientGeocoder();
var bounds = map.getBounds();
var southWest = bounds.getSouthWest();
var northEast = bounds.getNorthEast();
var lngSpan = northEast.lng() - southWest.lng();
var latSpan = northEast.lat() - southWest.lat();
boundsExtendSouth = southWest.lat() - 180;
boundsExtendWest = southWest.lng() - 360;
boundsExtendNorth = northEast.lat() + 180;
boundsExtendEast = northEast.lng() + 360;
var boundsOldSouth = boundsExtendSouth;
var boundsOldWest = boundsExtendWest;
var boundsOldNorth = boundsExtendNorth;
var boundsOldEast = boundsExtendEast;
var center = map.getCenter();
var zoom = map.getZoom();
var oldZoom = zoom;
GEvent.addListener(map, "moveend", function() {
bounds = map.getBounds();
southWest = bounds.getSouthWest();
northEast = bounds.getNorthEast();
lngSpan = northEast.lng() - southWest.lng();
latSpan = northEast.lat() - southWest.lat();
center = map.getCenter();
zoom = map.getZoom();

if( (southWest.lat() < boundsExtendSouth) || (southWest.lng() < boundsExtendWest) || (northEast.lat() > boundsExtendNorth) || (northEast.lng() > boundsExtendEast) || (oldZoom != zoom) ){
boundsExtendSouth = southWest.lat() - 180;
boundsExtendWest = southWest.lng() - 360;
boundsExtendNorth = northEast.lat() + 180;
boundsExtendEast = northEast.lng() + 360;
//oldZoom = zoom;
boundsOldSouth = boundsExtendSouth;
boundsOldWest = boundsExtendWest;
boundsOldNorth = boundsExtendNorth;
boundsOldEast = boundsExtendEast;
//alert('oldZoom: ' + oldZoom + ' zoom: ' + zoom);
//if( (zoom == 7) || (zoom == 10) || (zoom == 13) || ( zoom == 15 ) ){
if( ( oldZoom>=7 && zoom<=7 ) || ( oldZoom<=7 && zoom>=7 ) || ( zoom<=10 && oldZoom>=10 ) || ( zoom>=10 && oldZoom<=10 ) ){
//alert('Reload map');
GmapXmlRequest();
}
}
/*
if(zoom >= 13){
document.getElementById("LegendGMapVille").style.display = 'block';
document.getElementById("LegendGMapRegion").style.display = 'none';
//legendImg.src="http://" + defaultBaseURL + "/inc/Gmap/gx/legendVille_" + gLang + ".gif";
}else{
document.getElementById("LegendGMapVille").style.display = 'none';
document.getElementById("LegendGMapRegion").style.display = 'block';
//legendImg.src="http://" + defaultBaseURL + "/inc/Gmap/gx/legendRegion_" + gLang + ".gif";
}
*/
oldZoom = zoom;

});
}
GmapXmlRequest();
}
};

