/**
 * process the vote via javascript and AJAX
 * after the call the action will return rawContent
 * wich will show the results after the vote
 * @author b.vanelburg@2tci.nl
 * @param component_id int
 * @param poll_id int
 * @return void
 */
function process_vote(component_id,poll_id) {
	// the form
	var form_obj = document.getElementById('component_'+component_id+'_form_poll_'+poll_id);
	// list the options
	var poll_options = form_obj.elements["form_poll_"+poll_id+"_vote"];
	// if it is more then 1 option
	if(typeof(poll_options.length) === 'number') {
		var arLen=poll_options.length;
		var selected_option = null;
		for ( var i=0, len=arLen; i<len; ++i ){
			if(poll_options[i].checked) {
				selected_option = poll_options[i];
				break;
			}
		}
	} else { // else it is a poll with one option (huh?)
		if(poll_options.checked) {
			selected_option = poll_options;
		}
	}
	// if no selection was made, alert the user
	if(selected_option == null) { alert('Selecteer een optie'); }
	// else process the vote
	else {	AJAX.get("?m=poll&a=vote&id="+selected_option.value,AJAX.replaceContent,{'id': 'component_'+component_id+'_poll_'+poll_id+'_container'}); }
}
