function predictAnimate(data) {
	
	// **** P1 ****
	if(currCtrl == 'overview' || currCtrl == 'predictions') {
	if(currMod == 'pregame' || currMod == 'live') {	
		
		var predictHome;
		var predictDraw;
		var predictAway;
		
		
		
		//dataset
		if(data == 0) {
			if(currCtrl == 'youpredict') {
				predictHome = 1;
				predictDraw = 98;
				predictAway = 1;
			} else {
				predictHome = parseFloat(predict[data][0]);
				predictDraw = parseFloat(predict[data][1]);
				predictAway = parseFloat(predict[data][2]);
			}

		} else {
			var newData;
			if(typeof data == 'string')
				eval("newData = " + data);
			else
				newData = data;
				
			if(newData.data == undefined) {
				//invalid prediction
				msg("<strong>Important:</strong> Invalid prediction response. We've been notified. Please try again later.",1);
				$("#p-text").html('<strong>' + homeTeam + '</strong> to win match.');
				predictHome = 1;
				predictDraw = 98;
				predictAway = 1;
			} else {
				predictHome = Math.round(parseFloat(newData['data']['1'])*100);
				predictDraw = Math.round(parseFloat(newData['data']['X'])*100);
				predictAway = Math.round(parseFloat(newData['data']['2'])*100);
                                if (predictHome == 100)
                                {
                                    predictDraw = 1;
                                    predictAway = 1;
                                    predictHome = 98;
                                }
                                if (predictDraw == 100)
                                {
                                    predictHome = 1;
                                    predictAway = 1;
                                    predictDraw = 98;
                                }
                                if (predictAway == 100)
                                {
                                    predictDraw = 1;
                                    predictHome = 1;
                                    predictAway = 98;
                                }


			}
		}
		
		var max = Math.max(predictHome,predictAway,predictDraw);

		switch(max) {
			case predictHome:
				updatePredictionText(1,predictHome);
				break;
			case predictDraw:
				updatePredictionText(3,predictDraw);
				break;
			case predictAway:
				updatePredictionText(2,predictAway);
				break;
		}
		
		var predictHomeWidth = predictHome;
		var predictDrawWidth = predictDraw;
		var predictAwayWidth = predictAway;	
	
		
		//zeros?
		//home
		if(predictHome > 0) { 
			$("#predict-p1-home .percent").text(predictHome+'%');
		} else {
			if(predictDraw > predictAway) {
				predictDrawWidth = (predictDraw)-1+'%';
			} else {
				predictAwayWidth = (predictAway-1)+'%';
			}
			predictHomeWidth = 1;
		}


		//draw
		if(predictDraw > 0) { 
			$("#predict-p1-draw .percent").text(predictDraw+'%');
		} else {
			if(predictHome > predictAway) {
				predictHomeWidth = (predictHome-1)+'%';
			} else {
				predictAwayWidth = (predictAway-1)+'%';
			}
			predictDrawWidth = 1;
		}
		
		//away
		if(predictAway > 0) { 
			$("#predict-p1-away .percent").text(predictAway+'%');
		} else {
			if(predictHome > predictDraw) {
				predictHomeWidth = (predictHome-1)+'%';
			} else {
				predictDrawWidth = (predictDraw-1)+'%';
			}
			
			predictAwayWidth = 1;
		}


		//above 100?
		if(((predictHomeWidth + predictDrawWidth) + predictAwayWidth) > 100) {
			if((predictHomeWidth > predictDrawWidth) && (predictHomeWidth > predictAwayWidth)) {
				predictHomeWidth = predictHomeWidth-1;
			}
			if((predictDrawWidth > predictHomeWidth) && (predictDrawWidth > predictAwayWidth)) {
				predictDrawWidth = predictDrawWidth-1;
			}
			if((predictAwayWidth > predictHomeWidth) && (predictAwayWidth > predictDrawWidth)) {
				predictAwayWidth = predictAwayWidth-1;
			}
		}




		//clean up
		predictHomeWidth = parseFloat(predictHomeWidth)+'%';
		predictDrawWidth = parseFloat(predictDrawWidth)+'%';
		predictAwayWidth = parseFloat(predictAwayWidth)+'%';

		predictHomeWidthClean = parseFloat(predictHomeWidth);
		predictDrawWidthClean = parseFloat(predictDrawWidth);
		predictAwayWidthClean = parseFloat(predictAwayWidth);




		//animate	
		$("#predict-p1-home").animate({ 
	      width: predictHomeWidth
	     }, 2000, function () {
			if(predictHome > 2) {
				$(":first",this).fadeIn();
			}
		}
		);

		
		$("#predict-p1-draw").css({ 
			paddingLeft: predictHomeWidth,
			paddingRight: predictAwayWidth,
			width: predictDrawWidth
		});
		
		
		$("#predict-p1-away").animate({ 
	      width: predictAwayWidth
	     }, 2000, function () {
			if(predictAway > 2) {
				$(":first",this).fadeIn();
			}
			
			if(predictDraw > 2) {
				$("#predict-p1-draw :first").fadeIn();
			}
			
			//position icons
			$("#predict-icon-X").css("left",(predictHomeWidthClean+0.5)+"%");
			$("#predict-icon-2").css("left",((predictHomeWidthClean+predictDrawWidthClean)+0.5)+"%");

			//show icons?
			if(predictHome > 7) { $("#predict-icon-1").show(); }
			if(predictDraw > 7) { $("#predict-icon-X").show(); }		
			if(predictAway > 7) { $("#predict-icon-2").show(); }		
			
		}
		);
		
		
		
		
		
		
		
		

		//decimal
		var decimalHome = (100 / parseFloat(predictHome)).toFixed(2);
		var decimalDraw = (100 / parseFloat(predictDraw)).toFixed(2);
		var decimalAway = (100 / parseFloat(predictAway)).toFixed(2);
	
		$("#predict-p1-home .decimal").text( decimalHome );
		$("#predict-p1-draw .decimal").text( decimalDraw );
		$("#predict-p1-away .decimal").text( decimalAway );


		//fraction
		//var fractionHome = fractionalFromDecimal(decimalHome);
		//var fractionDraw = fractionalFromDecimal(decimalDraw);
		//var fractionAway = fractionalFromDecimal(decimalAway);
		
		$("#predict-p1-home .fraction").text( "Soon" );
		$("#predict-p1-draw .fraction").text( "Soon" );
		$("#predict-p1-away .fraction").text( "Soon" );

	
	}
	}
	

}







