/* BON JOVI */
/* Home Page Section Javascript Functions
--------------------------------------------------------------------------- */


	$(window).load(function() {
	
		nextStop();
		lastNight();
	
	});


/* NEXT STOP COUNTDOWN
--------------------------------------------------------------------------- */


	function nextStop() {

		var month = $('#next div.widget-event a.date abbr').text();
		var day = parseInt( $('#next div.widget-event a.date span').text() );
		var year = parseInt( $('#next div.widget-event a.date em').text() );
		var venue = $('#next div.widget-event h4 a span').text() + ',' + $('#next div.widget-event h4 a strong').text();
		var venue = venue.replace(/\s/g, '+');
	
		if (month == "Jan") {
			month = 1;
		} else if (month == "Feb") {
			month = 2;
		} else if (month == "Mar") {
			month = 3;
		} else if (month == "Apr") {
			month = 4;
		} else if (month == "May") {
			month = 5;
		} else if (month == "Jun") {
			month = 6;
		} else if (month == "Jul") {
			month = 7;
		} else if (month == "Aug") {
			month = 8;
		} else if (month == "Sep") {
			month = 9;
		} else if (month == "Oct") {
			month = 10;
		} else if (month == "Nov") {
			month = 11;
		} else if (month == "Dec") {
			month = 12;
		}
			
		$('#next h4.countdown').countdown({
		
			until: new Date(year, month - 1, day),
			timezone: -8,
			format: "D",
			layout: "{dn} More {dl}!"
			
		});
	
		$('#next h4.countdown').countdown('pause');
		
		if ($('#next h4.countdown').text() == "0 More Days!") {
			$('#next h4.countdown').text('Tonight!');
		}
		
		$('#next > li:not(.logo)').attr('style','background-image: url(http://maps.google.com/maps/api/staticmap?center=' + venue + '&zoom=16&size=284x251&maptype=satellite&sensor=false)');
		$('#next ul.actions a').attr('href', $('#next div.widget-event a.date').attr('href') );
		$('#next').cycle({ fx: 'fade', speed: 1000, timeout: 9000, pause: true });
		
	}
	
	
/* NEXT STOP COUNTDOWN
--------------------------------------------------------------------------- */


	function lastNight() {

		if ($('#lastnight').length > 0) {
		
			var event = $('#lastnight .widget-event a.date').attr('href');
			var eventTag;

			$.each(event.replace(/\//g, '-').split('-'), function(index, value) { 

			  if (value.match('11__')) {

				  eventTag = value;

			  }

			});
				
			$('#lastnight .overlay a.setlist').attr('href', '/story/set_lists-last_night-vip_2011-2011_tour-north_america-' + eventTag + '/set_list__' + eventTag);
			$('#lastnight .overlay a.media').attr('href', '/album/' + eventTag);
			$('#lastnight .overlay a.upload_photos').attr('href', event.replace('show','upload-photo') );
			$('#lastnight .overlay a.upload_videos').attr('href', event.replace('show','upload-video') );
			$('#lastnight .overlay a.rsvp').attr('href', event + '#going');
			$('#lastnight .overlay a.talk').attr('href', event + '#comments');
			$('#lastnight div:not(.overlay,.widget-advertising)').mouseenter(function() { $(this).siblings('.overlay').animate({ width: '652px' }, 'fast'); });
			$('#lastnight div.overlay').mouseleave(function() { $(this).animate({ width: '0px' }, 'fast'); });
			$('#lastnight .widget-event a, #lastnight .widget-photo a').click(function() { return false; });
			
		}
		
	}
