/*Star ratings*/
function starSwap(STAR) {
  for(i=1;i<=STAR;i++) {
    if(i<STAR) imageSwap("star_"+i,"theme/star.gif");
    else imageSwap("star_"+i,"theme/star_hi.gif"); 
  }
  if(STAR<5) {for(i=STAR+1;i<=5;i++) imageSwap("star_"+i,"theme/star_off.gif");}
  if(STAR==0) getId('rating_info').innerHTML="Click a star to rate";
  else getId('rating_info').innerHTML=STAR+" Stars"; 
}

function starSubmit(STAR,GAME) {
  getId('rating_info').innerHTML="Please Wait ...";
  ajaxpack.get("game-goto.php?cmd=rate&gen=y&r="+STAR+"&g="+GAME,"ajax_rating_fav");
}

function favSubmit(GAME,STAR) {
  getId('fav_info').innerHTML="Please Wait ...";
  ajaxpack.get("game-goto.php?cmd=fav&gen=y&g="+GAME,"ajax_rating_fav");
}

function watchSubmit(GAME) {
  ajaxpack.get("game-goto.php?cmd=watch&gen=y&g="+GAME,"ajax_watch");
}

function reviewSubmit(GAME) {
  document.review.chat_text.value=trim(document.review.chat_text.value);
  if(document.review.chat_text.value.length<=3) {
	  alert("Please enter a review more than 3 letters.");
	  return false;
  }
  else if(document.review.chat_text.value.length>300) {
	  alert("Please enter a review less than 300 letters.");
	  return false;
  }
  else if(check_badwords(document.review.chat_text.value)==false) {
    alert("Please do not use curse words when writing your review.");
    return false;
  }
  else if(check_longwords(document.review.chat_text.value)==false) {
    alert("Please do not use super long words when writing your review.");
    return false;
  }

  getId('ajax_review_wait').innerHTML='<IMG SRC="theme/ajax_loader.gif" BORDER="0" ALIGN="ABSMIDDLE" WIDTH="16" HEIGHT="16"/> Please wait while submitting review ...';
  document.review.chat_text.disabled=true;
  document.review.chat_text.style.backgroundColor="#F0F0F0";
  document.review.chat_text.style.color="#808080";
  var params="chat_text="+encodeURI(document.review.chat_text.value);
  ajaxpack.post("game-review.php?cmd=go&mode=ajax&g="+GAME,params,"ajax_review_wait");
  buttonDisable("review","but_submit");
  return true;
}
