/**
 * @author rollsd
 */
 
GY.FORUM = {

	init: function()
	{
		$(document).ready( function() {
		
			$('.forum-homepage-content .fm-forum-topic').slideUp();
			
			$('.fm-header-wrapper').css('cursor','pointer');
			
			$('.forum-homepage-content .fm-header-wrapper').click(function() {
				$(this).next().slideToggle();
			});
			
			$('.fm-info a[href="http://www.gapyear.com/boards/member/75761/"], .fm-heading a[href="http://www.gapyear.com/boards/member/75761/"]').each(function() {
				$(this).replaceWith('<span class="deleted-user-name">[' + $(this).text() + ']</span>');
			});
			$('.rankMember a[href="http://www.gapyear.com/boards/member/75761/"]').each(function() {
				_this = $(this);
				_this.parent().parent().replaceWith('<div class="inset"><span class="deleted-user-name">[deleted user]</span></div>');
				//_this.replaceWith('<span class="deleted-user-name">[' + _this.text() + ']</span>');
			});
			

			$('.forum-block-heading').click(function() {
				if ($('#forum-block-recent').hasClass('expanded')) {
					$('.forum-block').animate({height:'214px'},400);
					$('.forum-block').removeClass('expanded');
					$('.forum-block-heading span').text('show me more +');
				}
				else {
					$('.forum-block').animate({height:'934px'},500);
					$('.forum-block').addClass('expanded');
					$('.forum-block-heading span').text('less -');
				}
			});
			
			
			$('#forum-latest-container .forum-block-row a').each(function() {
				if ($(this).text().length > 65) {
					var shortText = $(this).text()
					.trim()
					.substring(0, 65)
					.split(" ")
					.slice(0, -1)
					.join(" ") + "...";
					$(this).text(shortText);
				}
			});

		});
	}
	
};


GY.FORUM.init();
