// Search hover
$('.search').mouseenter(function () {
	if ($(this).val() == 'Search') $(this).val('');
	$(this).focus();
})
$('.search').mouseleave(function () {
	if ($(this).val() == '') {
		$(this).val('Search');
		$(this).blur();
	}
}) 

// Div hovers
$('.concert-index').click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});

$('.belin_add_dates').click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
});


// Carousel
function paddCarouselInit(carousel) {
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});
 
	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});
 
	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(
		function() {
			carousel.stopAuto();
		},
		function() {
			carousel.startAuto();
		}
	);
}
 
	jQuery('ul#carousel').jcarousel({
		auto: 6,
		wrap: 'last',
		initCallback: paddCarouselInit
	});

// jTweetsAnywhere
$('#tweets').jTweetsAnywhere({
    username: 'civicmusic',
    count: 10,
    showTweetFeed: {
    	showProfileImages: true,
        showUserScreenNames: false,
        showTimestamp: {
            refreshInterval: 15
        },
        autorefresh: {
            mode: 'trigger-insert',
            interval: 30
        },
        paging: { mode: 'endless-scroll' }
    },
    onDataRequestHandler: function(stats, options) {
        if (stats.dataRequestCount < 11) {
            return true;
        }
        else {
            stopAutorefresh(options);
        }
    }
});

// Google Maps API v3
var geocoder;
var map;
var default_lat = 41.6004093;
var default_lng = -93.65102430000002;
			
function initialize() {

	geocoder = new google.maps.Geocoder();
	
	var latlng = new google.maps.LatLng(default_lat,default_lng);
	var options = {
		zoom: 14,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	map = new google.maps.Map(document.getElementById("map_canvas"), options);				

	var address = document.getElementById("concert_address").value;
	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("We were not able to geocode this location: " + status);
		}
	});
}
