var latlng;
$(document).ready(function() { 
	var address="6151 Old Stilesbroro Rd, Acworth, GA 30101";
	var streetview;
	var mapOptions;
	var geocoder = new google.maps.Geocoder();
	geocoder.geocode({'address' : address},function(results,status){
		if(status == google.maps.GeocoderStatus.OK){
var service = new google.maps.StreetViewService();
latlng = results[0].geometry.location;
service.getPanoramaByLocation(results[0].geometry.location, 500,checkNearestStreetView);
			mapOptions = {
			position:latlng,
			pov: {
				heading:20,
				pitch:0,
				zoom:1
			}
			};

			var streetviewmap = new google.maps.StreetViewPanorama(document.getElementById("streetview"), mapOptions);

			streetviewmap.setVisible(true);
			var myOptions = {
			   zoom: 12,
  			   center: results[0].geometry.location,
  			   mapTypeId: google.maps.MapTypeId.ROADMAP
 			   };
 			var map = new google.maps.Map(document.getElementById("map"),myOptions);
marker = new google.maps.Marker({
    map:map,
    draggable:true,
    animation: google.maps.Animation.DROP,
    position: results[0].geometry.location
  });
  google.maps.event.addListener(marker, 'click', toggleBounce);
		}

var contentString = '<div id="mapcontent">'+
    '<div class="markerinfo">'+
    '<a href=http://maps.google.com/?q=' + address.replace(/ /g,'+') + '" target="_blank">' + address + '</a>'+
    '</div></div>';

var infowindow = new google.maps.InfoWindow({
    content: contentString
});
google.maps.event.addListener(marker, 'click', function() {
  infowindow.open(map,marker);
});


	});
		$('#banner').after('<ul id="nav">')
		.cycle({ 
			pager:  '#nav',
			fx: 'fade',
			speed: 1000,
			timeout: 7000,
			pagerAnchorBuilder: function(idx, slide)
			{
				return '<li><a href="#"><img src="images/nav.png" width="14" height="14" border="0" /></a></li>'; 
  		  	},
			updateActivePagerLink: function(pager, activeIndex)
			{
				$(pager).find('li:eq('+activeIndex+')').html('<a href="#"><img src="images/nav_active.png" width="14" height="14" border="0" /></a>').siblings().html('<a href="#"><img src="images/nav.png" width="14" height="14" border="0" /></a>');
			}
		});
	
	$.fn.preload = function()
	{
  	this.each(function()
		{
    	$('<img/>')[0].src = this;
    });
	}

	$(['/images/nav_active.png']).preload();

}); 
function toggleBounce() {

  if (marker.getAnimation() != null) {
    marker.setAnimation(null);
  } else {
    marker.setAnimation(google.maps.Animation.BOUNCE);
  }
}
function checkNearestStreetView(panoData){
if(panoData){
         if(panoData.location){
            if(panoData.location.latLng){
                /**Well done you can use a nearest existing street view coordinates**/
latlng = panoData.location.latLng;
            }
        }
    }
else{
}
}
