﻿
//<![CDATA[

function load() {

    var loop = true;
    var counter = 0;
    var mapname = "map";
    while (loop) {
        counter = counter + 1;
        if (document.getElementById(mapname + counter) == null) {
            loop = false;
            continue;
        }

        var ispopup = document.getElementById('ispopup');

        var ilat = document.getElementById(mapname + counter + 'lat').value;
        var ilng = document.getElementById(mapname + counter + 'lng').value;

        var myLatlng = new google.maps.LatLng(parseFloat(ilat), parseFloat(ilng));

        var mapOptions = {
            zoom: 6,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            center: myLatlng
        };
        
        var map = new google.maps.Map(document.getElementById(mapname + counter), mapOptions);

//        if (ispopup == null)
//              //this is where the height and width are set.
//        else
        //            { size: new GSize(900, 800) });

        //        if (ispopup == null) {
        //            map.disableDragging();
        //            map.disableGoogleBar();
        //        }
        //        else {
        //            map.addControl(new GLargeMapControl3D());

        if (ispopup == null) {
            map.setOptions({ disableDefaultUI: true, draggable: false });
        }
        

    //map.addOverlay(createMarker(new GLatLng(ilat, ilng), 0));

        createMarker2(map, myLatlng, 0);
    }

}

function createMarker2(map, point, index) {

    var marker = new google.maps.Marker({
        position: point,
        map: map,
        //shadow: shadow,
        //icon: image,
        //shape: shape,
        //title: beach[0],
        //zIndex: beach[3]
    });


}

// Creates a marker whose info window displays the letter corresponding
// to the given index.
function createMarker(point, index) {

            // Create a base icon for all of our markers that specifies the
    // shadow, icon dimensions, etc.
    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);

    // Create a lettered icon for this point using our icon class
    var letter = String.fromCharCode("A".charCodeAt(0) + index);
    var letteredIcon = new GIcon(baseIcon);
    letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";

    // Set up our GMarkerOptions object
    markerOptions = { icon: letteredIcon };
    var marker = new GMarker(point, markerOptions);
    /*
    GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml("<b>Her kommer noe tekst fra FerieBoliger.<br/> Bla Bla Bla</b>");
    });*/
    return marker;
}



//]]>
    
