// clear map (marker, layer, popup)
function clearMap(mBool, lBool, pBool){
    if(mBool){ // marker
       if( this.layer_markers != undefined ){map.removeLayer(this.layer_markers );this.layer_markers = undefined;}
    }    
    if(lBool){ // layer
       if( this.lineLayer != undefined ){map.removeLayer( this.lineLayer );this.lineLayer = undefined;}
    }  
    if(pBool){ // popup
       if(this.feature !== undefined && this.feature !== null && this.feature != ''){ while(map.popups.length){map.removePopup(map.popups[0]);}}
    }
}

// check !defined map
function checkMap(lon, lat, zoom){
    if(map == undefined){
       $('#map').html('');
       map = new OpenLayers.Map('map', {
             div: "map",
             projection: new OpenLayers.Projection("EPSG:900913"),
             displayProjection: new OpenLayers.Projection("EPSG:4326"),
             controls: [new OpenLayers.Control.MouseDefaults()],
             units: 'm'
        });
        if(!panSmalSet){ map.addControl(new OpenLayers.Control.PanZoomBar()); }
            else{ map.addControl(new OpenLayers.Control.PanZoom()); }
        map.addControl(new OpenLayers.Control.Attribution());
        map.addControl(new OpenLayers.Control.Permalink('permalink1'));
        this.layer_markers = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
        map.addLayer(this.layer_markers);
        jumpTo(parseFloat(lon), parseFloat(lat),zoom);  
    }else
        if(this.layer_markers === undefined){     
           this.layer_markers = new OpenLayers.Layer.Markers("Marker", { 
                    projection: new OpenLayers.Projection("EPSG:4326"),
                    visibility: true, 
                    displayInLayerSwitcher: false });
           map.addLayer(this.layer_markers);       
        }
}

// zoom manipulation
function zoomManipulation(layer, zLevel){
    var boundsm = layer.getDataExtent();
    map.zoomToExtent(boundsm);
    if(map.zoom > zLevel){
       map.zoomTo(zLevel);
    }
}
