var vBrowser = null;
var URLUsed = false;

//  Change the selected table to view (style="display:inline")
//  and hide the other tables (style="display:none") 
function ChangeTable()
{
	vBrowser = BrowserDetect(0);
    if (document.getElementById("LadiesSingles"))
    	document.getElementById("LadiesSingles").style.display = "none";
    if (document.getElementById("LadiesDoubles"))
    	document.getElementById("LadiesDoubles").style.display = "none";
   	if (document.getElementById("MensSingles"))
	    document.getElementById("MensSingles").style.display   = "none";
   	if (document.getElementById("MensDoubles"))
	    document.getElementById("MensDoubles").style.display   = "none";
   	if (document.getElementById("MixedDoubles"))
	    document.getElementById("MixedDoubles").style.display  = "none";
   	if (document.getElementById("American"))
    	document.getElementById("American").style.display  = "none";
   	if (document.getElementById("Plate"))
    	document.getElementById("Plate").style.display  = "none";
   	if (document.getElementById("LadiesAfternoon"))
	   	document.getElementById("LadiesAfternoon").style.display  = "none";
   	if (document.getElementById("JuniorGirlsSingles"))
  		document.getElementById("JuniorGirlsSingles").style.display  = "none";
   	if (document.getElementById("JuniorGirlsDoubles"))
	   	document.getElementById("JuniorGirlsDoubles").style.display  = "none";
   	if (document.getElementById("JuniorBoysSingles"))
   		document.getElementById("JuniorBoysSingles").style.display  = "none";
   	if (document.getElementById("JuniorBoysDoubles"))
	   	document.getElementById("JuniorBoysDoubles").style.display  = "none";
   	if (document.getElementById("JuniorMixedDoubles"))
   		document.getElementById("JuniorMixedDoubles").style.display  = "none";


	if (URLUsed == false)
	{
		if((window.location.search[1] >= "0")
		|| (window.location.search[1] <= "4"))
		{
			document.getElementById("CupType").selectedIndex = window.location.search[1];
			URLUsed = true;
		}
	}
	
	switch(document.getElementById("CupType").selectedIndex)
    {
    case 0:
    	if (document.getElementById("LadiesSingles"))
	        if (vBrowser == "Internet Explorer")
				document.getElementById("LadiesSingles").style.display = "inline";
        	else
				document.getElementById("LadiesSingles").style.display = "table-row";
    	if (document.getElementById("JuniorGirlsSingles"))
        	if (vBrowser == "Internet Explorer")
				document.getElementById("JuniorGirlsSingles").style.display = "inline";
        	else
	        	document.getElementById("JuniorGirlsSingles").style.display = "table-row";
		break;
    case 1:
    	if (document.getElementById("LadiesDoubles"))
	        if (vBrowser == "Internet Explorer")
				document.getElementById("LadiesDoubles").style.display = "inline";
        	else
	        	document.getElementById("LadiesDoubles").style.display   = "table-row";
    	if (document.getElementById("JuniorGirlsDoubles"))
        	if (vBrowser == "Internet Explorer")
				document.getElementById("JuniorGirlsDoubles").style.display = "inline";
        	else
	        	document.getElementById("JuniorGirlsDoubles").style.display = "table-row";
        break;
    case 2:
    	if (document.getElementById("MensSingles"))
	        if (vBrowser == "Internet Explorer")
				document.getElementById("MensSingles").style.display = "inline";
        	else
	        	document.getElementById("MensSingles").style.display  = "table-row";
    	if (document.getElementById("JuniorBoysSingles"))
        	if (vBrowser == "Internet Explorer")
				document.getElementById("JuniorBoysSingles").style.display = "inline";
        	else
	        	document.getElementById("JuniorBoysSingles").style.display = "table-row";
        break;
    case 3:
    	if (document.getElementById("MensDoubles"))
	        if (vBrowser == "Internet Explorer")
				document.getElementById("MensDoubles").style.display = "inline";
        	else
	        	document.getElementById("MensDoubles").style.display = "table-row";
    	if (document.getElementById("JuniorBoysDoubles"))
        	if (vBrowser == "Internet Explorer")
				document.getElementById("JuniorBoysDoubles").style.display = "inline";
        	else
	        	document.getElementById("JuniorBoysDoubles").style.display = "table-row";
        break;
    case 4:
    	if (document.getElementById("MixedDoubles"))
	        if (vBrowser == "Internet Explorer")
				document.getElementById("MixedDoubles").style.display = "inline";
        	else
	        	document.getElementById("MixedDoubles").style.display = "table-row";
    	if (document.getElementById("JuniorMixedDoubles"))
        	if (vBrowser == "Internet Explorer")
				document.getElementById("JuniorMixedDoubles").style.display = "inline";
        	else
	        	document.getElementById("JuniorMixedDoubles").style.display = "table-row";
        break;
    };

	if (document.getElementById("CupType").value == "Normal Tournament")
 		window.location = 'Random.php?Type=Normal';
    if (document.getElementById("CupType").value == "American Tournament (Sayers Trophy)")
 		window.location = 'Random.php?Type=American';
    if (document.getElementById("CupType").value == "Plate Tournament")
 		window.location = 'Random.php?Type=Plate';
    if (document.getElementById("CupType").value == "Singles Tournament")
 		window.location = 'Random.php?Type=Singles';
    if (document.getElementById("CupType").value == "Speed Tournament")
 		window.location = 'Random.php?Type=Speed';
    if (document.getElementById("CupType").value == "Monday Ladder")
 		window.location = 'Ladder.php?Type=Monday';
    if (document.getElementById("CupType").value == "Tuesday Ladder")
 		window.location = 'Ladder.php?Type=Tuesday';

    document.getElementById("CupType").focus();
} 

