function googleMaps( container ) {
    this.map         = null;
    this.geoCache    = null;
    this.geocoder    = null;
    this.directions  = null;
    this.lastPoint   = null;

    this.controls   = new Array();


    if ( GBrowserIsCompatible() ) {
        this.geoCache    = new GGeocodeCache();
        this.geoCoder    = new GClientGeocoder( this.geoCache );

        this.map = new GMap2( container );

        this.map.enableDoubleClickZoom();
        this.map.enableContinuousZoom();
/*
        this.map.enableScrollWheelZoom();

        function wheelevent(e) {
            if (!e){
                e = window.event
            }

            if (e.preventDefault){
                e.preventDefault()
            }
        
            e.returnValue = false;
        }

        GEvent.addDomListener(this.map.getContainer(), "DOMMouseScroll", wheelevent);
        this.map.getContainer().onmousewheel = wheelevent; 
*/
        this.directions  = new GDirections(this.map);

    }
}

googleMaps.prototype = {
    
    addControl: function( type ) {
        this.controls.push( type );
    },


    createInfoWindow: function( point, text, opened, customIcon ) {
        this.lastPoint = point;

        if ( customIcon !== null ) {
            markerOptions = { icon:customIcon };
        } else {
            markerOptions = {};
        }

        var marker = new GMarker( point, markerOptions );
        this.map.addOverlay( marker );

        if ( opened ) {
            marker.openInfoWindowHtml( text );
        } else {
            GEvent.addListener(marker, "click", function() {
                marker.openInfoWindowHtml(text);
            });    
        }

    },

    createCustomIcon: function(url, width, height, aLeft, aTop) {

        if ( aLeft == null ) {
            aLeft = 0;
        }

        if ( aTop == null ) {
            aTop = height;
        }

        var tempIcon = new GIcon(G_DEFAULT_ICON);
        tempIcon.image = url;
        tempIcon.iconSize = new GSize(width, height);
        tempIcon.shadow = '';
        tempIcon.iconAnchor = new GPoint(aLeft, aTop);
        return tempIcon;
    },

    LargeControl: function() {
        this.map.addControl(new GLargeMapControl());
    },

    SmallControl: function() {
        this.map.addControl(new GSmallMapControl());
    },

    SmallControl: function() {
        this.map.addControl(new GSmallZoomControl());
    },

    MapControl: function() {
        this.map.addControl(new GOverviewMapControl());
    },


    getAddressPoint: function( address, callback ) {
        var args = arguments;
        this.geoCoder.getLatLng( address, function(point) { if (!point) {alert(address + " not found");} else { callback( point, args );} } );
    },

    _addMarker: function( point, args ) {
        args[4].createInfoWindow( point, args[2], args[3] );
    },

    addAddressMarker: function( address, text, opened ) {
        this.getAddressPoint( address, this._addMarker, text, opened, this );
    },

    addPointMarker: function( point, text, opened, icon ) {
        this.createInfoWindow( point, text, opened, icon );
    },

    setCenter: function( point, zoom ) {
        this.map.setCenter(point, zoom);
    },

    setCenterAddress: function( address, zoom ) {
        this.getAddressPoint( address, function( point, args ) { args[3].setCenter(point, args[2]); }, zoom, this );
    },

    consolePoint: function( address ) {
        this.getAddressPoint( address, function( point ) { console.log(point.toString()); } );
    },

    getPoint: function( cX, cY ) {
        return new GLatLng( cX, cY );
    },

    getDirections: function() {
        var obj = this;
        GEvent.addListener(this.directions,"load", function() {
            
            for (i=0; i<obj.directions.getRoute(0).getNumSteps(); i++ )
            {
                document.getElementById( 'route2' ).innerHTML = document.getElementById( 'route2' ).innerHTML + obj.directions.getRoute(0).getStep(i).getDescriptionHtml()+ ' - ' + obj.directions.getRoute(0).getStep(i).getDistance().html +'<br>';
            }
        });

        this.directions.loadFromWaypoints(['vasut utca 17, 9653 Repcelak, Hungary','Semmelweis Ignac u. 2, 9700 Szombathely, Hungary'],{getPolyline:true,getSteps:true});
    }

}
