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]="Indianapolis Colts";	team[0][1]="New Orleans Saints";	odds = new Array();	odds[0]= new Array();	odds[0][0]=1.47;	odds[0][1]= 2.75;	
		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 < 7; j++)
{
if((0.8-(total11 / totalx))  > (Math.random() * 1))
{
 	total1[j] = 7;	
}
else if((1-(total11 / totalx))  > (Math.random() * 1))
{
	total1[j] = 3;
}
else
{
	total1[j] = 0;	
}

if((0.8-(total33 / totalx))  > (Math.random() * 1))
{
 	total2[j] = 7;	
}
else if((1-(total33 / totalx))  > (Math.random() * 1))
{
	total2[j] = 3;
}
else
{
	total2[j] = 0;	
}
}

hometeam = total1[0] + total1[1] +total1[2] +total1[3] +total1[4] +total1[5] +total1[6];
awayteam = total2[0] + total2[1] +total2[2] +total2[3] +total2[4] +total2[5] +total2[6];




if(hometeam > awayteam)
{
	winner = side4;
}
else if(awayteam > hometeam)
{
	winner = side5;
}
else
{
	win = new Array();	win[0]=side4; win[1]=side5;
	winnerx = Math.floor(Math.random()*2);
		
		winner=win[winnerx] + " OT";
		
		if(win[winnerx]==side4)
		{
			if(Math.floor(Math.random()*2)==0)
			{
				hometeam = hometeam +6;
			}else
			{
				hometeam = hometeam +3;
			}
		}else
		{
		if(Math.floor(Math.random()*2)==0)
			{
				awayteam = awayteam +6;
			}else
			{
				awayteam = awayteam +3;
			}
		}
}




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 = "";
}
}

