  function isset(varname)  {
  if(typeof( window[ varname ] ) != "undefined") return true;
  else return false;
}
  
  function initialize() {
		
		if (window.XMLHttpRequest){
			projets=new XMLHttpRequest();
		}else{
			projets=new ActiveXObject("Microsoft.XMLHTTP");
		}
		projets.open("GET","/xml/allprojet.xml",false);
		projets.send("");
		projets=projets.responseXML; 
	  
	  	projs = projets.getElementsByTagName('projet');
		nbprojet = projs.length
		//alert(projs[0].childNodes[0].childNodes[0].nodeValue);
		//alert();
	  if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("mapQuest"));
		map.setUIToDefault();

		
		/*********************************/
		 var baseIcon = new GIcon(G_DEFAULT_ICON);
		baseIcon.image = "http://www.vivrealaval.ca/images/icone.png";
		baseIcon.shadow = "/";
		baseIcon.iconSize = new GSize(23, 25);
		baseIcon.shadowSize = new GSize(1, 1);
		baseIcon.iconAnchor = new GPoint(5, 10);
		baseIcon.infoWindowAnchor = new GPoint(15, 20);


		var iicon = new GIcon(G_DEFAULT_ICON);
		iicon.image = "http://www.vivrealaval.ca/images/icone2.png";
		iicon.shadow = "/";
		iicon.iconSize = new GSize(23, 25);
		iicon.shadowSize = new GSize(1, 1);
		iicon.iconAnchor = new GPoint(5, 10);
		iicon.infoWindowAnchor = new GPoint(15, 20);

		/*************************************/
		
		/*
		function createMarker(point, number,images,title) {
		 

		  var marker = new GMarker(point,markerOptions);
		  
		  marker.value = number;
		  
		  myHtml = '<table border="0"><tr><td valign="top"><img src="'+images+'" alt=""></td><td width="5"></td><td valign="top"><td>'+number+'<a href="http://www.google.com">google</a></td></tr></table>';
		  
		  GEvent.addListener(marker, "click", function() {
			
			map.openInfoWindowHtml(point, myHtml);
		  });
		  return marker;
		}
		*/
		function createMarker(point, number,images,title,type,local,url,urllabel,id,one) {
				markerOptions = { icon:baseIcon };
				markerOptions2 = { icon:iicon };
				
				
				var marker = new GMarker(point,markerOptions);
				var marker2 = new GMarker(point,markerOptions2);
			if(one == true ){
				GEvent.addListener(marker2, "click", function() {
					var myHtml = '<table border="0" width="400" height="185"><tr><td valign="top"><img src="'+images+'" alt=""></td><td width="5"></td><td valign="top"><td valign="top"><strong>'+title+'</strong><br><br>'+local+'<br><br>'+type+'<br><br><a href="'+url+'?id='+id+'">'+urllabel+'</a></td></tr></table>';
					map.openInfoWindowHtml(point, myHtml);
				})
				return marker2;
			
			}else{
				GEvent.addListener(marker, "click", function() {
					var myHtml = '<table border="0" width="400" height="185"><tr><td valign="top"><img src="'+images+'" alt=""></td><td width="5"></td><td valign="top"><td valign="top"><strong>'+title+'</strong><br><br>'+local+'<br><br>'+type+'<br><br><a href="'+url+'?id='+id+'">'+urllabel+'</a></td></tr></table>';
					map.openInfoWindowHtml(point, myHtml);
				})
				return marker;
			
			}
			
			
			}


		
		
		for (var i = 0; i < nbprojet; i++) {
				id = projs[i].getElementsByTagName('id')[0].childNodes[0].nodeValue;
				

				
				title = projs[i].getElementsByTagName('titre')[0].childNodes[0].nodeValue;
				images = projs[i].getElementsByTagName('images')[0].childNodes[0].nodeValue;
				local = projs[i].getElementsByTagName('localisation')[0].childNodes[0].nodeValue;
				lattitude = projs[i].getElementsByTagName('lattitude')[0].childNodes[0].nodeValue
				 longitude = projs[i].getElementsByTagName('longitude')[0].childNodes[0].nodeValue
				 
				if (isset('currentProjetId')){
					if(currentProjetId == id){
						one = true;
						onelatlon ={lat:lattitude,lon:longitude}
					}else{
						one = false;
					}
				}else{
					one = false;
				}
				 
				 
				type = projs[i].getElementsByTagName('type')[0].childNodes[0].nodeValue
				url = projs[i].getElementsByTagName('url')[0].childNodes[0].nodeValue
				urllabel= projs[i].getElementsByTagName('urllabel')[0].childNodes[0].nodeValue
				var point = new GLatLng(lattitude,longitude);
				
				map.addOverlay(createMarker(point, i + 1,images,title,type,local,url,urllabel,id,one));
			}
		


		if (isset('onelatlon')){
			centerMap = new GLatLng(onelatlon.lat,onelatlon.lon);
			map.setCenter(centerMap, 15);
		}else{
			centerMap = new GLatLng(45.551566,-73.744638);
			map.setCenter(centerMap, 12);
		}
	    
      }
    }
	
	
	
		
