// JavaScript Document

function ajaxFunction() {
	var ajax;
	try {
		ajax = new XMLHttpRequest();
	} catch (e) {
		try {
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				ajax = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return ajax;
}

function showRateBox(show) {
	var tag = document.getElementById("ratingBox");
	if (show == 1) {
		tag.style.display = "block";
	} else {
		tag.style.display = "none";
	}
}

function rateGame(gameid,vote) {
	ajax = ajaxFunction();
	ajax.onreadystatechange = function () { rateGame_stateChanged(); };
	var url = baseDir+ "inc/ajax-rating.php";
	url = url+ "?id=" +gameid;
	url = url+ "&vote=" +vote;
	ajax.open("GET",url,true);
	ajax.send(null);
}
function rateGame_stateChanged() { 
	var rateBox = document.getElementById('rateBox');
	if (ajax.readyState == 4) {
		rateBox.innerHTML = ajax.responseText;
	}
}

//the function below reloadAds() (line 47 - 59) refreshes all iframe ads once every minute to a max of 6 times (configurable below by "delay =" and "refresh_count="
//function reloadAds(first, refresh){
//	delay = 1; //refresh delay in minutes 
//	refresh_count = 6; // max amount of refreshes
//	if (refresh_count > refresh){
//		refreshed = refresh + 1;
//		setTimeout("reloadAds(false, refreshed)", delay*60*1000); 
//			if (!first) {
//				ads = document.getElementsByName("ad");for(var i=0; i<ads.length; i++) 
//					{ads[i].src = ads[i].src;
//					}
//				}
//			}
//}
//launch reloadAds() on pageload
//window.onLoad = reloadAds(true, 0); //remove or comment out this line to disable reloadAds() from running

