function load_poll_view(in_url, poll_id) {
	$.ajax({
		type: "POST",
		url: in_url+poll_id,
		data: "",
		success: function(data) {
			$('#poll_results_'+poll_id).html(data)
            .fadeIn(1500);
        }
    });
    return false;
}

function poll_process(poll_id) {
	var poll_row_id = $('input[name=poll_row_id]:checked').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;

    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({
        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;
}


$("#poll_submit").click(function() {
	$('#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;

    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({
        type: "POST",
        url: "/polls/vote",
        data: dataString,
        success: function(data) {
            $('#poll_results_'+poll_id).html(data)
            .hide()
            .fadeIn(1500);
        }
    });
    return false;
});
