jQuery(document).ready(function($) {
	// ROLLOVERS
	$('.rollover').rollover();
 
	// SETUP ARCHIVES IN FOOTER
	$('.archive_month').hide();
	$('.archive_year > a').toggle(function() {
		$(this).parent().addClass('expanded_list');
		var startingPoint = $(this).parent();
		while (startingPoint.next().attr('class') == 'archive_month') {
			startingPoint.next().fadeIn();
			startingPoint = startingPoint.next();
		}
	}, function() {
		$(this).parent().removeClass('expanded_list');
		var startingPoint = $(this).parent();
		while (startingPoint.next().attr('class') == 'archive_month') {
			startingPoint.next().fadeOut();
			startingPoint = startingPoint.next();
		}
	});

	$('.archive_year:first-child > a').trigger('click');

	
	// TWITTER FEED
	var url = "http://twitter.com/status/user_timeline/coolpeoplecare.json?count=1&callback=?";
	var myTwitter = '';

	$.getJSON(url,

		//This function is called when twitter responds with the appropriate information.
		function(data){
			//Step through each tweet.
			$.each(data, function(i, item) {
				//place the tweet within a paragraph tag within the main div.
				myTwitter = item.text;
			});

			$('#twitter_feed > a').text(myTwitter);
		}
	);
	
	// FACEBOOK WALL
	$('#facebook_wall').fbWall({
		id:                       'coolpeoplecare',
		accessToken:'206158599425293|7809823973348bcf8cd72f6d.1-100000221135225|BW9n2eoyL7EYvJs7GEmv61NbBFk',
		max:                      1,
		showComments:             true,
		showGuestEntries:         true,
		timeConversion:           24
	});
	
	// SUBNAVIGATION	
	$('ul.sub-menu').parent().hover(function() {
		$(this).find('ul.sub-menu').fadeIn();
	}, function() {
		$(this).find('ul.sub-menu').stop(true, true).fadeOut();
	});
	
	// HANDLE EMBEDS
	$('embed').each(function() {
		$(this).attr('wmode', 'transparent');
	})
	$('object').each(function() {
		$(this).attr('wmode', 'transparent');
	})
});
