
/* Validation */
function fncLocations_Validate(element) {
	new Validation(element); 
}


/* Google Map Init */
function fncLocations_Init(address, canvas) {
	
	var geocoder;
	var map;

	// draw map
	var myOptions = {
		zoom: 12,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	
	// do it
	map = new google.maps.Map(document.getElementById(canvas), myOptions);
	
	// place it on the spot of the address
	geocoder = new google.maps.Geocoder();
	geocoder.geocode( { 'address': address}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
		  
			// center it
			map.setCenter(results[0].geometry.location);
			
			// drop marker
			var marker = new google.maps.Marker({
				map: map, 
				position: results[0].geometry.location
			});
			
			// info bubble
			var infowindow = new google.maps.InfoWindow({
				content: results[0].formatted_address, 
				maxWidth: 200
			});
			
			// listen for a click on the red marker
			google.maps.event.addListener(marker, 'click', function() {
				infowindow.open(map,marker);
			});
		
		} else {
			$(canvas).update("Geocode was not successful for the following reason: " + status);
		}
	});							   
}

	
