$(document).ready(function(){
        $("#provincia").change(function(event){
            var id = $("#provincia").find(':selected').val();
            $("#poblacion").load('default/generaSelect?id='+id);
        });
});

$(document).ready(function(){
	if($('#provincia option:selected').val() != "")	{
        var id = $("#provincia").find(':selected').val();
        $("#poblacion").load('default/generaSelect?id='+id);
	} 
});

/*function cambiar(id, enlace) {
	if ($('#' + enlace + ' img').attr('src') == '/images/arrow.png')
		$('#' + enlace + ' img').attr('src', '/images/arrow2.png');
	else
		$('#' + enlace + ' img').attr('src', '/images/arrow.png');
	$('#' + id).slideToggle(300);
}*/

function mostrar(id) {
	$('#' + id).toggle("1000");
}

/*$(document).ready(function(){
    $("#poblacion").change(function(event){
    	if($("#poblacion").attr('value') != '')
    		$("#cp").attr('disabled', false);
    	else
    		$("#cp").attr('disabled', 'disabled');
    });
});*/

var geocoder;
var map;
function initialize(id, zoom) {
  geocoder = new google.maps.Geocoder();
  var latlng = new google.maps.LatLng(0, 0);
  var myOptions = {
    zoom: zoom,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  if (document.getElementById("mapa_cercanos"))
  {
	  map = new google.maps.Map(document.getElementById("mapa_cercanos"), myOptions);
	  codeAddress2();
  }
  else
  {
	  map = new google.maps.Map(document.getElementById("map_canvas" + id), myOptions);
      codeAddress();
  }
  
}

function codeAddress() {
  var address = document.getElementById("address").value;
  if (geocoder) {
    geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var marker = new google.maps.Marker({
            map: map, 
            position: results[0].geometry.location
        });
      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });
  }
}

function codeAddress2() {
	  var address = "Valencia, Valencia, Calle Jacinto labaila 33";
	  if (geocoder) {
	    geocoder.geocode( { 'address': address}, function(results, status) {
	      if (status == google.maps.GeocoderStatus.OK) {
	        map.setCenter(results[0].geometry.location);
	        var marker = new google.maps.Marker({
	            map: map, 
	            position: results[0].geometry.location
	        });
	      } else {
	        alert("Geocode was not successful for the following reason: " + status);
	      }
	    });
	  }
	}
