var baseIcon = new GIcon(G_DEFAULT_ICON);
baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
        
        
function createMarker(point, data, type) {
    var dataIcon = new GIcon(baseIcon);
    dataIcon.image = "/i/test_marker.png";

    var marker = new GMarker(point, { icon: dataIcon });
    var description = getDescription(type, data)

    GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(description);
    });
    return marker;
}

function getDescription(type, data)
{
    var dsc = '';
    switch(type) {
        case 'city': 
            dsc = '<b>'+data['name']+'</b><hr /><a href="'+data['city-url']+'">О городе</a>';
            if (typeof(data['tours']) != 'undefined') {
                dsc += '<br /><a href="'+data['city-url']+'#tours">Туров: '+data['tours']+'</a><br /><a href="'+data['city-url']+'#feedbacks">Отзывов: '+data['feedbacks']+'</a>';
            }
        break;
        
        case 'showplace': 
            dsc = '<b>'+data['name']+'</b><hr /><a href="'+data['url']+'">О достопримечательности</a>';
        break;
        
        
    }
    
    return dsc;
}

function setGmapPath(tourPath)
{
    if (GBrowserIsCompatible()) {
        if (typeof (encodedPolyline) == 'object') {
            map.removeOverlay(encodedPolyline, true);
        }
        
        encodedPolyline = new GPolyline.fromEncoded({
            color: "#FF0000",
            weight: 4,
            points: tourPath[0],
            levels: tourPath[1],
            zoomFactor: 32,
            numLevels: 4
        });
        
        map.addOverlay(encodedPolyline);
    }
}

function getPopPanel(container, type, id)
{
    
    msg = { 
        "map-tour": "<a href='/tours/view/"+id+"'>Ознакомиться с выбранным туром</a>"
    };
   
    $(container).find('div#pop-panel').remove();
    
    box = '<div id="pop-panel" class="pop_panel"><div class="png_crop">'+msg[type]+' <a style="margin-left:50px" href="#" onclick="$(this).parents(\'.pop_panel\').remove()">Скрыть</a></div></div>';
    topValue = ( $(container).height() - 50 ) + 'px';  
    
    $(box).css({'position':'absolute', 'top':topValue , 'z-index':'4000'}).appendTo(container);
}