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]="New Jersey Devils";	team[0][1]="Philadelphia Flyers";	odds = new Array();	odds[0]= new Array();	odds[0][0]=2.10;	odds[0][1]= 1.76;	
	team[1]= new Array();	team[1][0]="New York Rangers";	team[1][1]="Montreal Canadiens";		odds[1]= new Array();	odds[1][0]=2.30;	odds[1][1]= 1.66;	
	team[2]= new Array();	team[2][0]="Pittsburgh Penguins";	team[2][1]="Carolina Hurricanes";		odds[2]= new Array();	odds[2][0]=2.10;	odds[2][1]= 1.76;	
	team[3]= new Array();	team[3][0]="New York Islanders";	team[3][1]="Washington Capitals";		odds[3]= new Array();	odds[3][0]=2.40;	odds[3][1]= 1.62;	
	team[4]= new Array();	team[4][0]="Boston Bruins";	team[4][1]="Tampa Bay Lightning";		odds[4]= new Array();	odds[4][0]=1.68;	odds[4][1]= 2.25;	
	team[5]= new Array();	team[5][0]="Buffalo Sabres";	team[5][1]="Florida Panthers";		odds[5]= new Array();	odds[5][0]=1.83;	odds[5][1]= 2.00;	
	team[6]= new Array();	team[6][0]="Vancouver Canucks";	team[6][1]="Detroit Red Wings";		odds[6]= new Array();	odds[6][0]=2.80;	odds[6][1]= 1.45;	
	team[7]= new Array();	team[7][0]="Colorado Avalanche";	team[7][1]="Nashville Predators";		odds[7]= new Array();	odds[7][0]=2.25;	odds[7][1]= 1.68;	
	team[8]= new Array();	team[8][0]="Toronto Maple Leafs";	team[8][1]="Phoenix Coyotes";		odds[8]= new Array();	odds[8][0]=2.05;	odds[8][1]= 1.80;	
	team[9]= new Array();	team[9][0]="Columbus Blue Jackets";	team[9][1]="San Jose Sharks";		odds[9]= new Array();	odds[9][0]=3.30;	odds[9][1]= 1.35;	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.7-(total11 / totalx))  > (Math.random() * 1))
{
 	total1[j] = 1;	
}
else
{
	total1[j] = 0;	
}

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

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


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);
		if(Math.floor(Math.random()*2)==0)
		{
		winner=win[winnerx] + " OT";
		}else
		{
		winner=win[winnerx] + " SO";
		}
		if(win[winnerx]==side4)
		{
		hometeam = hometeam +1;
		}else
		{
		awayteam = awayteam +1;
		}
}

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 = "";
}
}

