var map;
var markers = new Array();
var points = new Array();
var zoom_value = 14;

function load_map(map_id) {
if(GBrowserIsCompatible()) {
map = new GMap2(document.getElementById(map_id));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(41.50685, -81.679752), 14);
}
}

function createInfoMarker(point, marker_content, icon) {
var marker = new GMarker(point, icon);

if(marker_content != '') {
GEvent.addListener(marker, 'click',
function() {
marker.openInfoWindowHtml(marker_content);
}
);
}

return marker;
}

function load_address(marker_id, address, marker_content, fail_id) {
if(GBrowserIsCompatible()) {
var geocoder = new GClientGeocoder();

geocoder.getLatLng(
address,
function(point) {
if(point) {
points[marker_id] = point;
markers[marker_id] = createInfoMarker(point, marker_content);
map.addOverlay(markers[marker_id]);
} else if(fail_id && document.getElementById(fail_id)) {
document.getElementById(fail_id).style.display = 'none';
document.getElementById(fail_id).innerHTML = '';
}
}
);
}
}

function load_one_address(marker_id, address, marker_content, fail_id) {
if(GBrowserIsCompatible()) {
var geocoder = new GClientGeocoder();

geocoder.getLatLng(
address,
function(point) {
if(point) {
var marker = createInfoMarker(point, marker_content);
map.addOverlay(marker);
map.setCenter(point, 13);
} else if(fail_id && document.getElementById(fail_id)) {
document.getElementById(fail_id).style.display = 'none';
document.getElementById(fail_id).innerHTML = '';
}
}
);
}
}

function load_point(marker_id, Lat, Lng, marker_content, fail_id) {
if(GBrowserIsCompatible()) {
var point = new GLatLng(Lat,Lng);

if(point) {
points[marker_id] = point;
markers[marker_id] = createInfoMarker(new GLatLng(Lat,Lng), marker_content);
map.addOverlay(markers[marker_id]);
} else if(fail_id && document.getElementById(fail_id)) {
document.getElementById(fail_id).style.display = 'none';
document.getElementById(fail_id).innerHTML = '';
}
}
}

function process_markers(center_marker_id, zoom_value, fail_id) {
if(points.length) {
map.setCenter(points[center_marker_id], zoom_value);
} else if(fail_id && document.getElementById(fail_id)) {
document.getElementById(fail_id).style.display = 'none';
document.getElementById(fail_id).innerHTML = '';
}
}


function highlight(marker_id) {
if(map.isLoaded()) {
GEvent.trigger(markers[marker_id], 'click');
}
}

function resetmap() {
map.setCenter(new GLatLng(41.50685, -81.679752), 6);
}
