//<![CDATA[
var map;
var icon0;
var newpoints = new Array();

function addLoadEvent(func) {
        var oldonload = window.onload;
        if (typeof window.onload != 'function'){
                window.onload = func
        } else {
                window.onload = function() {
                        oldonload();
                        func();
                }
        }
}

addLoadEvent(loadMap);
addLoadEvent(addPoints);

function loadMap() {
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(27.744150, -15.584542),8);
        map.setMapType(G_SATELLITE_MAP);

        icon0 = new GIcon();
        icon0.image = "bilder/marker.png";
        icon0.shadow = "bilder/shadow50.png";
        icon0.iconSize = new GSize(20, 34);
        icon0.shadowSize = new GSize(37, 34);
        icon0.iconAnchor = new GPoint(9, 34);
        icon0.infoWindowAnchor = new GPoint(9, 2);
        icon0.infoShadowAnchor = new GPoint(18, 25);

}

function addPoints() {

        newpoints[0] = new Array(27.773642, -15.606605, icon0, 'Maspalomas Playa Ingles','<a href="weatherstations_gran-canaria/El-Tablero.php" target="_self">Maspalomas Playa Ingles</a>');
        newpoints[1] = new Array(27.76028, -15.60972, icon0, 'El Tablero, Maspalomas','<a href="weatherstations_gran-canaria/El-Tablero-2.php" target="_self">El Tablero, Maspalomas</a>');
        newpoints[2] = new Array(27.918606, -15.430475, icon0, 'Villa de Ingenio','<a href="weatherstations_gran-canaria/Ingenio.php" target="_self">Villa de Ingenio</a>');
        newpoints[3] = new Array(28.117260, -15.422916, icon0, 'Las Palmas','<a href="weatherstations_gran-canaria/Las-Palmas.php" target="_self">Las Palmas</a>');
        newpoints[4] = new Array(27.770107, -15.574520, icon0, 'MASPALOMAS','<a href="weatherstations_gran-canaria/Maspalomas-2.php" target="_self">MASPALOMAS</a>');
        newpoints[5] = new Array(27.736667, -15.59, icon0, 'Playa_Maspalomas','<a href="weatherstations_gran-canaria/Maspalomas-Beach.php" target="_self">Playa_Maspalomas</a>');
        newpoints[6] = new Array(27.761723, -15.568806, icon0, 'Maspalomas, Playa del Ingles','<a href="weatherstations_gran-canaria/Playa-del-Ingles.php" target="_self">Maspalomas, Playa del Ingles</a>');
        newpoints[7] = new Array(28.011065, -15.532872, icon0, 'Vega de San Mateo (Casco)','<a href="weatherstations_gran-canaria/San-Mateo.php" target="_self">Vega de San Mateo (Casco)</a>');
        newpoints[8] = new Array(28.730000, -17.750000, icon0, 'El Gurugu, Puntallana','<a href="weatherstations_la-palma/Puntallana.php" target="_self">Puntallana</a>');
        newpoints[9] = new Array(28.686270, -17.764799, icon0, 'El Pilar S/C de LA PALMA','<a href="weatherstations_la-palma/Santa-Cruz.php" target="_self">S/C de LA PALMA</a>');
        newpoints[10] = new Array(27.809378, -17.913658, icon0, 'Valverde','<a href="weatherstations_el-hierro/Valverde.php" target="_self">Valverde</a>');
        newpoints[11] = new Array(27.783695, -17.997162, icon0, 'El Hierro Las Puntas','<a href="weatherstations_el-hierro/Las-Puntas.php" target="_self">El Hierro Las Puntas</a>');
        newpoints[12] = new Array(28.051994, -14.350795, icon0, 'MORRO JABLE','<a href="weatherstations_fuerteventura/Morro-Jable.php" target="_self">MORRO JABLE</a>');
        newpoints[13] = new Array(28.493334, -13.866389, icon0, 'PUERTO DEL ROSARIO','<a href="weatherstations_fuerteventura/Puerto-Rosario.php" target="_self">PUERTO DEL ROSARIO</a>');
        newpoints[14] = new Array(28.956371, -13.583994, icon0, 'La Concha Beach, Arrecife','<a href="weatherstations_lanzarote/Arrecife.php" target="_self">La Concha Beach, Arrecife</a>');
        newpoints[15] = new Array(28.870684, -13.826294, icon0, 'Lanzarote, Playa Blanca','<a href="weatherstations_lanzarote/Playa-Blanca-2.php" target="_self">Lanzarote, Playa Blanca</a>');
        newpoints[16] = new Array(28.876112, -13.822222, icon0, 'PLAYA BLANCA, LANZAROTE','<a href="weatherstations_lanzarote/Playa-Blanca.php" target="_self">PLAYA BLANCA, LANZAROTE</a>');

        for(var i = 0; i < newpoints.length; i++) {
                var point = new GPoint(newpoints[i][1],newpoints[i][0]);
                var popuphtml = newpoints[i][4] ;
                var marker = createMarker(point,newpoints[i][2],popuphtml);
                map.addOverlay(marker);
        }
}

function createMarker(point, icon, popuphtml) {
        var popuphtml = "<div id=\"popup\">" + popuphtml + "<\/div>";
        var marker = new GMarker(point, icon);
        GEvent.addListener(marker, "click", function() {
                marker.openInfoWindowHtml(popuphtml);
        });
        return marker;
}
//]]>
