function exO(a){return Math.round(a)+"px"}

GMap.prototype.applyZoom = function(a)
{
        var b = this;
        var c = Math.floor(Math.log(b.viewSize.width) * Math.LOG2E - 2);
        var d = b.zoomLevel - a;
        if (d > c)
        {
                d = c;
        }
        else if (d < -c)
        {
                d = -c;
        }

        var e = Math.pow(2, d);
        b.div.style.zoom = e;
        var f = b.viewSize.width * b.centerScreen.x;
        var h = b.viewSize.height * b.centerScreen.y;
        b.div.style.left = exO((this._savedOffset.x - f) * e + f);
        b.div.style.top = exO((this._savedOffset.y - h) * e + h);

}

GMap.prototype.smoothZoomTo = function(newZoom)
{
        var a = this;

        if (a.div == undefined || a.div.style.zoom == undefined)
        {
                a.setZoom(newZoom);
                return;
        }

        a._currentZoom = parseInt(a.getZoom());
        a._targetZoom = newZoom;
        a._savedOffset={"x" : a.div.offsetLeft, "y" : a.div.offsetTop};
        a.hideOverlays();

        this._zoomInterval = setInterval(function() {
                a._currentZoom += 0.3 * (a._targetZoom - a._currentZoom);

                if (Math.abs(a._targetZoom - a._currentZoom) < 0.05)
                {
                        if (a._savedOffset)
                        {
                                a.div.style.left=exO(a._savedOffset.x);
                                a.div.style.top=exO(a._savedOffset.y);
                        }
                        a.div.style.zoom = 1;
                        a.showOverlays();
                        a.setZoom(a._targetZoom);
                        a._savedOffset = null;
                        window.clearInterval(a._zoomInterval);
                }
                else
                {
                        a.applyZoom(a._currentZoom);
                }
        }, 50);

}

function zoom(oEvent, scr)
{
try{
        var new_zoom = map.getZoom();
        if (scr >= 120)
                new_zoom++;
        else
                new_zoom--;

        map.smoothZoomTo(new_zoom);
        if (oEvent.preventDefault)
                oEvent.preventDefault();
}
catch (exception) { }
}

// Hook the mouse wheel to zoom the map on Mozilla and Internet Explorer 6.0 browsers
function hookMouseWheelHandlers(id)
{
        var d = document.getElementById(id);
        if (d)
        {
                try
                {
                        if (document.body.addEventListener)
                                d.addEventListener('DOMMouseScroll', function(oEvent) {
zoom(oEvent, oEvent.detail * -40); }, false);
                        else
                                d.onmousewheel = function() { zoom(event, event.wheelDelta); return
false; }
                } catch (ex) { }
        }

} 