ServiMapPersonal=new OpenLayers.Class(OpenLayers.ServiMap,{
    layerWms:null,
    layerWms1:null,
    layerRest:null,
    wmsInfoControl:null,
    editControl:null,
    idPuntoGeoManual:null,
    dirPuntoGeoManual:null,
    activarGeoManual:false,
    geovisorGeoManual:false,
    grillaActivaGeoManual:null,
    layerWmsInfo:new Array(),
    initialize:function(options){
        OpenLayers.ServiMap.prototype.initialize.apply(this,arguments);

//WMS1
//        var ConsultaLuminaria = "select gid,fct1,fci,luminaria,poste,potencia,tiposistem,clase,pintado,the_geom, 1 as tematico  from luminaria";
//        var myUrl2 = "http://192.168.1.62/cgi-bin/mapserv.exe?map=C://mapas/infibague/mapa_00.map";
//        this.capaWms1 = new OpenLayers.Layer.WMS( "capaWms1",
//                        myUrl2,{
//                        layers: 'luminarias,transformadores',
//                        format: 'image/png',
//                        transparent: 'true',
//                        CONSULTALUMINARIA:	ConsultaLuminaria
//                    },{
//                        'isBaseLayer': false,
//                        'opacity': 1,
//                        'reproject':true,
//                        'gutter': 0,
//                        'singleTile': true,
//                        'maxResolution': 156543
//                    }
//        );
//        this.addLayer(this.capaWms1);
//
//        this.layerWmsInfo["capaWms1"] = new OpenLayers.Control.WMSGetFeatureInfo({
//            url: myUrl2,
//            layers: [this.capaWms1] ,
//            info_format: 'text/html',
//            queryVisible: true,
//            vendorParams : {CONSULTALUMINARIA : ConsultaLuminaria,RADIUS : 18}
//
//        });
//        this.layerWmsInfo["capaWms1"].events.register("getfeatureinfo", this, this.showInfo);
//        this.addControl(this.layerWmsInfo["capaWms1"]);
//        this.layerWmsInfo["capaWms1"].activate();


//inicio codigo para ArcGIS93Rest
//        this.capaBase = new OpenLayers.Layer.ArcGIS93Rest( "ArcGIS Server Layer",
//            "http://tecnologia/ArcGIS/rest/services/prueba1/MapServer/export?",{
//                LAYERS: 'show:0',
//                IMAGESR: '',
//                BBOXSR: '102113',
//                FORMAT: 'png',
//                TRANSPARENT: true
//            },{
//                isBaseLayer: true,
//                singleTile: true
//            }
//        );
        //this.addLayer(this.layerRest);
        //fin codigo para ArcGIS93Rest
        //
         //inicio codigo para wmsMapXtreme como base layer
//        var myUrl =  "http://EDERSON:8080/wmsserver111/servlet/wms";
//        this.capaBase = new OpenLayers.Layer.WMSMapXtreme( "capaBase",
//            myUrl,{
//                layers: 'layers/world/coordeillerasHomc2_region,layers/world/Grid',//'ACCIDENTES,Remocion,Inundacion',
//                format: 'image/png',
//                transparent: 'true'
//            },{
//                'isBaseLayer': true,
//                'opacity': 0.5,
//                'reproject':true,
//                'gutter': 0,
//                'singleTile': true,
//                'maxResolution': 156543
//            }
//
//        );
        //fin codigo para wms como base layer

        //inicio codigo para wmsMapXtreme como base layer
//        var myUrl =  "http://64.65.32.82/cgi-bin/mapserv?map=/var/www/html/webgis/mapa/prueba.map&RADIUS=10";
//        this.capaWms = new OpenLayers.Layer.WMS( "capaWms",
//            myUrl,{
//                layers: 'paises,Departamentos,cordillera1,cordillera2,cordillera3,parques_colombia,CentrosPoblados,OCEANO,Localidades,Barrios_Bogota,Manzanas_Bogota,parques,hidrografia_Bogota,Vias_Principales,Malla_vial,Ruta_Transmilenio,Est_transmilenio,rios,vias,Aeropuertos,PuntosCapitales,Comunas_Medellin,Barrios_Medellin,Manzanas_Medellin,Parques_Medellin,hidrografia_Medellin,Mallavial_Medellin,Ruta_Metro,Est_Metro,Comunas_Cali,Barrios_Cali,Manzanas_Cali,Mallavial_Cali',//'ACCIDENTES,Remocion,Inundacion',
//                format: 'image/png',
//                transparent: 'true'
//
//            },{
//                'isBaseLayer': true,
//                'opacity': 0.5,
//                'reproject':true,
//                'gutter': 0,
//                'singleTile': true,
//                'maxResolution': 156543
//            }
//        );
        //fin codigo para wms como base layer

        //OpenLayers.ServiMap.prototype.initialize.apply(this,arguments);
        //this.addLayer(this.layerWms1);
        //revisar existencia de la proyeccion EPSG:900913 en C:\ms4w\proj\nad\epsg
        //revisr el .map:
//        MAP
//           WEB
//              METADATA
//			     "wms_title"	"Servidor WMS demo"
//			     "wms_onlineresource"	"http://localhost/cgi-bin/mapserv.exe"
//			     "wms_srs"	"EPSG:900913"
//              END
//           END
//           PROJECTION
//              "init=EPSG:4326"
//	         END
//        END
//        falta revisar los layer sld
//        La especificacion de WMS puede devolver:
//        1. GetCapabilities: return an XML document with metadata of the Web Map Server?s information
//        2. GetMap: return an image of a map according to the user?s needs.

//        Lo siguiente es una lista de parametros de GetMap:
//        VERSION=version: Request version
//        REQUEST=GetMap: Request name
//        LAYERS=layer_list: Comma-separated list of one or more map layers. Optional if SLD parameter is present.
//        STYLES=style_list: Comma-separated list of one rendering style per requested layer. Optional if SLD parameter is present. NOTE that MapServer does not support named styles, so most times you would specify ?STYLES=? with an empty value. MapServer does support STYLES when used with an SLD.
//        SRS=namespace:identifier: Spatial Reference System.
//        BBOX=minx,miny,maxx,maxy: Bounding box corners (lower left, upper right) in SRS units.
//        WIDTH=output_width: Width in pixels of map picture.
//        HEIGHT=output_height: Height in pixels of map picture.
//        FORMAT=output_format: Output format of map.
//        SLD=http://localhost/mysld.xml
//        to use SLD you won't need very special mapfile configuration. You
//        should pay attention to setting the imgpath parameter of the web
//        section correctly, i.e. accessible and writable by mapserver-cgi,
//        since the sld's are stored there temporarily while/after downloading
//        them from the specified URL. I am not aware of any other special
//        configuration, but very helpful are the debugging outputs, that you
//        can enable with the keyword DEBUG "on" at map or layer level. I find
//        it most convenient to specify an errorfile path via CONFIG
//        "MS_ERRORFILE" "/ms4w/tmp/ms_error.txt" at map level.



    },

    showInfo: function (evt) {
        // evt.text,
        // evt.features,
        // evt.request,
        // evt.xy

        if (evt.text && evt.text != "") {
          var lonlat = this.getLonLatFromViewPortPx(evt.xy);
          var popup = new OpenLayers.Popup.FramedCloud("chicken",
                                       lonlat,
                                       null,
                                       "<table width='100%' border='0' class='popup'>"+evt.text+"</table>",
                                       null,
                                       true);
          popup.minSize = new OpenLayers.Size(100,200);
          popup.maxSize = new OpenLayers.Size(300,500);
          popup.autoSize = true;
          popup.opacity = 1;
          this.addPopup(popup,true);
           // this.limpiarCapas();
        //    var punto =this.getLonLatFromPixel(evt.xy);
        //    var lonlat = OpenLayers.Layer.SphericalMercator.inverseMercator(punto.lon,punto.lat);
        //    this.adicionarPunto(lonlat.lon,lonlat.lat, evt.text,'1',0,0,false,true,false);
        }
    },
    onMoveZoom: function (){


    },

    onRightClick:  function (event) {
        if (this.activarGeoManual){
            this.limpiarCapas();
            var lonlat = this.getLonLatFromViewPortPx(event.xy);
            lonlat = OpenLayers.Layer.SphericalMercator.inverseMercator(lonlat.lon,lonlat.lat);
            var popupContentHTML = "<table width='100%' border='0' class='popup'><caption> "+this.dirPuntoGeoManual+" </caption>"+
            "<tr><th>Orden</th><td>" + this.idPuntoGeoManual + "</td></tr>"+
            "<tr><th>Direccion</th><td>" + this.dirPuntoGeoManual + "</td></tr>"+
            "<tr><th>Longitud</th><td>" + lonlat.lon + "</td></tr>"+
            "<tr><th>Latitud</th><td>" + lonlat.lat + "</td></tr>"+
            '<td colspan="2"  align="center"><img align="absmiddle" alt="Guardar Coordenadas" title="Guardar Coordenadas" src="img_ol/guardar.png" onclick="ejecutarActualizacionGeoManual('+lonlat.lon+','+lonlat.lat+','+this.idPuntoGeoManual+');" width="24" height="24" /></td>'+
            "</table>";
            this.adicionarPunto(lonlat.lon,lonlat.lat, popupContentHTML,'',0,0,0,false,false,false);

        }
//
//       var lonBase = -74.23;
//       var latBase = 4.5;
//
//       var lonlat = this.getLonLatFromViewPortPx(event.xy);
//       lonlat = OpenLayers.Layer.SphericalMercator.inverseMercator(lonlat.lon,lonlat.lat);
//       var lon = Math.round((lonlat.lon-lonBase)*10000);
//       var lat = Math.round((lonlat.lat-latBase)*10000);
//
//
//       var strLon =lon.toString(36);
//       var strLat =lat.toString(36);
//       var intStrLon =parseInt(strLon,36);
//       var intStrLat =parseInt(strLat,36);
//       alert(Math.round(lonBase*10000).toString(36)+" "+ Math.round(latBase*10000).toString(36));
//
//       for (var dd=0; dd < 36 ; dd++){
//        alert(dd+ " "+ dd.toString(36))    ;
//
//       }
//
//
//
//       alert(lonlat);
//       alert(strLon+" "+strLat);
//       alert(intStrLon+" "+intStrLat);
//
//       this.adicionarPunto(lonlat.lon,lonlat.lat, 'popupContentHTML','1',0,0,null,false,false,false);
//

//       popup = new OpenLayers.Popup("chicken",
//           lonlat,
//           new OpenLayers.Size(100,100),
//           "popup onRightClick",
//           true);
//       this.addPopup(popup,true);
    },
    onClick:  function (event) {

    },

    onFeatureClick:  function (feature,posicion) {
       OpenLayers.ServiMap.prototype.onFeatureClick.apply(this,arguments);
       //para cancelar los otros eventos como el getFeatureInfo
       //feature.layer.map.addPopup(popup,true);
       if (this.wmsInfoControl){
            this.wmsInfoControl.deactivate();
            this.wmsInfoControl.activate();
       }
    },

    finalizarAdicionFeature: function(feature){
        //var cadena = this.wkt.write(feature);
        //alert(cadena);
    },



        CLASS_NAME: "ServiMapPersonal"
    });

OpenLayers.Util.createTable = function(id, px, sz, imgURL, position,
                                     border, overflow, opacity) {

    var dom = document.createElement('div');

    if (imgURL) {
        dom.style.backgroundImage = 'url(' + imgURL + ')';
    }

    //set generic properties
    if (!id) {
        id = OpenLayers.Util.createUniqueID("OpenLayersDiv");
    }
    if (!position) {
        position = "absolute";
    }
    OpenLayers.Util.modifyDOMElement(dom, id, px, sz, position,
                                     border, overflow, opacity);

    return dom;
};

