
function getRating(){
	var rateReq;  // The variable that makes Ajax possible
	
	try {
		// Opera 8.0+, Firefox, Safari
		rateReq = new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer Browsers
		try{
			rateReq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				rateReq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				// Something went wrong
				return false;
			}
		}
	}
	
	rateReq.open('GET','get_rating.php', true);
	
	// Create a function that will receive data sent from the server
	rateReq.onreadystatechange = function() {
		if(rateReq.readyState == 4){
              ratingJscript = rateReq.responseText;
              // the all-important eval function
              eval(ratingJscript);
              
              
              //update vote, rating total in infowindow
              var ratingText = '';
              ratingText += '<h3 style="text-align:center;">Thank you for your submission</h3>';
              ratingText += '<p style="text-align:center;margin-bottom:10px;">You submitted an emissions total of <strong>' + document._calculator.TotalEmissions.value + '</strong>.</p>';
//the variable 'number' holds the number of submissions.
              ratingText += '<p style="text-align:center;">Based on <strong>' + number + '</strong> submissions to our database, <br />the average number of pounds of carbon dioxide used per year is:<br /> <strong style="font-size:1.5em">' + average + '</strong>.</p>';
              var resultsDiv = document.getElementById('submitResults');
              var html = ''; 
              html += '<td colspan="4">';
              html += ratingText;
              html += '</td>';
              
              
              resultsDiv.innerHTML = html;

		}
	}
	rateReq.send(null); 
	
}
