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]="South Africa ";	team[0][1]="Draw";	team[0][2]= "Mexico";	odds = new Array();	odds[0]= new Array();	odds[0][0]=2.88;	odds[0][1]=3.25;	odds[0][2]= 2.5;	
	team[1]= new Array();	team[1][0]="Uruguay ";	team[1][1]="Draw";	team[1][2]= "France";		odds[1]= new Array();	odds[1][0]=3.6;	odds[1][1]=3.25;	odds[1][2]= 2.1;	calc();}
if (matchnumber==1) { team = new Array();	team[0]= new Array();	team[0][0]="Argentina ";	team[0][1]="Draw";	team[0][2]= "Nigeria";	odds = new Array();	odds[0]= new Array();	odds[0][0]=1.5;	odds[0][1]=4;	odds[0][2]= 7.5;	
	team[1]= new Array();	team[1][0]="England ";	team[1][1]="Draw";	team[1][2]= "USA";		odds[1]= new Array();	odds[1][0]=1.5;	odds[1][1]=4.1;	odds[1][2]= 7;	
	team[2]= new Array();	team[2][0]="South Korea ";	team[2][1]="Draw";	team[2][2]= "Greece";		odds[2]= new Array();	odds[2][0]=2.5;	odds[2][1]=3.2;	odds[2][2]= 2.9;	calc();}
if (matchnumber==2) { team = new Array();	team[0]= new Array();	team[0][0]="Algeria ";	team[0][1]="Draw";	team[0][2]= "Slovenia";	odds = new Array();	odds[0]= new Array();	odds[0][0]=3.4;	odds[0][1]=3.25;	odds[0][2]= 2.2;	
	team[1]= new Array();	team[1][0]="Germany ";	team[1][1]="Draw";	team[1][2]= "Australia";		odds[1]= new Array();	odds[1][0]=1.5;	odds[1][1]=4.1;	odds[1][2]= 7;	
	team[2]= new Array();	team[2][0]="Serbia ";	team[2][1]="Draw";	team[2][2]= "Ghana";		odds[2]= new Array();	odds[2][0]=2.2;	odds[2][1]=3.25;	odds[2][2]= 3.4;	calc();}
if (matchnumber==3) { team = new Array();	team[0]= new Array();	team[0][0]="Italy ";	team[0][1]="Draw";	team[0][2]= "Paraguay";	odds = new Array();	odds[0]= new Array();	odds[0][0]=2;	odds[0][1]=3.25;	odds[0][2]= 4.1;	
	team[1]= new Array();	team[1][0]="Japan ";	team[1][1]="Draw";	team[1][2]= "Cameroon";		odds[1]= new Array();	odds[1][0]=3.6;	odds[1][1]=3.3;	odds[1][2]= 2.1;	
	team[2]= new Array();	team[2][0]="Netherlands ";	team[2][1]="Draw";	team[2][2]= "Denmark";		odds[2]= new Array();	odds[2][0]=1.57;	odds[2][1]=4;	odds[2][2]= 6;	calc();}
if (matchnumber==4) { team = new Array();	team[0]= new Array();	team[0][0]="Brazil ";	team[0][1]="Draw";	team[0][2]= "North Korea";	odds = new Array();	odds[0]= new Array();	odds[0][0]=1.1;	odds[0][1]=9;	odds[0][2]= 29;	
	team[1]= new Array();	team[1][0]="Ivory Coast ";	team[1][1]="Draw";	team[1][2]= "Portugal";		odds[1]= new Array();	odds[1][0]=3.6;	odds[1][1]=3.3;	odds[1][2]= 2.1;	
	team[2]= new Array();	team[2][0]="New Zealand ";	team[2][1]="Draw";	team[2][2]= "Slovakia";		odds[2]= new Array();	odds[2][0]=9;	odds[2][1]=4.33;	odds[2][2]= 1.4;	calc();}
if (matchnumber==5) { team = new Array();	team[0]= new Array();	team[0][0]="Honduras ";	team[0][1]="Draw";	team[0][2]= "Chile";	odds = new Array();	odds[0]= new Array();	odds[0][0]=6;	odds[0][1]=3.75;	odds[0][2]= 1.62;	
	team[1]= new Array();	team[1][0]="South Africa ";	team[1][1]="Draw";	team[1][2]= "Uruguay";		odds[1]= new Array();	odds[1][0]=2.88;	odds[1][1]=3.25;	odds[1][2]= 2.25;	
	team[2]= new Array();	team[2][0]="Spain ";	team[2][1]="Draw";	team[2][2]= "Switzerland";		odds[2]= new Array();	odds[2][0]=1.29;	odds[2][1]=5.5;	odds[2][2]= 11;	calc();}
