(function($) {
function initialize(address) {	
	//alert(address);
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("companyLocalisationMap"));
		map.addControl(new GLargeMapControl());
		var bottomRight = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(5,30));
		map.addControl(new GMapTypeControl(), bottomRight);
		geocoder = new GClientGeocoder();
		//var address = "45 boulevard leclerc roubaix";
		if (geocoder) {
			geocoder.getLatLng(
				address,
				function(point) {
					if (!point) {
						alert(address + " introuvable");
					} else {				
						panoramaOptions = { latlng:point };
						if(document.getElementById("companyLocalisationStreetView") != null) {
							myPano = new GStreetviewPanorama(document.getElementById("companyLocalisationStreetView"), panoramaOptions);
							GEvent.addListener(myPano, "error", handleNoFlash);
						}
						map.setCenter(point, 17);
						var marker = new GMarker(point);
						map.addOverlay(marker);
					}
				}
			);
		}   
	}
}  

function handleNoFlash(errorCode) {
	var 
		NO_NEARBY_PANO = 600 ,
		FLASH_UNAVAILABLE = 603 
	;
	
	if(errorCode == NO_NEARBY_PANO) {
		//L'adresse n'est pas disponible pour la street view
		return;
	} else if(errorCode == FLASH_UNAVAILABLE) {
		alert('Flash n\'a pas été détecté sur votre ordinateur. Certaines fonctionalités pourraient ne pas fonctionner.');
		return
	}
}

function detectFirebug() { 
   if (window.console && window.console.firebug) { 
   		$('#firebug-alert').show();
   } 
} 

$(document).ready(function() {
	detectFirebug();
	initialize(address)
	
});
})(jQuery);