function MobicsGeo(gmap,srvURLMobics,imgURL,srvUrl) {
  this.MAP_UPDATE_INTERVAL = 500; //milliseconds before performing map updates when map state is changed

  this.map = gmap;
  this.serverURLMob = srvURLMobics;
  this.serverURL = srvUrl;
  this.imageURL = imgURL;
  this.callback = null;
  this.markerList = [];
  this.mapUpdateTimer = null;
   

  this.id = MobicsGeo.instanceIdx++;
  MobicsGeo.instance[this.id] = this;
  this.mapSnapshotZoom = this.map.getZoom();
  this.mapSnapshotBounds = this.map.getBounds();

  this.geocodeAddress = function(cback,division,area,streetName,streetNumber,postcode,opt) {    
      var params = {'division':division, 'area':area, 'streetname':streetName, 'streetnumber':streetNumber, 'postcode':postcode};      
      RemoteAjax.call({
        'url': this.serverURLMob+'/geocodeAddress.jsp',
        'data': params,
        'success': function(data) {	  
          cback(data,opt);
        }
      });
  }
  
  this.submitForm = function (cback,name,photo,address,address_lat,address_lng,email,follow_up,comments,status,sign_type,city){    
    var params = {'function':'add_report','name':name, 'photo':photo, 'address':address, 'city':city,'lat':address_lat, 'lng':address_lng,'email':email,'follow_up':follow_up,'comments':comments,'status':status,'sign_type':sign_type};
  
      RemoteAjax.call({
        'url': this.serverURL +'/functs/reports2.jsp',
        'data': params,
        'success': function(data) {
          cback(data);
        }
      });
  }
  
  this.showIllegalSigns = function (cback,bounds){
    var params = {'function':'get_reports','sw_lat':bounds.southwest.lat, 'sw_lng':bounds.southwest.lng, 'ne_lat':bounds.northeast.lat, 'ne_lng':bounds.northeast.lng};    	
      RemoteAjax.call({
 //       'url': 'http://home.ploigos.gr:13245/illegalsigns/functs/reports2.jsp',
	'url': this.serverURL +'/functs/reports2.jsp',
        'data': params,
        'success': function(data) {	  		
          cback(data);
        }
      });
  }

  this.reverseGeocode = function(cback,pointY,pointX) {    
	    var params = {'pointX':pointX, 'pointY':pointY};
	    RemoteAjax.call({
	      'url': this.serverURLMob+'/reverseGeocode.jsp',
	      'data': params,
	      'success': function(data) {			    
	        cback(data);
	      }
	    });
	  } 

  this._markers = {
    'Default':{'iconurl':this.imageURL+'/markers/Scaled_Default.png'},
    'Trans':{'iconurl':this.imageURL+'/markers/Scaled_Green.png'},
    'User':{'iconurl':this.imageURL+'/markers/Scaled_Trans_big.png'}
  };

  this._markerIcons = {};

  this._getMarkerIcon = function(markertype) {
    var res = G_DEFAULT_ICON;
    var t = this._markers[markertype];
    if (t!==undefined) {
      res = this._markerIcons[markertype];
      if (res===undefined) {
        res = new GIcon();
        res.image = this._markers[markertype].iconurl;
        res.shadow = this.imageURL+'/markers/shadow50.png';
 //       res.iconSize = new GSize(26, 40);
 //       res.shadowSize = new GSize(37, 34);
        res.iconAnchor = new GPoint(9, 34);
        res.infoWindowAnchor = new GPoint(9, 2);
        res.infoShadowAnchor = new GPoint(18, 25);
        this._markerIcons[markertype] = res;
      }
    }
    return res;
  }

  this.addMarker = function(markertype, lat, lng, text) {
    var icon = this._getMarkerIcon(markertype);
    var m = new GMarker(new GLatLng(lat,lng),{'icon':icon,'draggable': true});
    this.map.addOverlay(m);
  //  this.markerList.push(m);
    address_mark = m;
    GEvent.addListener(address_mark, "dragend", function() {
		  address_lat = address_mark.getLatLng().lat();
		  address_lng = address_mark.getLatLng().lng();		  		  
		  revGeocode(pointInMunic,address_lat,address_lng);	  

	});		
    
   // m.bindInfoWindow(text);
    var id = this.markerList.length-1;
//     m.bindInfoWindow(this.markerHtml(text,id));
    return id;
  }

  this.markerHtml = function(data,id){ 
    var st='<b>'+data.foundAs+'</b>,<br>'+data.zip+', '+data.municipality+'<br><br>';       
    return st;   
  }

  this.removeMarker = function(id) {    
    if (id>=this.markerList.length) return false;    
    var m = this.markerList[id];
    if (m==null) return false;
    this.map.removeOverlay(m);
    this.markerList[id] = null;
    return true;
  }

}

MobicsGeo.instanceIdx = 0;
MobicsGeo.instance = {};

