
function linksReporting(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=400, height=380,left = 320,top = 272');");
}

function getStarNum(movie_id, star)
{
	window.location = 'reporting.php?movrating=&movid'+movie_id+'&star='+star;	 
}

// update movie rating
function sendRating(movieID, starNum, type)
	{
		var xmlhttp;
		var countUp = "add=" + starNum + "&movieID=" + movieID + "&type=" + type;
		
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		  xmlhttp.onreadystatechange=function()
		  {
		  if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {
		    document.getElementById("currentMovieRating").innerHTML=xmlhttp.responseText;
		    }
		  }
		xmlhttp.open("GET","updateRating.php?"+countUp,true);
		xmlhttp.send(null);
	}


function chengeBack(star_id)
{
	for(var i=1; i<=5; i++)
	{
		if(i <= star_id)
		{
			document.getElementById(i).style.backgroundImage="url('template/star_1.gif')";
		}
		else
		{
			document.getElementById(i).style.backgroundImage="url('template/star_2.gif')";
		}
	}
}
function chengeBackOut(star_id)
{
    for(var i=5; i>0; i--)
	{
		if(i > star_id)
		{
			document.getElementById(i).style.backgroundImage="url('template/star_2.gif')";
		}
		else
		{
			document.getElementById(i).style.backgroundImage="url('template/star_1.gif')";
		}
	}
}
