<!--
var gameRating = {
	setCookie:false, curGame:'',
	
	writeRating:function(o) {
		var displaytxt = 'your browser doesn\'t support this javascript, please upgrade to see this correctly';
	  var response = o.responseText;
		if(gameRating.setCookie)
			createCookie(gameRating.curGame + 'freearcade', 'voted', 14, 'freearcade.com');
		if(response != 'e') {
			response = response.split(';');
			document.getElementById('current-rating').style.width = response[0] + 'px';  
			displaytxt = 'current rating: ' + response[1] + '/' + response[2] + ' votes';
	  } else {
			displaytxt = 'the ratings are down for maintenance';
			gameRating.writeTxt('try again later', 'thanks');
		}
	  gameRating.writeTxt(displaytxt, 'details');
	},
	handleFailure:function(o) {
		alert('Whoops, your rating request failed!\nTry closing the browser and trying again.');
	},
	getRating:function(game) {
	  gameRating.curGame = game.toLowerCase(); gameRating.curGame = gameRating.curGame.replace(/ /g,"");
		var request = YAHOO.util.Connect.asyncRequest('POST', '/gatherRatings.php', callback, "scre=0&gm=" + encodeURI(gameRating.curGame));
	  if(readCookie(gameRating.curGame + 'freearcade'))
	    gameRating.writeTxt('you already voted!', 'thanks');
	  else
	    gameRating.writeTxt('rate this game!', 'thanks');
	},
	sendRate:function(value) {
		if(!readCookie(gameRating.curGame + 'freearcade')) {
			var request = YAHOO.util.Connect.asyncRequest('POST', '/gatherRatings.php', callback, "scre=" + encodeURI(value) + "&gm=" + encodeURI(gameRating.curGame));
			gameRating.setCookie = true;
			gameRating.writeTxt('thanks for voting!', 'thanks');
		} else gameRating.writeTxt('you already voted!', 'thanks');
	},
	writeTxt:function(displayText, id) {
	  var txtnode = document.getElementById(id);
	  txtnode.innerHTML = displayText;
	}
};

/*
 * Define the callback object for success and failure
 * handlers as well as object scope.
 */
var callback = {
	success: gameRating.writeRating,
	failure: gameRating.requestFailed,
	scope: gameRating
};

// general site-wide functions
function createCookie(name, value, days, domain) {
  if(days) {
    var date = new Date();
    date.setTime(date.getTime() + (days*24*60*60*1000));
    var expires = "; expires=" + date.toGMTString();
  }
  else var expires = "";
  document.cookie = name + "=" + value + expires + "; path=/; domain=" + domain;
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i = 0;i < ca.length;i++) {
    var c = ca[i];
    while(c.charAt(0)==' ') c = c.substring(1, c.length);
      if(c.indexOf(nameEQ) == 0) return(true);//return(c.substring(nameEQ.length, c.length));
  }
  return(false);
}

/* used for the search box */
function clearTxtBox(box) {
  if(box.value == box.defaultValue) {
    box.value = '';
  }
}
function populateTxtBox(box) {
  if( box.value == '') {
  	box.value = 'enter game name';
  }
}

// -->
