document.onmousemove = getMouse;
function getMouse(e) {
	var posx = 0;
	var posy = 0;
	var array = new Array();
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else 
	if (e.clientX || e.clientY) 	
	{
		posx = e.clientX + document.body.scrollLeft; + document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop; + document.documentElement.scrollTop;
	}
	coord[0] = posx;
	coord[1] = posy;
}
var coord = new Array();

function showNote(id, id2)
{
	id = document.getElementById(id);
	id2 = document.getElementById(id2);
	if(id.style.display == 'block')
	{
		id.style.display = 'none';
	}
	else
	{
		value = id.innerHTML;
		id.style.position = "absolute";
		id.style.top = parseInt(findPosY(id2)+20)+'px';
		id.style.left = parseInt(findPosX(id2)+20)+'px';
		id.style.display = 'block';
		id.style.width = parseInt(value.length*5)+'px';
	}
}

function ajaxVote(poll, option)
{
	new Ajax.Request('/vote/vote.php?poll_id='+poll+'&value='+option,
	{
			method: 'get',
  			onSuccess: function(display)
					   {
							$('result').update(display.responseText);
							$('result').innerHTML;	
					   }
	});
}

function get_radio_value()
{
	for (var i=0; i < document.vote2.option.length; i++)
	{
		if (document.vote2.option[i].checked)
		{
			var rad_val = document.vote2.option[i].value;
			return rad_val;
		}
	}
	return -10;
}

function get_radio_value3()
{
	for (var i=0; i < document.vote3.option.length; i++)
	{
		if (document.vote3.option[i].checked)
		{
			var rad_val = document.vote3.option[i].value;
			return rad_val;
		}
	}
	return -10;
}

function get_radio_value4()
{
	for (var i=0; i < document.vote4.option.length; i++)
	{
		if (document.vote4.option[i].checked)
		{
			var rad_val = document.vote4.option[i].value;
			return rad_val;
		}
	}
	return -10;
}


function get_radio_value5()
{
	for (var i=0; i < document.vote5.option.length; i++)
	{
		if (document.vote5.option[i].checked)
		{
			var rad_val = document.vote5.option[i].value;
			return rad_val;
		}
	}
	return -10;
}

function ajaxVote2()
{
	value = get_radio_value();
	if(value == -10)
	{
		alert('Selecteaza o optiune!');
	}
	else
	{
		new Ajax.Request('/vote/vote2.php?value='+value,
		{
				method: 'get',
				onSuccess: function(display)
						   {
								$('poll2_result').update(display.responseText);
								$('poll2_result').innerHTML;	
						   }
		});
	}
}

function ajaxVote3()
{
	value = get_radio_value3();
	if(value == -10)
	{
		alert('Selecteaza o optiune!');
	}
	else
	{
		new Ajax.Request('/vote/vote3.php?value='+value,
		{
				method: 'get',
				onSuccess: function(display)
						   {
								$('poll3_result').update(display.responseText);
								$('poll3_result').innerHTML;	
						   }
		});
	}
}
function ajaxVote4()
{
	value = get_radio_value4();
	if(value == -10)
	{
		alert('Selecteaza o optiune!');
	}
	else
	{
		new Ajax.Request('/vote/vote4.php?value='+value,
		{
				method: 'get',
				onSuccess: function(display)
						   {
								$('poll4_result').update(display.responseText);
								$('poll4_result').innerHTML;	
						   }
		});
	}
}

function ajaxVote5()
{
	value = get_radio_value5();
	if(value == -10)
	{
		alert('Selecteaza o optiune!');
	}
	else
	{
		new Ajax.Request('/vote/vote5.php?value='+value,
		{
				method: 'get',
				onSuccess: function(display)
						   {
								$('poll5_result').update(display.responseText);
								$('poll5_result').innerHTML;	
						   }
		});
	}
}


function findPosY(obj) {
	var posTop = 0;
	while (obj.offsetParent) {posTop += obj.offsetTop; obj = obj.offsetParent;}
	return posTop;
}
function findPosX(obj) {
	var posLeft = 0;
	while (obj.offsetParent) {posLeft += obj.offsetLeft; obj = obj.offsetParent;}
	return posLeft;
}
