/* UFC Community */
/* Rewording Functions
----------------------------------------------------------------------------- */


	$(document).ready(function() {


/* ALERTS
----------------------------------------------------------------------------- */

	// Friend requests
	$('div.widget-alert h3:contains("would like to be your friend")').parent().append('<ul class="actions"><li><a class="action approve" href="/friends">Approve Requests</a></li><li><a class="action friendsupto" href="/members#friends">See What Your Friends Are Up To</a></li></ul>');


	// Video uploaded
	$('div.widget-alert h3:contains("Your video upload is currently being readied for others to watch")').text("Thanks for your submission").parent().children('p').text("Your video will be added shortly.");


	// Analysis/prediction posted
	if (page == "blog" && tag.match("analysis") || tag.match("Analysis")) {

		$('div.widget-alert h3:contains("Your blog has been successfully updated.")').text("Your analysis has been successfully updated.");
		$('div.widget-blog.display > strong').hide();

	} else if (page == "blog" && tag.match("prediction") || tag.match("Prediction")) {
	
		$('div.widget-alert h3:contains("Your blog has been successfully updated.")').text("Your prediction has been successfully updated.");
		$('div.widget-blog.display > strong').hide();
	
	}


/* NETWORK / PROFILE WIDGETS
----------------------------------------------------------------------------- */


	// Headshot
	$("#profile-pictures div.badge h4").text("Your Profile Photo");

	
	// Headshot explanation copy
	$("#profile-pictures p").text("Your profile photo is anything you want to represent you: artwork, photos, and other cool images. Images must be in JPEG (.jpg) format.");


	// Header instructions
	$('div.widget-network div.banner p').text('This image will appear at the top of your profile. Images will be automatically cropped and resized to 843x93px.');


	// Love
	$('#profile div.about h4').text("Introduction & Other Details");
	$('#profile div.love h4').text("Personal");
	$('#about div.love h4').text("Personal");
	

	// Network site title
	$("#skin div.title h4").text("What's Your Profile Called?");


	// Network site header
	$("#skin div.banner h4").text("Upload a Banner");
	$("#skin div.banner label em").text("Banner");


/* PLACEHOLDERS
----------------------------------------------------------------------------- */


	// Predictions
	$('#predictions div.placeholder p, #video_predictions div.placeholder p').text('Got a prediction for the next fight?');


	// Analysis
	$('#analysis div.placeholder p, #video_analysis div.placeholder p').text('Got something on your mind from the last fight?');


	// Favorite videos
	$('#page-profile #favorite-video').each(function() {
		
		$(this).find('div.placeholder').children('p').text("You haven't chosen any favorite videos. Pick your favorites and they will appear here.");
		$(this).find('div.placeholder ul.actions li a.browse').attr('href', '/videos/all');
		$(this).find('div.placeholder ul.actions li a.upload').hide();
		
	});


	// Favorite photos
	$('#page-profile #favorite').each(function() {
		
		$(this).find('div.placeholder').children('p').text("You haven't chosen any favorite photos. Pick your favorites and they will appear here.");
		$(this).find('div.placeholder').append('<ul class="actions"><li><a class="action browse" href="/photos/all">Browse</a></li></ul>');
		
	});


	// Upcoming events RSVP
	$('#page-profile #events').each(function() {
		
		$(this).find('div.placeholder').children('p').text("You haven't RSVPed to any upcoming events. Use the button below to find the events you plan on attending.");
		$(this).find('div.placeholder').children('ul.actions').hide;
		
	});
	
	
	// Past events RSVP
	$('#page-profile #past-events').each(function() {
		
		$(this).find('div.placeholder').children('p').text("You haven't said that you've gone to any past events. Use the button below to find the events you've gone to.");
		$(this).find('div.placeholder').children('ul.actions').hide;
		
	});


/* RANDOM UPDATES
----------------------------------------------------------------------------- */


	// Shorten tooltip labels
	$("dl dt.comments").text("Comments");


	// Remove locations from sidebar event listings and truncate event names
	$('#sidebar div.widget-event ul.events h4').each(function() {
	
		$(this).children('em').children('span').remove();
		var name = $(this).children('em').text();
		
		if (name.length > 30) {

			var name = name.slice(0,30);
			$(this).empty().prepend('<em>' + name + '<var>&hellip;</var></em>');

		} else {

			$(this).empty().prepend('<em>' + name + '</em>');
		
		}


	});

	// Truncate video captions

	$('div.widget-media ul.clips div > em').prev().each(function() {

		var title = $(this).text();	

		if (title.length > 38) {

			var title = title.slice(0,38);
			$(this).empty().prepend(title + '<var>&hellip;</var>');

		}

	});

	// Upload Formats
	
	$('div.widget-media.video div.upload dd').text('AVI, MOV, MPG, MP4, M4A, M4V, WMV');

		
/* TRUNCATION
----------------------------------------------------------------------------- */


	$('#sidebar div.widget-event ul.events h4').each(function() {
	
		var text = $(this).children('a.headline').text().slice(0,23);
	
		$(this).children('a.headline').text(text);
		$(this).children('a.headline').append('<var>&hellip;</var>');
	
		var insertion = $(this).children('a.comments');

		$(this).children('strong').clone().insertAfter(insertion);
		$(this).find('strong:first-child').remove();
		
		$(this).show();
	
	});


/* END REWORDING FUNCTIONS
----------------------------------------------------------------------------- */


	});