if (matchnumber==6) { team = new Array();	team[0]= new Array();	team[0][0]="Argentina ";	team[0][1]="Draw";	team[0][2]= "South Korea";	odds = new Array();	odds[0]= new Array();	odds[0][0]=1.36;	odds[0][1]=4;	odds[0][2]= 8;	
	team[1]= new Array();	team[1][0]="France ";	team[1][1]="Draw";	team[1][2]= "Mexico";		odds[1]= new Array();	odds[1][0]=2;	odds[1][1]=3.25;	odds[1][2]= 3.5;	
	team[2]= new Array();	team[2][0]="Greece ";	team[2][1]="Draw";	team[2][2]= "Nigeria";		odds[2]= new Array();	odds[2][0]=2.63;	odds[2][1]=3.25;	odds[2][2]= 2.38;	calc();}
if (matchnumber==7) { team = new Array();	team[0]= new Array();	team[0][0]="England ";	team[0][1]="Draw";	team[0][2]= "Algeria";	odds = new Array();	odds[0]= new Array();	odds[0][0]=1.29;	odds[0][1]=4.5;	odds[0][2]= 10;	
	team[1]= new Array();	team[1][0]="Germany ";	team[1][1]="Draw";	team[1][2]= "Serbia";		odds[1]= new Array();	odds[1][0]=1.83;	odds[1][1]=3.25;	odds[1][2]= 4;	
	team[2]= new Array();	team[2][0]="Slovenia ";	team[2][1]="Draw";	team[2][2]= "USA";		odds[2]= new Array();	odds[2][0]=3;	odds[2][1]=3.25;	odds[2][2]= 2.2;	calc();}
if (matchnumber==8) { team = new Array();	team[0]= new Array();	team[0][0]="Cameroon ";	team[0][1]="Draw";	team[0][2]= "Denmark";	odds = new Array();	odds[0]= new Array();	odds[0][0]=2.63;	odds[0][1]=3.25;	odds[0][2]= 2.38;	
	team[1]= new Array();	team[1][0]="Ghana ";	team[1][1]="Draw";	team[1][2]= "Australia";		odds[1]= new Array();	odds[1][0]=2.25;	odds[1][1]=3.25;	odds[1][2]= 2.88;	
	team[2]= new Array();	team[2][0]="Netherlands ";	team[2][1]="Draw";	team[2][2]= "Japan";		odds[2]= new Array();	odds[2][0]=1.4;	odds[2][1]=4;	odds[2][2]= 7;	calc();}
if (matchnumber==9) { team = new Array();	team[0]= new Array();	team[0][0]="Brazil ";	team[0][1]="Draw";	team[0][2]= "Ivory Coast";	odds = new Array();	odds[0]= new Array();	odds[0][0]=1.57;	odds[0][1]=3.5;	odds[0][2]= 5.5;	
	team[1]= new Array();	team[1][0]="Italy ";	team[1][1]="Draw";	team[1][2]= "New Zealand";		odds[1]= new Array();	odds[1][0]=1.14;	odds[1][1]=6;	odds[1][2]= 15;	
	team[2]= new Array();	team[2][0]="Slovakia ";	team[2][1]="Draw";	team[2][2]= "Paraguay";		odds[2]= new Array();	odds[2][0]=3.4;	odds[2][1]=3.25;	odds[2][2]= 2;	calc();}
if (matchnumber==10) { team = new Array();	team[0]= new Array();	team[0][0]="Chile ";	team[0][1]="Draw";	team[0][2]= "Switzerland";	odds = new Array();	odds[0]= new Array();	odds[0][0]=2.2;	odds[0][1]=3.25;	odds[0][2]= 3;	
	team[1]= new Array();	team[1][0]="Portugal ";	team[1][1]="Draw";	team[1][2]= "North Korea";		odds[1]= new Array();	odds[1][0]=1.17;	odds[1][1]=5.5;	odds[1][2]= 15;	
	team[2]= new Array();	team[2][0]="Spain ";	team[2][1]="Draw";	team[2][2]= "Honduras";		odds[2]= new Array();	odds[2][0]=1.17;	odds[2][1]=5.5;	odds[2][2]= 15;	calc();}
if (matchnumber==11) { team = new Array();	team[0]= new Array();	team[0][0]="France ";	team[0][1]="Draw";	team[0][2]= "South Africa";	odds = new Array();	odds[0]= new Array();	odds[0][0]=1.8;	odds[0][1]=3.4;	odds[0][2]= 4;	
	team[1]= new Array();	team[1][0]="Greece ";	team[1][1]="Draw";	team[1][2]= "Argentina";		odds[1]= new Array();	odds[1][0]=5;	odds[1][1]=3.5;	odds[1][2]= 1.62;	
	team[2]= new Array();	team[2][0]="Mexico ";	team[2][1]="Draw";	team[2][2]= "Uruguay";		odds[2]= new Array();	odds[2][0]=2.5;	odds[2][1]=3.2;	odds[2][2]= 2.6;	
	team[3]= new Array();	team[3][0]="Nigeria ";	team[3][1]="Draw";	team[3][2]= "South Korea";		odds[3]= new Array();	odds[3][0]=1.83;	odds[3][1]=3.25;	odds[3][2]= 4;	calc();}
