var layerPoi;

function loadPoiLayers() {
    initPoiStyles();

    vectorLayers.push(new OpenLayers.Layer.Vector("Point of Interest", {
        layerType: 'poi',
        styleMap: styleMapPoi,
        displayInLayerSwitcher: false,
        rendererOptions: {
            zIndexing: true
        }
    }));
    map.addLayers(vectorLayers);
    clearModule2Load();
}

/* POI - Styling */
function initPoiStyles() {
    var context = {
        context: {
            getPointRadius: function(feature) {
                return 12;
                if (feature.attributes.poi_member)
                    return 8;
                return 6;
            },
            getPointRadiusHover: function(feature) {
                return 16;
                if (feature.attributes.poi_member)
                    return 10;
                return 8;
            },
            getName: function(feature) {
                return feature.attributes.name;
            },
            getExternaleGraphic: function(feature) {
                if (feature.attributes.use_symbol)
                    return '../file/poi_symbol/'+feature.attributes.cat_id+'.'+feature.attributes.mime;
                return '../images/ico_info.gif';
            },
            isVisible: function(feature) {
                // TODO PERFORMANCE: the function call map.getScale should be eliminated
                if (feature.attributes.scale && map.getScale() > feature.attributes.scale)
                    return 'none';
                return '';
            }
        }
    }

    var stylePoi = {
        graphicZIndex: 3,
        cursor: 'pointer',
        pointRadius: "${getPointRadius}",
        fillOpacity: 1,
        externalGraphic: "${getExternaleGraphic}",

        display: "${isVisible}"
    };
    var styleHighlite = {
        strokeColor: "#00FFFF",
        strokeWidth: 3,
        pointRadius: "${getPointRadiusHover}",
        pointerEvents: "visiblePainted",
        graphicZIndex: 6,
        //externalGraphic: "${getExternaleGraphic}",
        /*
        label: "${getName}",

        labelOffsetX: "10px",
        labelOffsetY: "10px",
        //fontColor: "red",
        fontSize: "12px",
        fontFamily: "Verdana",
        fontWeight: "bold",
        labelAlign: "lb",
*/
        display: "${isVisible}"
    };

    styleMapPoi = new OpenLayers.StyleMap({
        'default': new OpenLayers.Style(stylePoi, context),
        'select': new OpenLayers.Style(styleHighlite, context),
        'temporary': new OpenLayers.Style(styleHighlite, context)
    });
}
