var map, manager;
var centerLatitude = 1.360803, centerLongitude = 103.820800, startZoom = 12;

var map;

//Add Customized Icons and Info Windows
var LotusLogo = new GIcon();
LotusLogo.image = 'lotus_bigger.jpg';
LotusLogo.iconSize = new GSize(48, 24);
LotusLogo.iconAnchor = new GPoint(24, 14);
LotusLogo.infoWindowAnchor = new GPoint(24, 24);


function addMarker(latitude, longitude, description) {
    var marker = new GMarker(new GLatLng(latitude, longitude), LotusLogo);

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

    map.addOverlay(marker);
}

// Filling Vertical Space
function windowHeight() {
	// Standard browsers (Mozilla, Safari, etc.)
	if (self.innerHeight)
		return self.innerHeight;
	// IE 6
	if (document.documentElement && document.documentElement.clientHeight)
		return document.documentElement.clientHeight;
	// IE 5
	if (document.body)
		return document.body.clientHeight;
	// Just in case.
	return 0;
}

function handleResize() {
	var height = windowHeight() - document.getElementById('toolbar').offsetHeight - 30;
	document.getElementById('map').style.height = height + 'px';
	document.getElementById('sidebar').style.height = height + 'px';
}

function changeBodyClass(from, to) {
     document.body.className = document.body.className.replace(from, to);
     return false;
}

// Side Panel Toggle Buttons
function init() {
	document.getElementById('button-sidebar-hide').onclick = function() { return changeBodyClass('sidebar-right', 'nosidebar'); };
	document.getElementById('button-sidebar-show').onclick = function() { return changeBodyClass('nosidebar', 'sidebar-right'); };
	handleResize();
	
 map = new GMap2(document.getElementById("map"));
        map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GOverviewMapControl());
        map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);

        for(id in markers) {
            addMarker(markers[id].latitude, markers[id].longitude, markers[id].name);
        }
    }

window.onresize = handleResize;
window.onload = init;


