function getLeagueTable(team){
	if(!document.getElementById('leagueFrame')) {return false;}
	if(!document.createElement) return false;
	if(!document.createTextNode) return false;

	//first we want to hide the Javawarning Div because if we got this far we figure their browser supports JS.
	document.getElementById('javawarning').style.visibility = 'hidden';
	document.getElementById('javawarning').style.height = '0px';
	document.getElementById('javawarning').style.display = 'none';
	document.getElementById('leagueSelect').style.visibility = 'visible';
	
/*******************************************/	
/* here we go, off to sort of the league table	 */
/*******************************************/
	var leagueFrame = document.getElementById('leagueFrame');
	var outputDiv = document.getElementById('output');
	
	var tables = leagueFrame.getElementsByTagName('table');	
	var leagueTable = tables[0];
	
	var newLeagueTable = document.createElement('table');
	var newTableBody = document.createElement('tbody');
	
	newLeagueTable.style.borderCollapse = 'collapse';
	newLeagueTable.style.border = '1px solid #fff';
	
	
	//create the headings for the table columns
	var tableHeaders = ['Team','Played','Won','Drawn','Lost','For','Against','Diff.','Points'];
	var topRow = document.createElement('tr');
	for(i = 0; i < 9; i++){
		var newHeader = document.createElement('th');
		var headerTextNode = document.createTextNode(tableHeaders[i]);
		newHeader.style.borderBottom = '1px solid #fff';
		
		newHeader.appendChild(headerTextNode);
		topRow.appendChild(newHeader);		
	}
	newTableBody.appendChild(topRow);
	//finshed creating headings
	
	//get all the old rows from the league table
	var oldRows = leagueTable.getElementsByTagName('tr');	
	
	//this little bit is to get around the error in IE becuase it doesnt do reg exp matching properly.
	//this drops out the last rows for the 2 affected teams.
	//will remove this when i figure how to get reg exp matching in IE sorted	
	if((team == 2)){
		numOldRows = oldRows.length - 1;
		} else {
		numOldRows = oldRows.length;
	}
	
	for (i = 1; i < numOldRows ; i++){
		cellBackground = '';
		
		var cells = oldRows[i].getElementsByTagName('td');
		
		var newRow = document.createElement('tr');
		//deal with title cell
		var aContents = cells[1].getElementsByTagName('a');
		var teamName = aContents[0].firstChild.nodeValue;
		
		
				
		var titleCell = document.createElement('td');
		var newTextNode = document.createTextNode(teamName);
		titleCell.style.borderBottom = '1px solid #fff';
		
		//highlight the row where the word 'loughborough' appears in the title cell
		if(teamName.match(/Loughborough Town/i)){
			cellBackground = '#3360AA';
			titleCell.style.background = cellBackground;
		}
		
		titleCell.appendChild(newTextNode);
		newRow.appendChild(titleCell);
		titleCell.style.width = '200px';
		
		//now deal with rest of cells
		for (j = 2; j < cells.length ; j++){
			//get value from old cell
			var oldText = '0';
			oldText = cells[j].firstChild.nodeValue;
			
			if(!oldText.match(/\d+/m)){oldText = ' 0 ';}
			
			
			var currentCell = document.createElement('td');
			var textNode = document.createTextNode(oldText);
						
			currentCell.style.width = '50px';
			currentCell.style.textAlign = 'center';
			currentCell.style.borderBottom = '1px solid #fff';
			if(cellBackground){currentCell.style.background = cellBackground;}
			
			currentCell.appendChild(textNode);
			newRow.appendChild(currentCell);		
		}		
		newTableBody.appendChild(newRow);		
	}	
	newLeagueTable.appendChild(newTableBody);
	outputDiv.appendChild(newLeagueTable);
	
	
/******************************************************/	
/*finished the league table, recent results from here down	 */
/******************************************************/

	var resultsFrame = document.getElementById('resultsFrame');
	var outputDiv2 = document.getElementById('output2');
	
	var tables = resultsFrame.getElementsByTagName('table');
	var resultsTable = tables[0];
	
	var newResultsTable = document.createElement('table');
	var newResultsTableBody = document.createElement('tbody');
	
	newResultsTable.style.borderCollapse = 'collapse';
	newResultsTable.style.border = '1px solid #fff';
	
	//create the headings for the table's columns
	var tableHeaders = ['Home','Score','Away'];
	var cellWidths = ['200px','150px','200px'];
	var cellAligns = ['right','center','left'];
	
	var topRow = document.createElement('tr');
	for(i = 0; i < 3; i++){
		var newHeader = document.createElement('th');
		var headerTextNode = document.createTextNode(tableHeaders[i]);
		newHeader.style.borderBottom = '1px solid #fff';
		newHeader.style.width = cellWidths[i];
		
		
		newHeader.appendChild(headerTextNode);
		topRow.appendChild(newHeader);
		
	}
	
	newResultsTableBody.appendChild(topRow);
	//finished creating headings.
	
	var oldRows = resultsTable.getElementsByTagName('tr');
	for (i = 1; i < oldRows.length ; i++){
		var cells = oldRows[i].getElementsByTagName('td');
		var newRow = document.createElement('tr');
		
		for (j = 0; j < cells.length; j++){
			var aContents = cells[j].getElementsByTagName('a');
			if(aContents.length > 0){
				var nodeText = aContents[0].firstChild.nodeValue;
			} else if(aContents.length == 0){
				var nodeText = cells[j].firstChild.nodeValue;
			}
			
			var currentCell = document.createElement('td');
			var textNode = document.createTextNode(nodeText);
			currentCell.style.width = cellWidths[j];
			currentCell.style.textAlign = cellAligns[j];
			
			currentCell.appendChild(textNode);
			newRow.appendChild(currentCell);
		}
		newResultsTableBody.appendChild(newRow);
	}
	newResultsTable.appendChild(newResultsTableBody);
	outputDiv2.appendChild(newResultsTable);
}