	$(document).ready(function() {

		var filename = window.location.href.substr(window.location.href.lastIndexOf("/") + 1);
		filename = filename.toUpperCase();

		if (filename.indexOf("QUESTIONNAIRE.ASPX") > -1)
		// if (filename.indexOf("QUESTIONAIRE.HTML") > -1) // local debug use only
		{
			$("input[type=radio]").each(

				function(intIndex) {

					var y = $(this).parents('table');								

					var tableid = "#" + y.get(0).id; // stores the table ID where questionaires are 					                

					// This process re-align the list of questions so that it displays vertically 
					var tds = $(tableid + " tr td"); // gets all td elements in the table with id myTable
					var tdsInput = $(tableid + " tr td input"); // gets all td elements in the table with contents 
					var col1 = $("<tr></tr>"); // holds our first row's columns
					var col2 = $("<tr></tr>"); // holds our second row's columns
					var col = [tdsInput.length]; // array to store number of columns

					// add the first half of our td's to the first row, the second half to the second
					for (var i = 0; i < tdsInput.length; i++) {
						col[i] = $("<tr></tr>");
						col[i].append(tds[i]);
					}

					// clear out the clutter from the table
					$(tableid).children().remove();
					// add our two rows

					for (var i = 0; i < tdsInput.length; i++) {
						$(tableid).append(col[i]);
					}

					$(tableid).css({ 'display': 'block' }).css({ 'width': '100%' });
					
					// $(tableid).closest('tr').css({'vertical-align':'top'}); // Update the Table Tag to valign=Top					
					// $(tableid).closest('tr').css({'background-color':'aqua'}); // Update the Table Tag to valign=Top					
					// $(tableid).closest('tr').children('td').css({'background-color':'green'}); // Update the Table Tag to valign=Top			
					// $(tableid).closest('tr').children('td').attr('valign', 'top'); 					
					$(tableid).closest('tr').children('td').css({'vertical-align':'top'});
				 }
		   )
		}		
	});
