// <!--
// UA Zone QuickPoll -- Free Ukrainian WWW Voting System
// http://www.poll.com.ua/
//
// QuickPoll Standard Functions
// Version: 1.0
// Created: 11/28/1999 by  --ob. (oleg@uazone.net)
//
// Copyright (c) 1999 by UA Zone Group International  http://www.uazone.net/
//

/******************************************************************************
functions synopsis:
  PrintPollForm()	-- prints the standard poll form to the document.
  PrintPollResult() -- prints poll standard results graph to the document.
  PrintPollAuto()   -- prints poll form if user didn't vote on current poll,
                       otherwise prints poll results...
expects poll data to be defined from PollDataJS.phtml call. Otherwise returns error.
******************************************************************************/


htmlPollLogo = "<a href=\"http://www.poll.com.ua/\"><img src=\"http://www.poll.com.ua/img/Poll-buton-1-sm-fl.gif\" \
width=143 height=20 align=\"left\" hspace=1 vspace=2 border=0></a><br clear=\"all\"> \
<img src=\"http://www.poll.com.ua/img/pixel_b2.gif\" width=1 height=500 align=\"left\" hspace=3 vspace=2>\n";

function PollWindow(w_url) {
    window.open(w_url,"pollwindow",
    "toolbar=no,scrollbars=yes,directories=no,status=no,menubar=no,resizable=yes,width=630,height=460")
}

function PrintPollForm() {
  
  if (!qpVersion) {
    document.write("QuickPoll Error: No data!<br>\n");
    return;
  }
  document.write(htmlPollLogo);
    
  if (qpReturnCode != 0 ) {
    document.write("Error Occured: " + qpErrorText + "<br><br>\n");
    return;
  }

  document.write("<font size=-1> \
<form action=\"http://www.poll.com.ua/PollProbe3.phtml\" method=\"POST\" > \
<input type=\"hidden\" name=\"PollID\" value=\"" +qpPollID + "\"> \
<input type=\"hidden\" name=\"ac\" value=\"AddVote\"> \
<input type=\"hidden\" name=\"PollReturnURL\" value=\"" + qpReturnURL + "\"> \
<font color=\"#0077aa\"><b>" + qpPollTitle + "</b></font> \
<br><font color=\"#993300\" size=1 class=\"Small1\"> \n");

  for (i=0; i<qpNumOptions; i++) {
    if (qpOptionChecked[i])
      checkedText = "checked";
    else
      checkedText = "";
    document.write("&nbsp;<input type=\"radio\" name=\"OptionID\" value=\"" + i + "\" " + checkedText + "> " + qpOption[i] + "<br>\n");
  }
  
  if (qpAllowComments) {
    document.write("&nbsp;<input type=\"text\" name=\"xComment\" maxlength=255 size=15><br>\n");
  }

  document.write("</font>\n<input type=\"submit\" value=\"   Submit   \"><br>\n</font></form>\n\n");

//  if (qpHasVoted == 0)
    document.write("<font color=\"#0077aa\"> \
<a href=\"http://poll.com.ua/PollProbe2.phtml?PollID=" + qpPollID + "&ac=ShowResult\" target=\"pollwindow\" \
onClick=\"PollWindow('about:blank')\">Poll Results</a> \
</font>");

  return;
}

function PrintPollResult() {

  if (!qpVersion) {
    document.write("QuickPoll Error: No data!<br>\n");
    return;
  }
  document.write(htmlPollLogo);
    
  if (qpReturnCode != 0 ) {
    document.write("Error Occured: " + qpErrorText + "<br><br>\n");
    return;
  }

  if (qpMaxVotes == 0) qpMaxVotes = 1;
  qpTotalVotes1 = qpTotalVotes;
  if (qpTotalVotes == 0) qpTotalVotes1 = 1;
  
  document.write("<font face=\"arial cyr\" size=-1> \
<font color=\"#0077aa\"><b>" + qpPollTitle + "</b> \
<font color=\"#993300\" class=\"Small1\" size=1><br><br> \n");

  barFactor = qpBarWidth / qpMaxVotes;
  for (i=0; i<qpNumOptions; i++) {
    barWidth = Math.round(qpVotesData[i] * barFactor);
    votesPercent = Math.round( qpVotesData[i] / qpTotalVotes1  * 100 );
    
    document.write("&nbsp; " + i + ". " + qpOption[i] + "<br>\n");
    document.write("&nbsp; <img src=\"http://www.poll.com.ua/img/pixel_r1.gif\" height=2 width=" + barWidth + " vspace=2<br>\n");
    document.write("<font color=\"#0077aa\">" + qpVotesData[i] + "(" + votesPercent + "%)</font><br>\n");
  }
  document.write("\n</font><br>\n\nTotal Votes: " + qpTotalVotes + "</font><br>\n");
  return;
  
}

function PrintPollAuto() {
  if (qpHasVoted)
    PrintPollResult();
  else
    PrintPollForm();
  return;
}

// -->