function GetPoint(rating, coeff) {
	if (rating<=1500) {
		var points=coeff*(0.22*rating+14);
		if (points <= 0) {
			return 0;
		}else{
			return parseInt(points, 10);
		}
	}else{
		return parseInt(coeff*(1511.26/(1+1639.28*Math.pow(2.71828, -0.00412*rating))), 10);
	}
}

function GetRating(points, coeff) {
	var rating = parseInt(Math.log((1511.26/(1639.28*points/coeff))-(1/1639.28))/(-0.00412),10);
	if (rating <= 1500) {
		return parseInt(((points/coeff)-14)/0.22,10);
	}else{
		return rating;
	}
}
function RatingToPoints() {
	var rating = parseInt(document.getElementById("rating_22").value,10);
	if (rating > 0 && rating <= 4000) {
	  document.getElementById("points_22").value = GetPoint(rating, 0.76);
	}else{
	  document.getElementById("points_22").value = 'Invalid Value';
	}

	rating = parseInt(document.getElementById("rating_33").value,10);
	if (rating > 0 && rating <= 4000) {
	  document.getElementById("points_33").value = GetPoint(rating, 0.88);
	}else{
	  document.getElementById("points_33").value = 'Invalid Value';
	}

	rating = parseInt(document.getElementById("rating_55").value,10);
	if (rating > 0 && rating <= 4000) {
	  document.getElementById("points_55").value = GetPoint(rating, 1);
	}else{
	  document.getElementById("points_55").value = 'Invalid Value';
	}
}
function PointsToRating() {
	var points = parseInt(document.getElementById("pts").value,10);
	
	rating = GetRating(points, 0.76);
	if (rating > 0 && rating < 4000) {
		document.getElementById("rat_22").value = rating;
	}else{
		document.getElementById("rat_22").value = 'Not Possible';
	}

	rating = GetRating(points, 0.88);
	if (rating > 0 && rating < 4000) {
		document.getElementById("rat_33").value = rating;
	}else{
		document.getElementById("rat_33").value = 'Not Possible';
	}

	rating = GetRating(points, 1);
	if (rating > 0 && rating < 4000) {
		document.getElementById("rat_55").value = rating;
	}else{
		document.getElementById("rat_55").value = 'Not Possible';
	}
	
}