/* ----------------------------------- /*
	used to toggle poll options in the
	admin. It adds options and an empty
	value for the result (0). Or it removes
	the option field and it's spot in the 
	result's array
/* ----------------------------------- */
function poll_option(type,colors)
{	
	extra_div 			= document.getElementById('poll_extra_options');
	results				= document.getElementById('poll_results');
	
	color_select = '<select name="poll_colors[]">';
	for(i=0;i<colors.length;i++)
	{
		color_select += '<option value="'+colors[i]+'">'+colors[i]+'</option>';
	}
	color_select += '</select>';
	
	if(type == 'add')
	{
		results.value		+= ',0';
		opt_count			= results.value.length/2;
		opt_count			= Math.ceil(opt_count);
		extra_div.innerHTML += 'Option '+opt_count+': <input type="text" name="poll_options[]" id="poll_options[]" /> Color: '+color_select+' <input type="button" value="Add" onClick="javascript:poll_option(\'add\',colors);" /> <input type="button" value="Remove" onClick="javascript:poll_option(\'remove\',colors);" /><br /><br />';
	}
	else
	{
		results.value		= results.value.substring(0,results.value.length-2);
		extra_div.innerHTML = extra_div.innerHTML.substring(0,extra_div.innerHTML.lastIndexOf('Option'));
	}
}


/* ----------------------------------- /*
	used to reset the values in the poll
	results field. replaces all vote 
	totals with zero(0).
/* ----------------------------------- */
function reset_poll()
{	
	results				= document.getElementById('results');
	voter_list			= document.getElementById('voter_list');
	rval				= results.value
	result_count		= rval.split(',').length;
	results.value		= '';
	for(i=0;i<result_count;i++) results.value += '0,';
	results.value = results.value.substring(0,results.value.length-1);
	voter_list.value	= ' ';			// needs to set as a space so that the empty list will be stored in the database (function does not store blank values)
	alert('The poll has been TEMPORARILY reset!\n Please make sure to click UPDATE or changes will be lost!');
}