﻿var markers = new Array();

$(document).ready(function () {
    extraOptions($("#ckToLetOnly").attr('checked'));
    $("#ckToLetOnly").click(function () {
        extraOptions($(this).attr('checked'));
    });
});

function extraOptions(shouldShow) {
    if (shouldShow) {
        $("#additionalOptions").show();
    } else {
        $("#additionalOptions").hide();
    }
}

function addMarker(number, phc, pubName, lat, lon, address, showImg) {
    var pos = new MMLatLon(lat, lon);
    createMarker(pos, number, phc, pubName, address, showImg);
}

//Add a marker to the map at the specified point, and attach an info box showing a number:
function createMarker(location, number, phc, pubName, address, showImg) {
    var icon = MM_DEFAULT_ICON.copy();
    marker = mapviewer.createMarker(location, { 'label': pubName, 'icon': icon, 'text': number });
    markers.push(marker);
    var html = '';
    if (showImg) {
        html += '<img class=\"map_thumb flright\" src=\"/img/cache/thumb/' + phc + '_thumb.jpg\" />';
    }
    html += '<h1>' + pubName + '<' + '/h1>';
    html += '<p><a href=\"/pubs/view/' + phc + '\">View details</a></p>';
    if (address && address != '') {
        html += '<p class=\"map_address\">' + address + '</p>';
    }
    marker.setInfoBoxContent(html);
} 