if (matchnumber==12) { team = new Array();	team[0]= new Array();	team[0][0]="Australia ";	team[0][1]="Draw";	team[0][2]= "Serbia";	odds = new Array();	odds[0]= new Array();	odds[0][0]=3;	odds[0][1]=3.25;	odds[0][2]= 2.2;	
	team[1]= new Array();	team[1][0]="Ghana ";	team[1][1]="Draw";	team[1][2]= "Germany";		odds[1]= new Array();	odds[1][0]=4.33;	odds[1][1]=3.4;	odds[1][2]= 1.73;	
	team[2]= new Array();	team[2][0]="Slovenia ";	team[2][1]="Draw";	team[2][2]= "England";		odds[2]= new Array();	odds[2][0]=8;	odds[2][1]=4;	odds[2][2]= 1.36;	
	team[3]= new Array();	team[3][0]="USA ";	team[3][1]="Draw";	team[3][2]= "Algeria";		odds[3]= new Array();	odds[3][0]=1.73;	odds[3][1]=3.4;	odds[3][2]= 4.33;	calc();}
if (matchnumber==13) { team = new Array();	team[0]= new Array();	team[0][0]="Cameroon ";	team[0][1]="Draw";	team[0][2]= "Netherlands";	odds = new Array();	odds[0]= new Array();	odds[0][0]=4;	odds[0][1]=3.4;	odds[0][2]= 1.8;	
	team[1]= new Array();	team[1][0]="Denmark ";	team[1][1]="Draw";	team[1][2]= "Japan";		odds[1]= new Array();	odds[1][0]=2;	odds[1][1]=3.25;	odds[1][2]= 3.5;	
	team[2]= new Array();	team[2][0]="Paraguay ";	team[2][1]="Draw";	team[2][2]= "New Zealand";		odds[2]= new Array();	odds[2][0]=1.33;	odds[2][1]=4.33;	odds[2][2]= 8;	
	team[3]= new Array();	team[3][0]="Slovakia ";	team[3][1]="Draw";	team[3][2]= "Italy";		odds[3]= new Array();	odds[3][0]=6;	odds[3][1]=3.4;	odds[3][2]= 1.57;	calc();}
if (matchnumber==14) { team = new Array();	team[0]= new Array();	team[0][0]="Chile ";	team[0][1]="Draw";	team[0][2]= "Spain";	odds = new Array();	odds[0]= new Array();	odds[0][0]=5;	odds[0][1]=3.5;	odds[0][2]= 1.62;	
	team[1]= new Array();	team[1][0]="North Korea ";	team[1][1]="Draw";	team[1][2]= "Ivory Coast";		odds[1]= new Array();	odds[1][0]=10;	odds[1][1]=5.5;	odds[1][2]= 1.22;	
	team[2]= new Array();	team[2][0]="Portugal ";	team[2][1]="Draw";	team[2][2]= "Brazil";		odds[2]= new Array();	odds[2][0]=4;	odds[2][1]=3.4;	odds[2][2]= 1.8;	
	team[3]= new Array();	team[3][0]="Switzerland ";	team[3][1]="Draw";	team[3][2]= "Honduras";		odds[3]= new Array();	odds[3][0]=1.8;	odds[3][1]=3.4;	odds[3][2]= 4;	calc()};



}
function calc()
{

var total = 0;
var total1 = 0;
var total2 = 0;
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][2];
side6 = team[i][1];
tot = total;
tot2 = totalx;
total11 = odds[i][0];
total22 = odds[i][1];
total33 = odds[i][2];
totalx = total11 + total22 + total33;

hometeam = Math.round(((totalx / total11)/totalx)  * (Math.random() * 7));
awayteam = Math.round(((totalx / total33)/totalx)  * (Math.random() * 7));

if(hometeam > awayteam)
{
	winner = side4;
}
else if(awayteam > hometeam)
{
	winner = side5;
}
else
{
	winner = side6;
}



var odds4 = odds[i][0];
var odds5 = odds[i][2];
var odds6 = odds[i][1];
 

var res = side4 + " <strong>" + hometeam + "</strong>  v  " + side5 + "  <strong>" + awayteam + "</strong> <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 = "";
}
}

