var map;

function mapinitialize() {
	var latlng = new google.maps.LatLng(47.5, -100.1);
	var myOptions = {
	zoom: 7,
	center: latlng,
	mapTypeId: google.maps.MapTypeId.HYBRID
	};//end my options
	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}//end mapinitialize

try{
function pinFunctionClass(address, businessname, lat, lon){
	var addy = address;
	var business = businessname;
	var lattitude = lat;
	var longitude = lon;
	delete lat;
	delete lon;
	delete address;
	delete businessname;
	var markers;
	var markerMade;
	
	this.showHide = function (){
		if ((markerMade == undefined || markerMade== false)){
			makepin(addy, business, lattitude, longitude);
		}else{
			if(markers.getVisible()){
				markers.setVisible(false);
			}else{
				markers.setVisible(true);
			}
		}
	};
	
	/***************************************************
	* Function creates the marker object including the action
	* listeners for the marker.
	***************************************************/
	function makepin(address, business, lattitude, longitude){
		var geocoder;
		geocoder = new google.maps.Geocoder();
		if (lattitude != 0 && longitude != 0){
			var latlon = new google.maps.LatLng(lattitude, longitude);
			map.setCenter(latlon);
			map.setZoom(15);
			markers = new google.maps.Marker({
							map: map, 
							position: latlon, 
							visible:true, 
							title:business + "\n" + address, 
							//icon:'http://preview.inetzone.com/maps/untitled.gif',
							draggable:false
						});
			markerMade = true;
			
		}else{
			if (geocoder){
				geocoder.geocode( { 'address': address}, function(results, status) {
					if (status == google.maps.GeocoderStatus.OK) {
						map.setCenter(results[0].geometry.location);
						map.setZoom(15);
						markers = new google.maps.Marker({
							map: map, 
							position: results[0].geometry.location, 
							visible:true, 
							title:business + "\n" + address, 
							//icon:'http://preview.inetzone.com/maps/untitled.gif',
							draggable:false
						});
						
						//MarkerMade is set to true so that system will not try and remake marker.
						markerMade = true;
				
					} else {
						alert("Geocode was not successful for the following reason: " + status);
					}
				});
			}//end if (geocoder)
	
		}//end if(lattitude.length() > 0 && longitude.length() > 0)
	};//end makepin
	
}//end Class header
}catch(e){
	alert("pinfunctionerror " + e);
}