var pollOldOnload = window.onload;

window.onload = function()
{
    if (typeof pollOldOnload == 'function')
    {
         pollOldOnload();
    }

    window.pollInstance = new poll();
    pollInstance.init();
}

poll = function ()
{
    this.form = null;
    this.container = null;
}


poll.prototype.init = function()
{

    this.form = document.getElementById('pollForm');
    if (!this.form)
    {
        return;
    }
    this.container = document.getElementById('pollBox');
    if (!this.container)
    {
        return;
    }

    var script = this;

    this.form.onsubmit = function()
    {
        script.submitPoll(this);
        return false;
    }
}

poll.prototype.submitPoll = function(form)
{
    Blocks.submitFormAsBlock(form, 'results', this.processPollResponse, this);
}

poll.prototype.processPollResponse = function( xmlhttp, script )
{
    script.container.innerHTML =  xmlhttp.responseText;
}

