window.onload = function() {init()};

var map;

function init()
{
    // create the map
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("gig_map"));
        //map.addControl(new GMapTypeControl());
        map.addControl(new GSmallZoomControl());
        map.setCenter(new GLatLng(63.15436, 15.73242), 3);
    }
}

function show_location(lat, lon)
{
    //hide_map(function() {
        map.clearOverlays();
        map.addOverlay(new GMarker(new GLatLng(lat, lon)));
        map.setCenter(new GLatLng(lat, lon), 7);
        show_map();
    //});
}

function hide_map(func)
{
    var height = document.getElementById("gig_map").clientHeight;
    if(height > 0) {
        document.getElementById("gig_map").style.height = (height - 20) + 'px';
        window.setTimeout(hide_map, 5, func);
    }
    else {
        document.getElementById("map_container").style.display = 'none';
        document.getElementById("hide").style.display = 'none';
        if(func != undefined)
            func();
    }
}

function show_map()
{
    if(document.getElementById("map_container").style.display == 'none') {
        document.getElementById("map_container").style.display = 'block';
        document.getElementById("hide").style.display = 'inline';
    }

    var height = document.getElementById("gig_map").clientHeight;
    if(height < 200) {
        document.getElementById("gig_map").style.height = (height + 20) + 'px';
        window.setTimeout(show_map, 5);
    }
}
