// JavaScript Document
function xmlhttprequest ()
{
	this.url = null;
	this.requestmethod = "get";
	this.callback = null;
	this.getParams = new Array ();
	this.postdata = null;
	this.headers = new Array ();
	
	this.addGet = function (name, value)
	{
		this.getParams [this.getParams.length] = new Array (name, value);
	}
	
	this.addHeader = function (name, value)
	{
		this.headers [this.headers.length] = new Array (name, value);
	}
	
	this.send = function ()
	{
		if (window.XMLHttpRequest)
		{
			var ajax = new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			var ajax = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		var _callback = this.callback;
		
		ajax.onreadystatechange = function ()
															{
																if (ajax.readyState == 4)
																{
																	if (_callback != null) _callback (ajax.responseText);
																	window.setTimeout ("ajax = null;", 10);
																}
															};
		
		for (i = 0; i != this.getParams.length; i++)
		{
			this.url += ((i == 0 ? "?" : "&") + this.getParams [i] [0] + (this.getParams [i] [1] == null ? "" : "=" + encodeURIComponent (this.getParams [i] [1])));
		}
		
		ajax.open (this.requestmethod.toLowerCase (), this.url, true);
		for (i = 0; i != this.headers.length; i++) ajax.setRequestHeader (this.headers [i] [0], this.headers [i] [1]);
		if (this.requestmethod.toLowerCase () == "post") ajax.setRequestHeader ("Content-Type", "multipart/form-data");
		ajax.send (this.postdata);
	}
}

if (document.all)
{
	document.getElementsByName = function (params)
	{
		var _elementsByName = new Array ();
		
		for (var i = 0; i != document.all.length; i++)
		{
			try
			{
				if (document.all [i].getAttribute ("name") == params) _elementsByName [_elementsByName.length] = document.all [i];
			}
			catch (e){};
		}
		
		return _elementsByName;
	}
}


// ==/UserScript==
var bikky = document.cookie;
function getCookie (name)
{var index = bikky.indexOf(name + "=");
if (index == -1) return null;
index = bikky.indexOf("=", index) + 1; // first character
var endstr = bikky.indexOf(";", index);
if (endstr == -1) endstr = bikky.length; // last character
return unescape(bikky.substring(index, endstr));}
var today = new Date();
var expiry = new Date(today.getTime() + 90 * 24 * 60 * 60 * 1000); // plus 28 days
function setCookie(name, value){
if (value != null && value != "")
document.cookie=name + "=" + escape(value) + "; path=/; expires=" + expiry.toGMTString();
bikky= document.cookie;}


function vote (node)
{
	node.selected = true;
	
	request = new xmlhttprequest ();
	request.url = "./vote.php";
	request.addGet ("id", aid);
	request.addGet ("value", node.value);
	request.callback = function (data)
	{
		document.getElementById ("voteresult").innerHTML += data;
		document.getElementById ("voteresult").style.visibility = "visible";
	}
	request.send ();
	
	var radios = document.getElementsByName ("voteradiobutton");
	for (var i = 0; i != radios.length; i++)
	{
		radios [i].disabled = true;
	}
}

window.onunload = function ()
{
	if (statsID != 0)
	{
		request = new xmlhttprequest ();
		request.url = "./stayedonsite.php";
		request.addGet ("id", statsID);
		request.send ();
	}
}