﻿var _map = null;
function iniMap()
{
    if (GBrowserIsCompatible()) {
        _map = new GMap2(document.getElementById("map"));         
        _map.addControl(new GSmallMapControl());
        _map.addControl(new GMapTypeControl());     
      }
}
function mapVenue(sVenue, sAddress, sCity, sZip)
{
     if(sAddress == '' && sZip == '')
        return;
    //remove all existing points
    _map.clearOverlays();
    var oGeocoder = new GClientGeocoder();
    oGeocoder.getLatLng(sAddress + ', ' + sZip, 
        function(gLatLn)
        {
            var sInfoWindowHTML = '<div class=\"infoWindow\"><strong>' + sVenue + '</strong><br/>' + sAddress + "<br/>" + sCity + ", " + sZip + "</div>";
            var marker = new GMarker(gLatLn);
            _map.setCenter(gLatLn, 14);
            _map.addOverlay(marker);
            GEvent.addListener(marker, "click", function() {
                    marker.openInfoWindowHtml(sInfoWindowHTML, {maxWidth:150});
                  });

            marker.openInfoWindow(sInfoWindowHTML, {maxWidth:150});
        }
    );
    //set up directions
    document.getElementById('hdnEndAddress').value = sAddress;
    document.getElementById('hdnEndZip').value = sZip;
    document.getElementById('directionsTitle').innerHTML = sVenue;    
}
function getDirections(sAddress, sZip)
{
    var tbxStartingAddress = document.getElementById('tbxStartingAddress')
    if(tbxStartingAddress.value != '')
        window.open('http://maps.google.com/maps?saddr=' + encodeURI(tbxStartingAddress.value) + '&daddr=' + sAddress + ',%20' + sZip,'directions')
}

function showTickets(sEventID)
{
    window.location = '/viewTickets.aspx?eventID=' + sEventID
}
