
//var directionDisplay;
//var directionsService = new google.maps.DirectionsService();

var map, markerykml;
var geocoder = null;
   
function initialize() {    
    geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(52.025459,19.204102);
    
    var myOptions = {
        zoom: 10,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        animation: google.maps.Animation.DROP        
    };
    
    map = new google.maps.Map(document.getElementById("map_dealer"),myOptions);              
        
    markerykml = new google.maps.KmlLayer('http://www.taurus.info.pl/_var/js/map_dealer.kml');
    markerykml.setMap(map);   
    
    var marker = new google.maps.Marker({
        icon: 'http://taurus.info.pl/_skiny_users/shoper_blue-1/gfx/google_maps_dot.png'
    });    
    
    marker.setMap(map);
}
  
  
function select_town(nazwa) {        
    geocoder.geocode({'address': nazwa}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        map.setZoom(11);
        }
    });					
}

jQuery(window).load(function() {
    initialize();   
    
    jQuery("#google_miasta").change(function() {
        if (jQuery("#google_miasta option:selected").val() == 0) {            
            initialize()
        }
        else {
            select_town(jQuery("#google_miasta option:selected").val());           
        }
    });
});  
