var ajax =  new xhrObject();
//
function getVote()
{
	var voteNo;
	var pattern = /[a-z]*/;
	var radioButtons = getElementsByAttribute('class', 'voteRadio');
	for(var i = 0; i < radioButtons.length; i++)
	{
		if(radioButtons[i].checked)
		{
			var radioButtonsId = radioButtons[i].id;
			if(pattern.test(radioButtonsId))
			{
				radioButtonsId = radioButtonsId.replace(pattern, "");
				voteNo = radioButtonsId;
				ajax.doGet("lib/dovote.inc.php?q=" + voteNo + "&sid=" + Math.random(), appendVote)
			}
			else
			{
				return;
			}
		}
	}
}
//
function appendVote(reply)
{ 
	document.getElementById("voteArea").innerHTML = reply;
} 
//
function getVideo()
{
	ajax.doGet("lib/video.inc.php?num=" + randVideo(), appendVideo);
}
//
function randVideo()
{
	n = Math.floor(Math.random() * 4);
	return n;
}
//
function appendVideo(reply)
{  
	document.getElementById("video-player").innerHTML = reply;
}
//
function init()
{
	getVideo();
	if (document.getElementById('voteLink'))
	{
		attachEventListener(document.getElementById('voteLink'), 'click', getVote, false);
	}
}
//
addLoadListener(init);
