
    var colHeadArr = new Array();
    var tdColHeadArr = new Array();
    	$(document).ready(function(){
    		
    		//create an array of all the Column Headers
    		$('#stakeHolderTable thead th').each(
    		 	function(){
    		 	var txt = $(this).html();
    		 	colHeadArr.push(txt);
    		 	});
    		 //drop the first value in the array as the first th is not needed
    		 colHeadArr.shift();
    		
   		 
    		//create the array with all the column headers per table cell
    		$('#stakeHolderTable tr').each(function(){
    			$(this).children('td').each(
    				function(i){
    					tdColHeadArr.push(colHeadArr[i]);
    				});
    		});
    		
    		// delete the colHead Array as it is no longer needed
    		delete colHeadArr;


 			  $('#stakeHolderTable td:has(.issue)').addClass('hasContent');
 			  $('#stakeHolderTable td .issue').hide();
 			  $('td.hasContent').append('<span class="highlight"></span>');
 			  $('td.hasContent .highlight').hide();
 			  
 			  
 			$('#stakeHolderTable td').each(function(i){

 			  	var colHead = tdColHeadArr[i].toString();
 			  	var rowHead = $(this).parent().children([0]).html();
 			  	
 			  	//create the headings
 			  	var txt = 
 			  	'<div class="issueHeader">' +
 			  	'<em>Corporate Responsibility</em> ' + colHead +
 			  	'<br />' + 		  	
 			  	'<em>Stakeholder Group</em> ' + rowHead + 
 			  	'</div>';
 			  	//append the text to the issue
 			  	$(this).children('.issue').prepend(txt);
 			  	//set the offset
 			  	var mt = ($(this).height()+1);
 			  	$(this).children('.issue').css('margin-top', mt);
 			  	//remove the spans in the header that contain the numbers and letters  	
 			  	$('.issueHeader span').remove();
 			  	
 			  });
 			  
 			 
 			  
 			   			  
	$('td.hasContent').click(
	  	function(){
		$('td.hasContent').not($(this)).removeClass('isActive');
	  		$('#stakeHolderTable td:has(.issue)').not($(this)).children('.issue').hide();
	  		$('#stakeHolderTable td:has(.highlight)').not($(this)).children('.highlight').hide();
	  		$(this).children('.highlight').toggle();
	  		$(this).children('.issue').toggle();
	  		$(this).toggleClass('isActive');
	  		
	  	});
});
