var ContainerId = 'electionC';
function submitElection(obj)
{
	check = false;
	url = typeof(ePageUrl != 'undefined') ? ePageUrl : 'ajax_pro/elections.php'; 
	query = "hdnAction=" + obj.hdnAction.value;
	query += "&hdnId=" + obj.hdnId.value;
	for (i=2; i<=(obj.length)-1; i++)
	{
		if (obj[i].checked)
		{
			query += "&radioElection=" + obj[i].value;
			check = true;
		}
	}
	if (!check) 
	{
		alert('Please select one\'s');
		return false;
	}
	if (typeof(eLoadingText) == 'undefined')
		eLoadingText = 'please wait';

	ContainerId = obj.parentNode.getAttribute('id');	
	dog(ContainerId).innerHTML = eLoadingText;
	getData(url , query , 'GET' , onSubmitElection);
}

function onSubmitElection(txt)
{
	dog(ContainerId).innerHTML =  txt;
	animate();
}


function animate()
{
	timer = window.setInterval("move();" , 10);
}

function move()
{
	step = 1;
	moved = false;
	if (!dog('optionCount'))
	{
		window.clearInterval(timer);
		return;
	}
	for(j=0; j<dog('optionCount').value-1; j++)
	{
		if(parseInt(dog('option'+j).style.width) < dog('percents'+j).value)
		{
				dog('option'+j).style.width = parseInt(dog('option'+j).style.width) + step + "%";
				moved = true;
		}
	}
	if (!moved)
		window.clearInterval(timer);
}


