var ajax = new sack();
var review_id = 0;
var star_x = 0; // variable to hold the number of stars currently selected
var my_vote = 0;

function showContent()
{
	if (review_id == 0) {
	  get_review_id();
	}
	else {
      
	}
    get_review_avg();
}

function showWaitMessage()
{
	document.getElementById('contentContainer').innerHTML = '<img src="/js/updatefield/loading.gif" title="Working...">';
}

function set_review_avg()
{
    var review_avg = ajax.response;
	star_x = Math.round(review_avg);
    showstars(star_x, false);
}

// Show number of star equal to x, and if change appearance if hovering
function showstars(x, hover){
  if (hover) { 
    star_src = '/images/global/votingstar_hover.gif';
  }
  else {
    star_src = '/images/global/votingstar.gif';
  }
  for (i = 1; i <= 5; i++) {
    if (x >= i) {
	  document.getElementById('star_' + i).src = star_src;
	}
	else
	{
        if(i <= star_x){
	        document.getElementById('star_' + i).src = '/images/global/votingstar.gif';
        }else{
            document.getElementById('star_' + i).src = '/images/global/votingstar_empty.gif';
        }
	}  
  }
}

// When star is clicked, set the variable holding the current stars
function clickstar(x){
  my_vote = x;
}

