function GetXmlHttpObject(){ var xmlHttp=null; try { xmlHttp=new XMLHttpRequest(); } catch (e) { try  { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }

function updateRank(rating,movie_num,movie_id,facebook_id)
{
	xmlHttp = GetXmlHttpObject();

	if(xmlHttp == null)
	{
		alert("Browser does not support HTTP Request");
		return;
	} 
	var   url="http://www.allentheatresinc.com/facebook/rate/ajax_php/update_rank.php?"
	url	= url+"movie_num="+ movie_num
	url	= url+"&rating="+ rating 
	url	= url+"&facebook_id="+ facebook_id 
	url	= url+"&sid="+Math.random()
	 
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{ 
			//document.getElementById('mls_rating_' + mls_num).innerHTML = xmlHttp.responseText; 
			//setTimeout("clearDiv('"+mls_num+"')",5000);
			rating = rating * 25;
			document.getElementById('current_rating_'+ movie_num).style.width = rating+'px';
			update_total_votes(movie_num);
			if(rating != 0)
			{
				document.getElementById('no_rating_' + movie_num).style.display = 'block';
			}
			else
			{
				document.getElementById('no_rating_' + movie_num).style.display = 'none';
			}
			
		}  
	}   
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
	
} 
function updateRank2(rating,movie_num,movie_id,facebook_id)
{
	xmlHttp = GetXmlHttpObject();

	if(xmlHttp == null)
	{
		alert("Browser does not support HTTP Request");
		return;
	} 
	
	var   url="http://www.allentheatresinc.com/facebook/rate/ajax_php/update_rank.php"
	url	= url+"?facebook_id="+ facebook_id
	url	= url+"&movie_num="+ movie_num
	url	= url+"&rating="+ rating 
	url	= url+"&sid="+Math.random()
	 
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{ 
			//document.getElementById('mls_rating_' + mls_num).innerHTML = xmlHttp.responseText; 
			//setTimeout("clearDiv('"+mls_num+"')",5000);
			rating = rating * 25;
			document.getElementById('current_rating_'+ movie_num).style.width = rating+'px';
			update_total_votes(movie_num);
			
			var new_url = "http://www.allentheatresinc.com/facebook/index.php?movie_num=" + movie_num + "&publish_to_facebook=true"
			//alert(new_url);
			
	window.location = new_url;
										  
			
		}  
	}   
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
} 
function update_total_votes(movie_num)
{
	xmlHttp = GetXmlHttpObject();

	if(xmlHttp == null)
	{
		alert("Browser does not support HTTP Request");
		return;
	}  
	
	var   url="http://www.allentheatresinc.com/facebook/rate/ajax_php/show_new_total_votes.php"
	url	= url+"?movie_num="+ movie_num
	url	= url+"&sid="+Math.random()
	 
	xmlHttp.onreadystatechange = function()
	{
		if(xmlHttp.readyState == 4)
		{  
			document.getElementById('total_votes_' + movie_num).innerHTML = xmlHttp.responseText;  
			//alert(xmlHttp.responseText);
		}  
	}   
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null); 
} 