// JavaScript Document

// The table of the decision matrix has to have the ID attribute named "matrix" for this script to work
 $(document).ready(function(){
	 
  // Get the text of the noscript to fill the div #toto and find its tr to apply a function on each of them
    $("#matrix").find("tr").each(function(j){
		// if a click is done on one of this th
		$(".show_rows",this).click(function(){
			// if this is not the first row
			if (j>0) {
				// call the function displayRow with the row number and the row object
				displayRow(j, $(this).parent());
			}
			// plus find all the div (X) of the table and hide them (first time it is loaded)
		}).parent().find("td div").hide();
	});
});
  
function displayRow(j, row) {
		
		// if row is visible: hide it
        if (row.find("td div:visible").length> 0) {
			// First clean the table, to restaure the intial state
		   row.find("td div").hide();	
		   row.removeAttr("id");		   
        } else { 
			// else make the div (X) appear for the clicked row
			row.find("td div").show();
			// Add an id to the tr of the row that is displayed
			row.attr("id","display");
      }
  }
