function matchselect()
{
var mymatch=document.getElementById("mymatch");
var matchnumber=document.getElementById("mymatch").selectedIndex;

span_clear();

if (matchnumber=="0") { team = new Array();	team[0]= new Array();	team[0][0]="Houston Astros (Oswalt)";	team[0][1]="Washington Nationals (Olsen)";	odds = new Array();	odds[0]= new Array();	odds[0][0]=1.74;	odds[0][1]= 2.15;	
	team[1]= new Array();	team[1][0]="Cleveland Indians (Reyes)";	team[1][1]="Toronto Blue Jays (Cecil)";		odds[1]= new Array();	odds[1][0]=2.10;	odds[1][1]= 1.76;	
	team[2]= new Array();	team[2][0]="San Francisco Giants (Lincecum)";	team[2][1]="Chicago Cubs (Marshall)";		odds[2]= new Array();	odds[2][0]=1.90;	odds[2][1]= 1.90;	
	team[3]= new Array();	team[3][0]="Baltimore Orioles (Uehara)";	team[3][1]="Tampa Bay Rays (Garza)";		odds[3]= new Array();	odds[3][0]=2.70;	odds[3][1]= 1.50;	
	team[4]= new Array();	team[4][0]="Texas Rangers (Padilla)";	team[4][1]="Seattle Mariners (Bedard)";		odds[4]= new Array();	odds[4][0]=2.45;	odds[4][1]= 1.60;	calc();}
if (matchnumber=="1") { team = new Array();	team[0]= new Array();	team[0][0]="Milwaukee Brewers (Suppan)";	team[0][1]="Pittsburgh Pirates (Snell)";	odds = new Array();	odds[0]= new Array();	odds[0][0]=1.86;	odds[0][1]= 1.95;	
	team[1]= new Array();	team[1][0]="Minnesota Twins (Blackburn)";	team[1][1]="Detroit Tigers (Porcello)";		odds[1]= new Array();	odds[1][0]=2.00;	odds[1][1]= 1.83;	
	team[2]= new Array();	team[2][0]="Boston Red Sox (Beckett)";	team[2][1]="New York Yankees (Chamberlain)";		odds[2]= new Array();	odds[2][0]=2.15;	odds[2][1]= 1.74;	
	team[3]= new Array();	team[3][0]="Cincinnati Reds (Volquez)";	team[3][1]="Florida Marlins (Volstad)";		odds[3]= new Array();	odds[3][0]=2.10;	odds[3][1]= 1.76;	
	team[4]= new Array();	team[4][0]="New York Mets (Hernandez)";	team[4][1]="Atlanta Braves (Kawakami)";		odds[4]= new Array();	odds[4][0]=2.10;	odds[4][1]= 1.76;	
	team[5]= new Array();	team[5][0]="Chicago White Sox (Floyd)";	team[5][1]="Kansas City Royals (Davies)";		odds[5]= new Array();	odds[5][0]=2.15;	odds[5][1]= 1.74;	
	team[6]= new Array();	team[6][0]="Philadelphia Phillies (Myers)";	team[6][1]="St Louis Cardinals (Wainwright)";		odds[6]= new Array();	odds[6][0]=2.05;	odds[6][1]= 1.80;	
	team[7]= new Array();	team[7][0]="Colorado Rockies (Cook)";	team[7][1]="San Diego Padres (Geer)";		odds[7]= new Array();	odds[7][0]=1.90;	odds[7][1]= 1.90;	
	team[8]= new Array();	team[8][0]="Los Angeles Angels of Anaheim (Loux)";	team[8][1]="Oakland Athletics (Braden)";		odds[8]= new Array();	odds[8][0]=2.25;	odds[8][1]= 1.68;	calc()};


}
function calc()
{

var total = 0;
var total1 = new Array();
var total2 = new Array();
var total3 = 0;
var totalx = 0;
var total11 = 0;
var total22 = 0;
var total33 = 0;
var hometeam = 0;
var drawteam = 0;
var awayteam = 0;
var winner = 0;
var result = 0;
var side4 = 0;
var side5 = 0;
var side6 = 0;
var tot = 0;



for(var i = 0; i < team.length; i++)
{
side4 = team[i][0];
side5 = team[i][1];

total11 = odds[i][0];
total33 = odds[i][1];
totalx = total11 + total33;

for(var j = 0; j < 10; j++)
{
if((0.8-(total11 / totalx))  > (Math.random() * 1))
{
 	total1[j] = 1;	
}
else
{
	total1[j] = 0;	
}

if((0.8-(total33 / totalx))  > (Math.random() * 1))
{
 	total2[j] =1;	
}
else
{
	total2[j] = 0;	
}
}

hometeam = Math.floor(Math.random()*7) +total1[0] + total1[1] +total1[2] +total1[3] +total1[4] +total1[5] +total1[6]+total1[7]+total1[8];
awayteam = Math.floor(Math.random()*7) +total2[0] + total2[1] +total2[2] +total2[3] +total2[4] +total2[5] +total2[6]+total2[7]+total2[8];




if(hometeam > awayteam)
{
	winner = side4;
}
else if(awayteam > hometeam)
{
	winner = side5;
}
else
{
	winner = "Draw";
}




var res = side4 + " <strong>" + hometeam + " "  + "</strong>  v  " + side5 + "  <strong>" + awayteam + " "+"</strong> <br /><span class='style2'>Result: "+winner+"</span><br />";

div = document.getElementById("results");


div.innerHTML = div.innerHTML + res + "<br />";



}
var mymatch=document.getElementById("mymatch");
var matchnumber=document.getElementById("mymatch").selectedIndex;
var matchy = mymatch.options[matchnumber].text
document.getElementById("matchx").innerHTML=document.getElementById("matchx").innerHTML+"<h3>"+matchy+"</h3><br />";


}

function span_clear() {
var max = 19;

for (var i=0; i<max+1; i++) {

document.getElementById("results").innerHTML = "";
document.getElementById("matchx").innerHTML = "";
}
}

