
    var USE_GOOGLE_BASE_LAYER = false;
    var ICC_URL_BASE_LAYER    = "http://norma.icc.cat/tilecache/tilecache.py/1.0.0/topo3857/{Z}/{X}/{Y}.png?type=google";
    var MARKER_HOVER_URL      = "/templates/default/img/markers/marker-hover.png";
    
    // GMap2 extensions
    //////////////////////////////////////////////////////

    GMap2.prototype.init = function(point, zoom)
    {
        if (USE_GOOGLE_BASE_LAYER)
        {            
            this.addControl(new GOverviewMapControl());
        }
        else
        {
            var collection = new GCopyrightCollection("ICC");
            var copyright  = new GCopyright(1, this.getBounds(), 7, "Š Institut Cartogrāfic de Catalunya");
            var topo       = new GTileLayer(collection,8, 18, {tileUrlTemplate: ICC_URL_BASE_LAYER, isPng: true, opacity: 1});
            var icc        = new GMapType([topo], G_NORMAL_MAP.getProjection(), "TopoICC", {errorMessage: "No ICC data available"});             
            
            collection.addCopyright(copyright);
            
            this.addMapType(icc);
            this.setMapType(icc);
            
            this.removeMapType(G_NORMAL_MAP);
        }
        
        this.removeMapType(G_HYBRID_MAP);
        this.removeMapType(G_SATELLITE_MAP);
        this.removeMapType(G_PHYSICAL_MAP);
        
        this.addControl(new GLargeMapControl());
        this.setCenter(point, zoom);
    }
    
    // GMyMarker
    //////////////////////////////////////////////////////

    function GMyMarker(point, num, marker, clas, url)
    {
        LabeledMarker.call(this, point, {labelText: num, labelOffset: new GSize(-9, -34)});

        this.showClose = "show";

        this.point   = point;
        this.num     = num;
        this.marker  = marker;
        this.clas    = clas;
        this.url     = url;
        this.html    = "This property must be setted by child classes";

        icon         = this.getIcon();
        icon.image   = marker;
    }

    GMyMarker.prototype = new LabeledMarker(new GLatLng(0, 0), {labelText: ""});

    GMyMarker.prototype.showHideInfoWindowHtml = function()
    {
        if (this.showClose == "show")
        {
            this.showClose = "close";
            this.openInfoWindowHtml(this.html);
        }
        else
        {
            this.showClose = "show";
            map.closeInfoWindow();
        }
    }

    GMyMarker.prototype.handleWindowOpen = function()
    {
        GEvent.clearListeners(this, "mouseover");
        GEvent.clearListeners(this, "mouseout");
        this.highlight();
    }

    GMyMarker.prototype.handleWindowClose = function()
    {
        GEvent.addListener(this, "mouseover", this.highlight);
        GEvent.addListener(this, "mouseout", this.unHighlight);
        this.unHighlight();
    }

    GMyMarker.prototype.highlight = function()
    {
        this.setImage(MARKER_HOVER_URL);
        e = document.getElementById("anchor" + this.num) || false;

        if (e)
        {
            e.className = "hover";
        }
    }

    GMyMarker.prototype.unHighlight = function()
    {
        this.setImage(this.marker);
        e = document.getElementById("anchor" + this.num) || false;

        if (e)
        {
            e.className = "";
        }
    }

    // GRegadiuMarker
    //////////////////////////////////////////////////////

    function GRegadiuMarker(point, num, marker, clas, url, thumb, nom, desc, zonesStr, conreusStr)
    {
        GMyMarker.call(this, point, num, marker, clas, url);

        this.thumb      = thumb;
        this.nom        = nom;
        this.desc       = desc;
        this.zonesStr   = zonesStr;
        this.conreusStr = conreusStr;

        this.html = "\
            <div class='markerInfo markerInfoRg'>\
                \
                <div class='foto'>\
                    <a href='" + this.url + "'><img width='75' height='75' class='border' src='" + this.thumb + "' /></a>\
                </div>\
                \
                <div class='dades'>\
                    <div class='nom'>\
                        <span class='circle " + this.clas + "'>" + this.num + "</span> <b>" + this.nom + "</b>\
                    </div>\
                    \
                    <div class='dadesSec'>\
                        " + this.zonesStr + " | <span>" + this.conreusStr + "</span>\
                    </div>\
                    \
                    <p>" + this.desc + "</p>\
                    \
                    <div class='more'>\
                        <a href='" + this.url + "'>veure fitxa</a>&nbsp;<img src='/templates/default/img/icon_more.png' />\
                    </div>\
                </div>\
                \
            </div>\
            ";

        GEvent.addListener(this, "click", this.showHideInfoWindowHtml);

        GEvent.addListener(this, "mouseover", this.highlight);
        GEvent.addListener(this, "mouseout", this.unHighlight);

        GEvent.addListener(this, "infowindowopen", this.handleWindowOpen);
        GEvent.addListener(this, "infowindowclose", this.handleWindowClose);
    }

    GRegadiuMarker.prototype = new GMyMarker(new GLatLng(0, 0), 1, "marker.png", "nova", "http://www.regadius.cat");

    // GCpMarker
    //////////////////////////////////////////////////////

    function GCpMarker(point, num, marker, clas, url, thumb, nom, desc)
    {
        GMyMarker.call(this, point, num, marker, clas, url);

        this.thumb = thumb;
        this.nom   = nom;
        this.desc  = desc;

        this.html  = "\
            <div class='markerInfo markerInfoCp'>\
                \
                <div class='foto'>\
                    <a href='" + this.url + "'><img width='75' height='75' class='border' src='" + this.thumb + "' /></a>\
                </div>\
                \
                <div class='dades'>\
                    <div class='nom'>\
                        <span class='circle " + this.clas + "'>" + this.num + "</span> <b>" + this.nom + "</b>\
                    </div>\
                    \
                    <p>" + this.desc + "</p>\
                    \
                    <div class='more'>\
                        <a href='" + this.url + "'>veure fitxa</a>&nbsp;<img src='/templates/default/img/icon_more.png' />\
                    </div>\
                </div>\
                \
            </div>\
            ";

        GEvent.addListener(this, "click", this.showHideInfoWindowHtml);

        GEvent.addListener(this, "mouseover", this.highlight);
        GEvent.addListener(this, "mouseout", this.unHighlight);

        GEvent.addListener(this, "infowindowopen", this.handleWindowOpen);
        GEvent.addListener(this, "infowindowclose", this.handleWindowClose);
    }

    GCpMarker.prototype = new GMyMarker(new GLatLng(0, 0), 1, "marker.png", "en-promocio", "http://www.regadius.cat");
    
    // GZepaMarker
    //////////////////////////////////////////////////////

    function GZepaMarker(point, num, marker, clas, url, thumb, nom, desc)
    {
        GMyMarker.call(this, point, num, marker, clas, url);

        this.thumb = thumb;
        this.nom   = nom;
        this.desc  = desc;

        this.html  = "\
            <div class='markerInfo markerInfoZepa'>\
                \
                <div class='foto'>\
                    <a href='" + this.url + "'><img width='75' height='75' class='border' src='" + this.thumb + "' /></a>\
                </div>\
                \
                <div class='dades'>\
                    <div class='nom'>\
                        <span class='circle " + this.clas + "'>" + this.num + "</span> <b>" + this.nom + "</b>\
                    </div>\
                    \
                    <p>" + this.desc + "</p>\
                    \
                    <div class='more'>\
                        <a href='" + this.url + "'>veure fitxa</a>&nbsp;<img src='/templates/default/img/icon_more.png' />\
                    </div>\
                </div>\
                \
            </div>\
            ";

        GEvent.addListener(this, "click", this.showHideInfoWindowHtml);

        GEvent.addListener(this, "mouseover", this.highlight);
        GEvent.addListener(this, "mouseout", this.unHighlight);

        GEvent.addListener(this, "infowindowopen", this.handleWindowOpen);
        GEvent.addListener(this, "infowindowclose", this.handleWindowClose);
    }

    GZepaMarker.prototype = new GMyMarker(new GLatLng(0, 0), 1, "marker.png", "espais-prepirineu", "http://www.regadius.cat");
