jQuery(document).ready(function() {
	  predict();
});

function predict()
{
	$('#wprob,#tprob,#lprob').animate({"width": "0%"}, 300);
	$('#ttxt').html("Tie Probability: ?");
	$('#wtxt,#ltxt').html("Win Probability: ?");

	var $ht = $('#hometeam')[0].options[$('#hometeam')[0].selectedIndex].value;
	var $at = $('#awayteam')[0].options[$('#awayteam')[0].selectedIndex].value;
	var $qdata = "hometeam=" + $ht + "&awayteam=" + $at;

	$.ajax({
		type: "POST",
		url: "query",
		data: $qdata,
		cache: false,
		success: function(d){
			displayprob(d);
		}
	});
}

function displayprob(d)
{
	var $arr = d.split(" ");
	
	var $v1 = $arr[0];
	var $v2 = $arr[1];
	var $v3 = $arr[2];

	$('#wprob').animate({width: $v1}, 300);
	$('#tprob').animate({width: $v2}, 300);
	$('#lprob').animate({"width": $v3}, 300);
	$('#wtxt').html("Win: " + $v1);
	$('#ttxt').html("Tie: " + $v2);
	$('#ltxt').html("Win: " + $v3);
}
