jQuery(function (){
	var idesignContactMap = {
		marker: null,
		infoWindow: null,
		map: null,

		init: function(){
			if(document.getElementById('map-canvas') == null)
				return false;
			
			if(idesignMap.marker.lat == 0 || idesignMap.marker.lng == 0)
				return false;
			
			var myLatLng = new google.maps.LatLng(idesignMap.marker.lat, idesignMap.marker.lng);

			var mapOptions = {
				center: myLatLng,
				mapTypeId: google.maps.MapTypeId.ROADMAP,
				navigationControl: true
			};

			idesignContactMap.map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
			idesignContactMap.map.setZoom(idesignMap.zoom);
			idesignContactMap.marker = new google.maps.Marker({
				position: myLatLng,
				map: idesignContactMap.map,
				title: idesignMap.marker.title,
				icon: THEME_DIR + 'images/markers/blue.png'
			});

			idesignContactMap.infoWindow = new google.maps.InfoWindow({
				content:  '<h3>'+idesignMap.marker.title+'</h3><p>'+idesignMap.marker.description.replace(/(\n)/g, "<br />")+'</p>'
			});

//			idesignContactMap.infoWindow.open(idesignContactMap.map, idesignContactMap.marker);
			google.maps.event.addListener(idesignContactMap.marker, "click", function(event) {
				idesignContactMap.infoWindow.open(idesignContactMap.map, idesignContactMap.marker);
			});

			google.maps.event.addListener(idesignContactMap.map, "click", function(event) {
				idesignContactMap.infoWindow.close();
			});

			return true;
		}
	};

	idesignContactMap.init();
	
});
