﻿function init() {

    div = document.createElement("div");     
    div.style.width = "1em";
    div.style.height = "1em";     
    document.body.appendChild(div);
    pxInEm = div.offsetWidth;
    document.body.removeChild(div);
    
    var isIe = false;
    if (navigator.appName.indexOf('Microsoft Internet Explorer') != -1)
        isIe = true;
       
    
    if (isIe == true)
      
    updateImagesSize();
    
    updateMap();    
}

function updateImagesSize() {     

     var images = document.getElementsByTagName("img");
     
     for (var imageIndex = 0; imageIndex < images.length; imageIndex++) {
        var image = images[imageIndex];
        image.style.width = (image.offsetWidth / pxInEm) + 'em';
     }          
}

function updateMap() {


    if (document.getElementById("mapMoscow") != null)	{

    	if (GBrowserIsCompatible()) {
	       var mapMoscow = new GMap2(document.getElementById("mapMoscow"));
	        mapMoscow.addControl(new GSmallMapControl());
	        mapMoscow.addControl(new GMapTypeControl());        
	    
	        mapMoscow.setCenter(new GLatLng(55.729542, 37.6646), 16);			    
		    var point = new GLatLng(55.729644, 37.6637);
		
            var marker = new GMarker(point);
            GEvent.addListener(marker, "click", function() {
	            marker.openInfoWindowHtml('000 Вларок. Кровля и изоляция.<br/>г. Москва, ул. Крутицкий Вал, д. 14');
                });		
		
		    mapMoscow.addOverlay(marker);
		 }
    }

    
    if (document.getElementById("mapPiter") != null)	{

    	if (GBrowserIsCompatible()) {
	       var mapPiter = new GMap2(document.getElementById("mapPiter"));
	        mapPiter.addControl(new GSmallMapControl());
	        mapPiter.addControl(new GMapTypeControl());        
	    
	        mapPiter.setCenter(new GLatLng(59.981452,30.360207), 16);			    
		    var point = new GLatLng(59.9815,30.358207);
		
            var marker = new GMarker(point);
            GEvent.addListener(marker, "click", function() {
	            marker.openInfoWindowHtml('000 Вларок. Кровля и изоляция.<br/>г. Санкт - Петербург, ул. Новолитовская, д. 15. офис №63');
                });		
		
		    mapPiter.addOverlay(marker);
		 }
    }
}

