// JavaScript Documentfunction profitRewards(){	var profitGoal = parseInt(document.getElementById('profitGoal').value);	var previousPeriod = parseInt(document.getElementById('previousPeriod').value);	var percentGain = parseInt(document.getElementById('percentGain').value) / 100;	var totalParticipants = parseInt(document.getElementById('totalParticipants').value);	var meetSalesGoal = parseInt(document.getElementById('meetSalesGoal').value) / 100;	var error = 0;	if( isNaN(profitGoal) )	{		alert("Please provide a sales or gross profit gaol.");		document.getElementById('profitGoal').focus();		error = 1;	}	else if( isNaN(previousPeriod) )	{		alert("Please provide the previous period actual");		document.getElementById('previousPeriod').focus();		error = 1;	}	else if( isNaN(percentGain) )	{		alert("Please provide the percent of gain used for rewards.");		document.getElementById('percentGain').focus();		error = 1;	}	else if( isNaN(totalParticipants) )	{		alert("Please provide the total number of participants");		document.getElementById('totalParticipants').focus();		error = 1;	}	else if( isNaN(meetSalesGoal) )	{		alert("Please provide the anticipated % of participants that will meet the sales goal.");		document.getElementById('meetSalesGoal').focus();		error = 1;	}	if( !error )	{		var gain = 0;		var amountForRewards = 0;		var netGain = 0;		var rewardValue = 0;				if( (profitGoal > 0) && (previousPeriod > 0) )		{			gain = (profitGoal - (previousPeriod) );		}				if( (percentGain > 0) )		{			amountForRewards = (gain * (percentGain) );		}		if( (meetSalesGoal > 0) && (totalParticipants > 0) )		{			rewardValue = (amountForRewards/(meetSalesGoal * totalParticipants) ) ;		}				netGain = (gain - (amountForRewards) ) ;		document.getElementById('gain').innerHTML=gain.toFixed(0);		document.getElementById('amountForRewards').innerHTML=amountForRewards.toFixed(0);		document.getElementById('netGain').innerHTML=netGain.toFixed(0);		document.getElementById('rewardValue').innerHTML=rewardValue.toFixed(0);	}}
