od47(function() 
	{
		od47('.pager').show();
		
		/* od47('.filter td.trust-name a').each(function()
			{
				var that = od47(this);
				var str = that.text();
				var trunc = str.substring(0, str.length-6);
				var trustNameLength = that.text().length;
				if(trustNameLength >66)
					{
						that.text(trunc);
						that.append('...');
					}
			}); */

od47('.filter th').click(function()
	{
		od47('.filter tbody td').removeClass('active');
	});

/* od47('.filter tbody tr').click(function() 
	{
		od47('.filter tbody td').removeClass('active');
		od47(this).children().addClass('active');
	}); */
		
od47('.filter td').not('.score').not('.trust-name').each(function()
	{
		var answerText = od47(this).text();
		od47(this).html('<img src="/quality-accounts/images/content/rank-' + answerText + '.gif" alt="Score: ' + answerText +' " />'); 
	});
		
od47('table.filter').tablesorter(
	{debug: false, 
	headers:{
		1: {sorter:'digit' },
		2: {sorter: false}}, 
		sortList: [[1,1]]
		})
	.tablesorterPager({container: od47('.pager')});
			
od47('.pager select').each(function()
	{
		od47(this).find('>option:nth(0)').attr('selected' , 'selected');
				
		od47(this).change(function()
			{
				var val = od47(this).val();
				od47('.pager select option[value="' + val + '"]').attr('selected' , 'selected');
				//alert('.pager select option[value="' + val + '"]')
						
			});
	});

od47('th.score').click(function()
	{
		od47(this).next().css('font-weight' , 'bold');
	});

od47('th').not('.score').not('.patient-safety').click(function()
	{
		od47('th.patient-safety').css('font-weight' , 'normal');
	});

od47('th img').click(function()
	{
		return false;
	});

od47('.qa-indicator-details , .quality-accounts').hide();

od47('div#patient-safety').show();
		
od47('#qa-tabs li').click(function()
	{
		od47('#qa-tabs li').removeAttr('class');
		od47(this).addClass('current');
		var href = od47(this).find('>a').attr('href');
		od47('.quality-accounts').hide();
		od47('div' + href).show();
		return false;
				
	});

od47('.indicator-list li a.read-more').toggle(function()
	{
		od47(this).find('>img').attr({src: "http://www.drfosterhealth.co.uk/images/layout/minus-icon.gif" , alt: "hide"});
		od47(this).parent().find('>.qa-indicator-details').slideDown('200').find('>div').fadeIn(700);
		return false;
	}, function()
	{
		od47(this).find('>img').attr({src: "http://www.drfosterhealth.co.uk/images/layout/plus-icon.gif" , alt: "show"});
		od47(this).parent().find('>.qa-indicator-details').hide().find('>.qa-chart-container').hide();
		return false;
	});

od47('.trust-comments').expander({
    slicePoint:       200,
    expandEffect:     'show',
    userCollapse:     false
  });
  
  
od47('.read-more').prev('p').css({display: "inline"}).prev('p').css({paddingBottom: "0.2em"});
od47('.details').find('>p:nth(0)').css({display: "inline"});

// od47('.control-limit').css('opacity' , 0.3);

});
