var map = null;
var geocoder = null;

function initialize() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("Kartta"));
    map.setCenter(new GLatLng(37.4419, -122.1419), 14);
    geocoder = new GClientGeocoder();
  }
}

function showAddress(address) {
  if (geocoder) {
    geocoder.getLatLng(
      address,
      function(point) {
        if (!point) {
          alert(address + " not found");
        } else {
          map.setCenter(point, 14);
          var marker = new GMarker(point);
          map.addOverlay(marker);
          //marker.openInfoWindowHtml(address);
        }
      }
    );
  }
}

function calcWeightIndex() { //v2.0
	var w = document.getElementById("weight").value;
	var h = document.getElementById("height").value;
	w = w.replace(/\,/, ".");
	h = h.replace(/\,/, ".");
	var tf = document.getElementById("result");
	if (w != '' && h != '') {
		var wi = (Math.round( (w / ((h/100)*(h/100))) * 100)) / 100;
		wi = wi.toString();
		wi = wi.replace(/\./, ",");
		tf.innerHTML = "Painoindeksisi on: " + wi;
	} else {
		tf.innerHTML = "TŠytŠ ensin molemmat kentŠt";
	}
}

$(document).ready(function(){

	// Google Maps
	initialize();
	showAddress("Paciuksenkatu 21, 00101 Helsinki");
	// Google Maps
        
});
