function initialize() {
    //Standardkordinater
    var latlng = new google.maps.LatLng(63.8205560, 20.3036110);
    var myOptions = {
        zoom: 14,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.SATELLITE
    };
    
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
  
    
    //Ny lista med bounds(för att kunna centrera efter dom pungterna som finns)
    var bounds = new google.maps.LatLngBounds();
    
    var HarKord = false;
    
    //För varje kordinat från databasen om det finns
    if (locations) {
        if (locations.length > 0) {
            for (var i = 0; i < locations.length; i++) {
                var beach = locations[i];
                if (beach) {
                    if (beach[1] && beach[2]) {
                        if (beach[1].toString() != "" && beach[2].toString() != "") {
                            HarKord = true;
                            var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
                        
                            if (myLatLng){
                                //Lägger till myLatLng till Bounds för utökning av "området"
                                bounds.extend(myLatLng);
                                var image = new google.maps.MarkerImage('/images/map/2.png',
                                //var image = new google.maps.MarkerImage('/images/map/' + beach[4] + '.png',
                                    // This marker is 20 pixels wide by 32 pixels tall.
                                    new google.maps.Size(12, 20),
                                    // The origin for this image is 0,0.
                                    new google.maps.Point(0,0),
                                    // The anchor for this image is the base of the flagpole at 0,32.
                                    new google.maps.Point(7, 20));                        
                                
                                //Sätt markör på kartan
                                var marker = new google.maps.Marker({
                                    position: myLatLng, 
                                    map: map, 
                                    icon: image, 
                                    title: beach[3]
                                }); 
                                //Räknar ut höjden på visningsboxen
                                var h = 290;
                                if (beach[5] > 0){
                                    h = parseInt(beach[5]) * 13;
                                }
                                
                                //Sätter Visningsboxen
                                SetInfoWindow(map, beach[0], marker, h)
                            }
                        }
                    }
                }
            }
        }        
    }
    
 

    //Zoomar in och centrerar efter bounds om det finns några
  //alert(locations.length);

  var browser=navigator.appName;
	if (navigator.appName=="Microsoft Internet Explorer" && locations.length == 2) {
	map.setCenter( myLatLng, 14);
	//alert("1");
 	
	 }else if  (locations.length == 1){
      map.setCenter( myLatLng, 16);
	
      //alert("2");
     
    }else{
    //	map.setCenter( myLatLng, 14);
	  map.fitBounds(bounds);
	  //alert("3");
    }	
    	
   
    // Fungerade inte plötsligt 2009-12-18
    
    //Kollar så man inte kan zomma för mycket (finns för att den inte skall zooma för långt in vid träff på en kordinat)
    //google.maps.event.addListener(map, 'zoom_changed', function() {
     //   zoomLevel = map.get_zoom();
    //    if (zoomLevel > 15) {
    //      map.set_zoom(15);
    //    }      
    //  });    
       
}

function SetInfoWindow(map, info, marker, h){
    var infowindow = new google.maps.InfoWindow(
        { content: info,
            size: new google.maps.Size(250,h)
        });        
    google.maps.event.addListener(marker, 'click', function() {
        infowindow.open(map,marker);
    });
}








function showOneSchool(location,tmpx,tmpy,strSkola, marker, height ) {
	
	document.getElementById('DivMap').style.visibility = 'visible'; 
	document.getElementById('DivMap').style.display = ''; 
	
	document.getElementById('DivCloseMap').style.visibility = 'visible'; 
	document.getElementById('DivCloseMap').style.display = ''; 
	
	     window.location.hash='tagMap';  


	

    //Standardkordinater
    var latlng = new google.maps.LatLng(63.8205560, 20.3036110);
    var myOptions = {
        zoom: 12,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.SATELLITE
    };
    
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
     
                            
                            var myLatLng = new google.maps.LatLng(tmpx, tmpy);
                           
                            if (myLatLng){
                                //Lägger till myLatLng till Bounds för utökning av "området"
                                //bounds.extend(myLatLng);
                                var image = new google.maps.MarkerImage('/images/map/' + marker + '.png',
                                    // This marker is 20 pixels wide by 32 pixels tall.
                                    new google.maps.Size(12, 20),
                                    // The origin for this image is 0,0.
                                    new google.maps.Point(0,0),
                                    // The anchor for this image is the base of the flagpole at 0,32.
                                    new google.maps.Point(7, 20));                        
                                
                                //Sätt markör på kartan
                                var marker = new google.maps.Marker({
                                    position: myLatLng, 
                                    map: map, 
                                    icon: image, 
                                    title: strSkola
                                }); 
                                
                                //Räknar ut höjden på visningsboxen
                                var h = 290;
                                //if (locations2[5] > 0){
                                //    h = parseInt(locations2[5]) * 13;
                                //}
                                
                                //Sätter Visningsboxen
                                SetInfoWindow(map, location, marker, h)
                                
                                map.setCenter(myLatLng, 3);
      
    }
    
  
       
}






function hideMap() {
	
	document.getElementById('DivMap').style.visibility = 'hidden'; 
	document.getElementById('DivMap').style.display = 'none'; 
	
	document.getElementById('DivCloseMap').style.visibility = 'hidden'; 
	document.getElementById('DivCloseMap').style.display = 'none'; 
}	