function updatePredictionText(result,percent) {
	
	var homeTeam = $(".teams #team-home .team-name").text();
	var awayTeam = $(".teams #team-away .team-name").text();
	
	//live?
	if(currMod == "pregame") {
		var shareTwitter = "Get+In+Statistical+Prediction:+";
	} else {
		var homeScore = $("#home-score").text();
		var awayScore = $("#away-score").text();
		var shareTwitter = "Get+In+LIVE+Prediction+%28"+homeScore+"-"+awayScore+"%29:+";
	}


	if(result == 1) {
		$("#p-text").html('<strong>' + homeTeam + ' to win match.</strong> ');
		var shareTwitter = shareTwitter + homeTeam + "+to+win+match+vs.+"+awayTeam+"!+("+percent+"%+chance)";
				
	} else if(result == 2) {
		$("#p-text").html('<strong>' + awayTeam + ' to win match.</strong>');
		var shareTwitter = shareTwitter + awayTeam + "+to+win+match+vs.+"+homeTeam+"!+("+percent+"%+chance)";

	} else {
		$("#p-text").html('<strong>Draw</strong>');
		var shareTwitter = shareTwitter + "Draw+between+"+homeTeam+"+vs.+"+awayTeam+"!+("+percent+"%+chance)";
	}
	
	
	//add url
	if(currMod == "pregame") { var twitterURL = "p"; } else { var twitterURL = "l"; }
	var shareTwitter = shareTwitter + "+www.getinlive.com/"+twitterURL+"/"+currMatch;
	$("#shareTwitter").attr("href","http://twitter.com/?status="+shareTwitter+"+%23getin");
	
}

function getNewPrediction(homePlayers, awayPlayers) {
	data = '';
	homePlayers = homePlayers.join('#');
	awayPlayers = awayPlayers.join('#');
	
	if(homePlayers.length > 0) {
		if(awayPlayers.length > 0) {
			data = encodeURIComponent('Home team Initial lineup') + '=5;' + encodeURIComponent(homePlayers) + '&' + encodeURIComponent('Away team Initial lineup') + '=5;' + encodeURIComponent(awayPlayers);
		} else {
			data = encodeURIComponent('Home team Initial lineup') + '=5;' + encodeURIComponent(homePlayers);
		}
	} else {
		encodeURIComponent('Away team Initial lineup') + '=5;' + encodeURIComponent(awayPlayers);
	} 


	$.ajax({
		type: 'GET',
		url: '',
		data: data,
		success: function(msg) {
				predictAnimate(msg);
			}
	});
}

