// PlayItOnTheWeb Ajax Functions
// Copyright 2007 PlayItOnTheWeb.com

function rateFill(num){
	var div;
	var icostar=document.getElementById("icostar");
	var icostarh=document.getElementById("icostarh");
	for (var i=1;i<=10;i++){
		div=document.getElementById("rate"+i);
		div.innerHTML = (i<=num) ? icostar.innerHTML : icostarh.innerHTML;
	}
}
function ajaxRate(gameid,rating){
	theDoc.getElementById('ratewrap').innerHTML='Submitting rating...';
	ajaxEnqueue('rate',gameid+'_'+rating);
}
function ajaxEmail(gameid){
	var a=theDoc.getElementById('emailmyname').value.replace(/_/,'');
	var b=theDoc.getElementById('emailfemail').value.replace(/_/,'');
	var c=theDoc.getElementById('emailmsg').value.replace(/_/,'');
	var d=theDoc.getElementById('human').value.replace(/_/,'');
	theDoc.getElementById('email1').style.display='none';
	theDoc.getElementById('email2').style.display='inline';
	theDoc.getElementById('email2').innerHTML='Sending email...';
	ajaxEnqueue('email',a+'_'+b+'_'+c+'_'+d+'_'+gameid);
}
function ajaxEmailReset(){
	theDoc.getElementById('email2').style.display='none';
	theDoc.getElementById('email1').style.display='inline';
}
function ajaxFlag(gameid){
	var a,b;
	var f=document.flagform;
	for (var i=0;i<f.flagsubject.length;i++){
		if (f.flagsubject[i].checked) a=f.flagsubject[i].value.replace(/_/,'');
	}
	b=theDoc.getElementById('flagcomments').value.replace(/_/,'');
	theDoc.getElementById('flag1').style.display='none';
	theDoc.getElementById('flag2').style.display='inline';
	theDoc.getElementById('flag2').innerHTML='Submitting report...';
	ajaxEnqueue('flag',gameid+'_'+a+'_'+b);
}
function ajaxFlagReset(){
	theDoc.getElementById('flag2').style.display='none';
	theDoc.getElementById('flag1').style.display='inline';
}
function ajaxFav(gameid,toggle){
	theDoc.getElementById('mark1').style.display='none';
	theDoc.getElementById('mark2').style.display='inline';
	theDoc.getElementById('mark2').innerHTML='Updating favorites...';
	ajaxEnqueue('fav',gameid+'_'+toggle);
}
function ajaxFavReset(){
	theDoc.getElementById('mark2').style.display='none';
	theDoc.getElementById('mark1').style.display='inline';
}
function ajaxToggle(idprefix){
	var wrap=theDoc.getElementById(idprefix+'wrap');
	var toggle=theDoc.getElementById(idprefix+'toggle');
	if (toggle.innerHTML.indexOf('down')>-1){
		wrap.style.display='none'; toggle.innerHTML=bulletgo;
	} else {
		wrap.style.display='inline'; toggle.innerHTML=bulletdown;
	}
}
