function load_poll_view(in_url, poll_id) {
    //    alert(in_url);
    $.ajax({
        type: "POST",
        url: in_url+poll_id,
        data: "",
        success: function(data) {
            //                            alert("Data: "+ data);
            $('#poll_results_'+poll_id).html(data)
            .fadeIn(1500);
        }
    });
    return false;
}

function poll_process(poll_id) {
    //    alert ("hello");
    //    return false;

    var poll_row_id = $('input[name=poll_row_id]:checked').val();
    //    var poll_id = $('input[name=poll_id]').val();
    if (poll_row_id===undefined) {
        alert("Please chose a vote before clicking to vote!");
        return false;
    }

    $('#PollVoteForm_'+poll_id).hide();

    var dataString = 'poll_row_id='+ poll_row_id +"&poll_id="+ poll_id;
//    alert (dataString);
//    return false;

    //
    // cookies
    //
    var nDays = 14;
    var today = new Date();
    var expire = new Date();
    expire.setTime(today.getTime() + 3600000*24*nDays);
    document.cookie = "poll_"+ poll_id +"=1;expires="+expire.toGMTString();

    //
    // AJAX request
    //
    $.ajax({
        type: "POST",
        url: "/polls/vote/"+poll_id+"/"+poll_row_id,
        data: dataString,
        success: function(data) {
            $('#poll_results_'+poll_id).html(data)
            .hide()
            .fadeIn(1500);
        }
    });
    return false;
}

JQuery.noConflict();

$(function() {
    alert ("hello");
    $("#poll_submit").click(function() {
        alert ("hello");
        return false;

        $('#PollVoteForm').hide();

        var poll_row_id = $('input[name=poll_row_id]:checked').val();
        var poll_id = $('input[name=poll_id]').val();
        if (poll_row_id===undefined) {
            alert("Please chose a vote before clicking to vote!");
            return false;
        }

        var dataString = 'poll_row_id='+ poll_row_id +"&poll_id="+ poll_id;
        //                    alert (dataString);return false;

        //
        // cookies
        //
        var nDays = 14;
        var today = new Date();
        var expire = new Date();
        expire.setTime(today.getTime() + 3600000*24*nDays);
        document.cookie = "poll_"+ poll_id +"=1;expires="+expire.toGMTString();

        //
        // AJAX request
        //
        $.ajax({
            type: "POST",
            url: "/polls/vote",
            data: dataString,
            success: function(data) {
                $('#poll_results_'+poll_id).html(data)
                .hide()
                .fadeIn(1500);
            }
        });
        return false;
    });
});


runOnLoad(function(){
    $("input#name").select().focus();
});

