/*
* maps.js
* timmy willison
* choochooflyandtackle.com
* SDG
*/


(function ($) {
    
    google.maps.Ov = function(map) {
      google.maps.OverlayView.call(this);
      this.setMap(map); 
    }
    google.maps.Ov.prototype = new google.maps.OverlayView(); 
    google.maps.Ov.prototype.draw = function () { 
      if (!this.ready) { 
        this.ready = true; 
        google.maps.event.trigger(this, 'ready'); 
      } 
    };
    google.maps.Ov.prototype.lltp = function(latlng){
        return this.getProjection().fromLatLngToDivPixel(latlng);
    };
    
    $(document).ready(function(){
        
        $('#id_state').elect();
        
        var latlng = new google.maps.LatLng(35.063446,-85.309307);
        var map = new google.maps.Map(
            $('#google-map')[0], 
            { zoom: 16,
            scrollwheel: false,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
                mapTypeControl: false,
                navigationControlOptions: {
                    style: google.maps.NavigationControlStyle.SMALL
                }
        });
        
        attachInfo(map);
        
    });
    
    function attachInfo(map) {
        var myLatLng = new google.maps.LatLng(35.063024, -85.309314);
        var image = '/media/images/pin.png';
        var shadow = '/media/images/pin-shadow.png';
        var marker = new google.maps.Marker({
                position: myLatLng,
                map: map,
                title: 'Choo Choo Fly & Tackle',
                icon: image,
                shadow: shadow
        });
        var contentString = '<div class="map_marker_details">'+
                '<h3> Choo Choo Fly & Tackle </h3>'+
                '<p> 17 Cherokee Blvd.<br /> Chattanooga, TN 37405</p>'+
                '<p><b>P </b> (423) 267-0024 </p>'+
                '<p><a target="_blank" href="http://maps.google.com/maps?hl=en&q=17+Cherokee+Blvd+Chattanooga+TN" class="get_directions" name="Directions">Get Directions</a></p>' +
                '</div>'; 
        
        var info = new google.maps.InfoWindow();
        info.setContent(contentString);
        google.maps.event.addListener(marker, 'click', function(){
              info.open(map, marker);
        });
    }

})(jQuery)
