var Site = {

   cacheStory:Array(),

   shrinkStories:function()
   {	   	
   	$('.story').each(function(){   	
			Site.shrinkStory.call(this);   	
   	});	
   },
   fullStory:function(whichStory){
   
      $('#'+whichStory).find('.content').html(Site.cacheStory[whichStory]).append('<a class="show-less" href="javascript:Site.shrinkStory(\''+whichStory+'\')">Show less</a>');
   },
	shrinkStory:function(whichStory){
		
		if (typeof whichStory != 'undefined'){
			var story = $('#'+whichStory).get(0);
		}else{
			var story = this;
		}
		
   	var moreChar = '&#8230;';	
   	var words = 35;
   	var re = new RegExp("\\s*(?:\\S*\\s*){"+words+"}");		
		
	   if(typeof Site.cacheStory[story.id] == 'undefined'){
			var content = $(story).find('.content').html();
		   Site.cacheStory[story.id] = content;
		}else{
			var content = Site.cacheStory[story.id];
		}
	   
	   var words = content.match(re);
	   
   	if(words[0].length == content.length){
   		$(story).find('.content').html(content);
   	}else{
   		$(story).find('.content').html(words[0] + moreChar+'<a class="show-more" href="javascript:Site.fullStory(\''+story.id+'\')">Show more</a>');
   	}			
	}

}
