function displayType(distype) {
// Hides and displays the appropriate rows

// Find the table
var table=document.getElementById('fixtureslist');
var tabbodies=table.getElementsByTagName('tbody');

// (Crudely) Check if the browser is IE as IE won't understand table-row
var isie=false;
if (document.all&&document.getElementById)
	isie=true;

// Set the appropriate value for the CSS display property. IE will have to make do with block
// if (isie)
// 	var disatt="block";
// else
// 	var disatt="table-row";

//loop through the tbody's (unlikely to be >1 but just in case)
for (var j=0; j<tabbodies.length; j++)
	{
	var tabrows=tabbodies[j].getElementsByTagName('tr');
//loop over each row
        for (var i=0; i<tabrows.length; i++)
        	{
        	if (distype=="all")
		// Display all the rows
        		{
        		tabrows[i].style.display="";
        		}
        	else
        		{
        		if (tabrows[i].className==distype)
			//if this has the class we're displaying, show it
				tabrows[i].style.display="";
				
        		else
			//Otherwise hide it
        			tabrows[i].style.display="none";
        		}
        	}
	}
}

function FixtureFormCreate(FixTypes) {
// Create the containing div
var insdiv=document.createElement("div");
// and insert it into the document above the fixtures list
var table=document.getElementById("fixtureslist");
table.parentNode.insertBefore(insdiv,table);
insdiv.setAttribute("id", "fixtypeselect");
// Create the form elements
var insform=document.createElement("form");
var insselect=document.createElement("select");
insselect.setAttribute("id","fixturesel");
var inslabel=document.createElement("label");
inslabel.appendChild(document.createTextNode("Select fixtures "));
inslabel.setAttribute("for","fixturesel");
// Build the form
insdiv.appendChild(insform);
insform.appendChild(inslabel);
insform.appendChild(insselect);

// Add the Options
for (var i=0; i<FixTypes.length; i++)
	{
	insselect.appendChild(new Option);
	insselect.options[i].text=FixTypes[i].displaytxt;
	insselect.options[i].value=FixTypes[i].passvalue;
	}
// Set the event handler to change the display
insselect.onchange=function() {
displayType(this.options[this.selectedIndex].value);
}
}

function FixtureTypes() {
//options for fixture display types
var FixTypes=new Array();
//Format is FixType("displayed name", "class")
FixTypes.push(new FixType("All", "all"));
FixTypes.push(new FixType("Premiership", "prem"));
FixTypes.push(new FixType("FA Cup", "facup"));
FixTypes.push(new FixType("League Cup", "lcup"));
FixtureFormCreate(FixTypes);
}

function FixType(dtxt,pvalue)
{
this.displaytxt=dtxt;
this.passvalue=pvalue;
}
