function showForm()
{	
	if ( document.getElementById("form").style.display == "block" )
	{
		document.getElementById("form").style.display = "none";
		document.getElementById("ïnstructions").style.display = "block";
	}
	else
		{
			document.getElementById("form").style.display = "block"
			document.getElementById("ïnstructions").style.display = "none";
		}
}

var locker = new Array();

function addLocker(id_video)
{
	this.locker[id_video] = false;
}

function rate(id_video, rate, video_pos)
{    
	$.post("index.php/videos/rate_video/" + id_video + "/" + rate, { func: "rate_video" },
	  	function(ret){
                if ( ret[0] == false )
					{
						$("#retorno_"+id_video).html("Already Rated");
					}
					else
						{
							$("#retorno_"+id_video).html("Thanks for rating.");
							$("#score_"+id_video).html("Rating: " + ret[1] + " ");
						}
					}, "json");
	
	
    /*$.getJSON($("base").attr("jshref") + '/videos/rate_video/' + id_video+ "/" + rate,
	               function(ret){
	                      if ( ret[0] == false )
							{
								$("#retorno_"+id_video).html("Already Rated");
							}
							else
								{
									$("#retorno_"+id_video).html("Thanks for rating.");
									$("#score_"+id_video).html("Rating: " + ret[1] + " ");
								}
	               });*/
	addLocker(video_pos);
	setRate(rate, id_video);

}

function setStars(number, video_pos)
{
	if ( this.locker[video_pos] != false )
	{

		for(i = 1; i <= 5; i++)
		{
			if ( i <= number )
			{
				$(".star"+i+"_"+video_pos).html("<img src='public/img/star.jpg' alt='"+i+"' />");
			}
			else
				{
					$(".star"+i+"_"+video_pos).html("<img src='public/img/star-gray.jpg' alt='"+i+"' />");
				}
		}
	}

}

function cleanStars(video_pos, rate)
{
	if(this.locker[video_pos] != false )
	{
		for(i = 1; i <= 5; i++)
		{
			$(".star"+i+"_"+video_pos).html("<img src='public/img/star-gray.jpg' alt='"+i+"' />");
		}
	}
	
}

function setRate(rate, video_id)
{
	if ( this.locker[video_id] == false  )
	{
		for(i = rate+1; i <= 5; i++)
		{
			$(".star"+i).html("<img src='public/img/star-gray.jpg' alt='"+i+"' />");
		}
	}
}

function toogleSkip(action)
{
	var obj = document.getElementById('skip');
	if (action == 'over')
	{
		obj.src = 'public/img/skipthis-hover.jpg';
	}
	if (action == 'out')
	{
		obj.src = 'public/img/skipthis.jpg';
	}
}