﻿var map;

function CreateMarker(map, point, name, address, phone, website) {
    var marker = new GMarker(point);
    //add an event that is fired when someone clicks on the specific marker
    //	that we just added, also add the dialog box text
    GEvent.addListener(marker, "click", function() {
        var myHtml = "<table><tr><td align=left><font align=left color=6459c4 face=helvetica,arial,verdana size=2><strong>&nbsp;" + name + "</strong></font></td></tr>" +
					 "<tr><td height=21px><font color=000000 face=helvetica,arial,verdana size=2>&nbsp;" +
					 address + "<br>&nbsp;" +
					 phone + "&nbsp;&nbsp;" +
					 website +
					 "</tr></table>";
        map.openInfoWindowHtml(point, myHtml);
    });
    return marker;
}

//this loads the map and pertinent markers -- it is called by the body onload event handler
function LoadMap() {
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(41.494539, -82.832393), 13);

        map.enableScrollWheelZoom();

        map.setZoom(9);

        map.setUIToDefault();
    }
}

function AddToItinerary(categoryItemId,btnAdd, btnRemove) {
    $.ajax({
        type: "POST",
        url: "/itinerary/business-service.aspx/AddItemToItinerary",
        data: "{'categoryItemId':'" + categoryItemId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(response) {
            $(btnRemove).css('display', 'block');
            $(btnAdd).css('display', 'none');
        }
    });
}

function RemoveFromItinerary(categoryItemId,btnAdd, btnRemove) {
    $.ajax({
        type: "POST",
        url: "/itinerary/business-service.aspx/RemoveItemFromItinerary",
        data: "{'categoryItemId':'" + categoryItemId + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(response) {

        $(btnRemove).css('display', 'none');
        $(btnAdd).css('display', 'block');
        }
    });
}
