private Table BuildResultsBarTable(QuestionResultsData.AnswersRow[] answers, double totalOfVotes)
		{
			double currentRate = 0; 
			double totalRate = 0;
			double totalOfVotesRate = 0;

			Table barTable = new Table();
			barTable.Width = Unit.Percentage(95);
			barTable.BorderWidth = 0;
			barTable.ControlStyle.CopyFrom(AnswerStyle);

			foreach (QuestionResultsData.AnswersRow answer in answers)
			{
				if ((((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Selection) > 0))
				{
					double VotePercent = 0;

					if (totalOfVotes != 0)
					{
						if (answer.VoterCount==0)
							VotePercent = 0;		
						else
							VotePercent = ((double)answer.VoterCount / (double)totalOfVotes) * 100;
					}

					// Add answer text & vote count
					answer.AnswerText = Context.Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(answer.AnswerText, "<[^>]*>", " "));
					string answerCellText;
					if (!ShowOnlyPercent)
					{
						answerCellText = string.Format("{0}&nbsp;({1})",
							answer.AnswerText, answer.VoterCount.ToString());
					}
					else
					{
						answerCellText = answer.AnswerText;
					}
					barTable.Rows.Add(BuildRow(answerCellText, AnswerStyle));				

					// Add results bar
					ResultsBar resultsBar = new ResultsBar();
					resultsBar.Progress = (int)Math.Round(VotePercent);
					resultsBar.ItemStyle = this.AnswerStyle;
					resultsBar.BarColor = BarColor;
					if (this.Width.IsEmpty)
					{
						resultsBar.TableWidth = 110;
					}
					else
					{
						resultsBar.TableWidth = this.Width;
					}
					barTable.Rows.Add(BuildRow(resultsBar, AnswerStyle));				
					
					// Do we include this answer in the
					// rating total
					if (answer.RatePart)
					{
						currentRate++;
						totalRate += currentRate * answer.VoterCount;
						totalOfVotesRate += answer.VoterCount;
					}
				}
			}
			
			// Add Rating Bar
			if (_dataSource.Questions[0].RatingEnabled && currentRate>0)
			{
				double meanRate = 0;

				if (totalOfVotes == 0)
					meanRate = 0;
				else
					meanRate = totalRate / totalOfVotesRate;
			
				RatingBar ratingBar = new RatingBar();
				ratingBar.MaxRating = currentRate;
				ratingBar.Rating = meanRate;
				ratingBar.ItemStyle = this.AnswerStyle;

				if (this.Width.IsEmpty)
				{
					ratingBar.TableWidth = 110;
				}
				else
				{
					ratingBar.TableWidth = this.Width;
				}

				barTable.Rows.Add(BuildRow(ratingBar, AnswerStyle));
			}

			return barTable;
		}
        private Table BuildResultsBarTable(QuestionResultsData.AnswersRow[] answers, double totalOfVotes)
        {
            double currentRate      = 0;
            double totalRate        = 0;
            double totalOfVotesRate = 0;

            Table barTable = new Table();

            barTable.Width       = Unit.Percentage(95);
            barTable.BorderWidth = 0;
            barTable.ControlStyle.CopyFrom(AnswerStyle);

            foreach (QuestionResultsData.AnswersRow answer in answers)
            {
                if ((((AnswerTypeMode)answer.TypeMode & AnswerTypeMode.Selection) > 0))
                {
                    double VotePercent = 0;

                    if (totalOfVotes != 0)
                    {
                        if (answer.VoterCount == 0)
                        {
                            VotePercent = 0;
                        }
                        else
                        {
                            VotePercent = ((double)answer.VoterCount / (double)totalOfVotes) * 100;
                        }
                    }

                    // Add answer text & vote count
                    answer.AnswerText = Context.Server.HtmlEncode(System.Text.RegularExpressions.Regex.Replace(answer.AnswerText, "<[^>]*>", " "));
                    string answerCellText;
                    if (!ShowOnlyPercent)
                    {
                        answerCellText = string.Format("{0}&nbsp;({1})",
                                                       answer.AnswerText, answer.VoterCount.ToString());
                    }
                    else
                    {
                        answerCellText = answer.AnswerText;
                    }
                    barTable.Rows.Add(BuildRow(answerCellText, AnswerStyle));

                    // Add results bar
                    ResultsBar resultsBar = new ResultsBar();
                    resultsBar.Progress  = (int)Math.Round(VotePercent);
                    resultsBar.ItemStyle = this.AnswerStyle;
                    resultsBar.BarColor  = BarColor;
                    if (this.Width.IsEmpty)
                    {
                        resultsBar.TableWidth = 110;
                    }
                    else
                    {
                        resultsBar.TableWidth = this.Width;
                    }
                    barTable.Rows.Add(BuildRow(resultsBar, AnswerStyle));

                    // Do we include this answer in the
                    // rating total
                    if (answer.RatePart)
                    {
                        currentRate++;
                        totalRate        += currentRate * answer.VoterCount;
                        totalOfVotesRate += answer.VoterCount;
                    }
                }
            }

            // Add Rating Bar
            if (_dataSource.Questions[0].RatingEnabled && currentRate > 0)
            {
                double meanRate = 0;

                if (totalOfVotes == 0)
                {
                    meanRate = 0;
                }
                else
                {
                    meanRate = totalRate / totalOfVotesRate;
                }

                RatingBar ratingBar = new RatingBar();
                ratingBar.MaxRating = currentRate;
                ratingBar.Rating    = meanRate;
                ratingBar.ItemStyle = this.AnswerStyle;

                if (this.Width.IsEmpty)
                {
                    ratingBar.TableWidth = 110;
                }
                else
                {
                    ratingBar.TableWidth = this.Width;
                }

                barTable.Rows.Add(BuildRow(ratingBar, AnswerStyle));
            }

            return(barTable);
        }