var trun = new Object();

trun.init = function(){
	var i = 0;
	$('.trun').each(function(){
		var id = 'showHideContents_'+i
		
		$(this).attr('id', id);
		$(this).find('> *').hide();
		$(this).find('> *:eq(0)').show();
		$(this).find('> *:eq(0)').after('<a class="readMore" href="javascript:;" onClick="trun.show(\''+id+'\')">Read more</a>');
		$(this).append('<a class="readLess" href="javascript:;" onClick="trun.hide(\''+id+'\')">Close</a>');
		
		i++;
	});
	
	$('.trun .readLess').hide();
	//$('.trun > *').hide();
	$('.trun > *:lt(2)').show();
}

trun.show = function(id){
	$('#'+id).find('> *').show();
	$('#'+id+' .readMore').hide();
	$('#'+id+' .readLess').show();
}

trun.hide = function(id){
	$('#'+id).find('> *').hide();
	$('#'+id).find('> *:lt(1)').show();
	$('#'+id+' .readMore').show();
	$('#'+id+' .readLess').hide();
}

$(document).ready(function(){
	trun.init();
});
