var provincia = '';
var MapLoaded = 0;
var myMap = null;
var zoomLevel = 5;

function LoadMap()
{
	//alert("entro");
	myMap = new VEMap("mapDiv");
	var latLon = new VELatLong(57.5, -92);
	myMap.LoadMap(latLon);
	
	//myMap.AttachEvent("onendzoom", showLocs);
	//myMap.AttachEvent("onendpan", showLocs);
	MapLoaded = 1;
	var city = document.ff3.recID.value;
	
	if(city != "Type in a City Name or Property ID#"){
		if(!isNumeric(city)){
	StartGeocoding(city);
		}
	 
	 } 
	
	showLocs();
}


//para encontrar locacion
function StartGeocoding( address )
{
   myMap.Find(null,    // what
              address, // where
              null,    // VEFindType (always VEFindType.Businesses)
              null,    // VEShapeLayer (base by default)
              null,    // start index for results (0 by default)
              null,    // max number of results (default is 10)
              null,    // show results? (default is true)
              null,    // create pushpin for what results? (ignored since what is null)
              null,    // use default disambiguation? (default is true)
              null,    // set best map view? (default is true)
              GeocodeCallback);  // call back function
}
function GeocodeCallback (shapeLayer, findResults, places, moreResults, errorMsg)
{
   // if there are no results, display any error message and return
   if(places == null)
   {
      alert( (errorMsg == null) ? "There were no results" : errorMsg );
      return;
   }

   var bestPlace = places[0];
   
   // Add pushpin to the *best* place
   var location = bestPlace.LatLong;
   
   var newShape = new VEShape(VEShapeType.Pushpin, location);
   
   var desc = "Latitude: " + location.Latitude + "<br>Longitude:" + location.Longitude;
   newShape.SetDescription(desc);
   newShape.SetTitle(bestPlace.Name);
   myMap.AddShape(newShape);
}
//*****************************

function UnloadMap()
{
	if (myMap != null) {
	   myMap.Dispose();
	}
}

//***********
function change_map(s_prov){
	document.getElementById('img_map').src=urlact +'img/home1/map_'+s_prov+'.jpg';
	}
function refill_field(o_obj, n_nn){
	
	if(Trim(o_obj.value)=='' && n_nn=='0'){o_obj.value='Type in a City Name or Property ID#';document.ff3.city_name.value=""; document.ff3.province.value=""; }
	if(o_obj.value=='Type in a City Name or Property ID#' && n_nn=='0'){ document.getElementById('recID').className='txt1_9';}
	else{document.getElementById('recID').className='txt1_9_1';}
	//alert();
	}


