/* QUIERO WIFI MAIN JAVASCRIPT FILE */
var myLatlng;
var geocoder;
var map;
var add_wifi_market = null;




/* ------------------------------- MARKERS  ---------------------------------------*/
google.maps.Map.prototype.markers = new Array();

google.maps.Map.prototype.getMarkers = function() {
    return this.markers
};

google.maps.Map.prototype.clearMarkers = function() {
    for(var i=0; i<this.markers.length; i++){
    	//console.log(this.markers[i]);
        this.markers[i].setMap(null);
    }
    this.markers = new Array();
};

google.maps.Marker.prototype._setMap = google.maps.Marker.prototype.setMap;

google.maps.Marker.prototype.setMap = function(map) {
    if (map) {
        map.markers[map.markers.length] = this;
    }
    this._setMap(map);
}
/* ------------------------------------------------------------------------------- */



/* ----------------------------------------  BUSCADOR FORM  -------------------------------- */
function iniciar_busqueda(form) {
	var address = document.getElementById('id_seleccionar_lugar').value;
    if (geocoder) {
      geocoder.geocode( { 'address': address}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
          map.setCenter(results[0].geometry.location);
		  if(add_wifi_market){
			  //verificamos si estamos poniendo una nueva red wifi
			  //si es asi actualizamos la posicion de ese market
			  add_wifi_market.setPosition(results[0].geometry.location);
		  }
		  map.setZoom(13);
        } else {
          alert("Geocode was not successful for the following reason: " + status);
        }
      });
    }
    return false;
  }

function iniciar_con_busqueda(q) {
	var address = q;
	
    if (geocoder) {
      geocoder.geocode( { 'address': address}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
          map.setCenter(results[0].geometry.location);
		  if(add_wifi_market){
			  //verificamos si estamos poniendo una nueva red wifi
			  //si es asi actualizamos la posicion de ese market
			  add_wifi_market.setPosition(results[0].geometry.location);
		  }
		  map.setZoom(13);
        } else {
          if (status ==="ZERO_RESULTS"){
        	  alert('No existe el lugar que usted esta buscando, intente nuevamente.')
        	  $('id_seleccionar_lugar').focus();
              cambiar_estilo_search(true);
          }
          	
        }
      });
    }
    return false;
  }

/* ----------------------------------------------------------------------------------- */



