//SET NOCONFLICT TO WORK WITH OTHER LIBRARIES
jQuery.noConflict();

//CUSTOM JQUERY FUNCTIONS
jQuery(document).ready(function(){

	jQuery('ol li:odd, ul li:odd').addClass('odd');
	jQuery('ol li:even, ul li:even').addClass('even');
	jQuery('ol li:last-child, ul li:last-child').addClass('last');
	
	jQuery('#events div.event:last-child').addClass('last');
	
});


//Set googlemaps variables
var map = null;
var geocoder = null;

//Initialize GoogleMaps and create map
function initialize() {
	
	//Check if browser can render googlemaps
	if (GBrowserIsCompatible()) {
		
		//Initialize geocoder
		geocoder = new GClientGeocoder();
		
	}
	
}

//Geocode address and create new map point
function showAddress(street, city, province) {
	
	var fulladdress = street + ", " + city + ", " + province + ", Canada";
	var address = city + ", " + province + ", Canada";
	
	//Check if geocoder is initiated
	if (geocoder) { 
		
		//Geolocate address
		geocoder.getLatLng(fulladdress, function(point) {
			
			//If address does not return a point
			if (!point) {
				
				//Check for point using city and province only
				geocoder.getLatLng(address, function(point2) {
					
					//If address does not return a point
					if (!point) {
					
						//Do nothing
					
					} else {
						
						jQuery('#map').show();
						
						//Create new map
						map = new GMap2(document.getElementById("map"));
					 
						//Center map on point
						map.setCenter(point2, 10);
						
						//Add point to map
						var marker = new GMarker(point2);
						map.addOverlay(marker);						
					
					}
					
				});
	        
	        } else {
				
				jQuery('#map').show();
				
				//Create new map
				map = new GMap2(document.getElementById("map"));
				
				//Center map on point
				map.setCenter(point, 10);
				
				//Add point to map
				var marker = new GMarker(point);
				map.addOverlay(marker);
				
	        }
	      
		});

	}
  
}