/*****
** New class inheriting from OpenLayers.Control that 
**
**
**
******/

OpenLayers.Control.myClick = OpenLayers.Class(OpenLayers.Control, {                
    defaultHandlerOptions: {
        'single': true,
        'double': false,
        'pixelTolerance': 0,
        'stopSingle': false,
        'stopDouble': false
    },

    initialize: function(options) {
        this.handlerOptions = OpenLayers.Util.extend(
            {}, this.defaultHandlerOptions
        );
        OpenLayers.Control.prototype.initialize.apply(
            this, arguments
        ); 
        this.handler = new OpenLayers.Handler.Click(
            this, {
                'click': this.trigger
            }, this.handlerOptions
        );
    }, 
    trigger: function(e) {
        var lonlat = map.getLonLatFromViewPortPx(e.xy);
        /***
        * From this point the operation to do when a click
        * has been detected
        ***/
        //log("You clicked near " + lonlat.lat + " x, " + lonlat.lon + " y",1);
        //alert("doc: " +document);
        if (document.getElementById("HiddenLon") != null)
            document.getElementById("HiddenLon").value = Math.round(lonlat.lon);
        if (document.getElementById("HiddenLat") != null)
            document.getElementById("HiddenLat").value = Math.round(lonlat.lat);
        //log("HidenLon: "+document.pointPickForm.hiddenLon.value+" HidenLat: "+document.pointPickForm.hiddenLat.value,1);
        //alert("Submitting ");
        //document.form1.submit();
    }

});
