$(function() {
  $('.ui-link-button, .ui-button').hover(
	function() { $(this).addClass('ui-state-hover'); },
	function() { $(this).removeClass('ui-state-hover'); }
)}); 

function OpenTrailer(movieid) {
	$('<div />').dialog({
		title: 'Viewing trailer!',
		bgiframe: true, 
		modal: true,
		resizable: false,
		width: 512,
		position: ['center',200],
		draggable: false,
		buttons: {}
	}).load('/ajax/loadtrailer.php?movieid='+ movieid);
}

function SaveRating(movieid, rating) {
	$.get('/ajax/saverating.php', {movieid: movieid, rating: rating});
	$('#giverating'+ movieid).hide();
	$('<div />').dialog({
		title: 'Thanks for rating!',
		bgiframe: true,
		modal: true,
		resizable: false,
		width: 512,
		position: ['center',200],
		draggable: false,
		buttons: {
			'Close': function() {
				$(this).dialog('close');
				}
		}
	}).load('/ajax/justrated.php?movieid='+ movieid +'&rating='+ rating);
}

function EditRating(movieid) {
	$('<div />').dialog({
		title: 'Edit your rating',
		bgiframe: true,
		modal: true,
		resizable: false,
		width: 512,
		position: ['center',200],
		draggable: false,
		buttons: {
			'Cancel': function() {
				$(this).dialog('close');
				}
		}
	}).load('/ui/editrating.php?movieid='+ movieid);
}

function DrawStars(total, count, callback) {
	
}

function ClearRating(movieid) {
	$.get('/ajax/clearrating.php', {movieid: movieid});
	$('#giverating'+ movieid).show();
	$('#myrating'+ movieid).hide();
}


function WantToSee(movieid) {
	$.get('/ajax/savemeta.php', {movieid: movieid, meta: 'wanttosee'});
	$('#metabar'+ movieid).hide();
}

function DontRemember(movieid) {
	$.get('/ajax/savemeta.php', {movieid: movieid, meta: 'dontremember'});
	$('#metabar'+ movieid).hide();
}

function NotInterested(movieid) {
	$.get('/ajax/savemeta.php', {movieid: movieid, meta: 'notinterested'});
	$('#metabar'+ movieid).hide();
}