function vote( url, popup )
{
    if( popup == null )
    {
        popup == false;
    }
//    if( canVote || !canVote )
    if( canVote )
    {
        /* AJAX VOTE -- the URL holds the prize number */
        $.ajax(
            {
                type: "POST",
                url: url,
                success: function( data, textStatus ) { voteSuccess( data, textStatus, popup ); }
            }
        );
    }
    else
    {
        alert( "Sorry, but you can vote only once!" );
    }
}

function voteSuccess( data, textStatus, popup )
{
    //Update the votes
    try
    {
        data = JSON.parse( data );
        if( data.voted == true )
        {
            votes = "votes";
            if( data.votes == 1 )
            {
                votes = "vote";
            }
            $( "#" + data.prize_number + "-votes").text( data.votes + " " + votes );

            /* load the doubleclick stuff */
            var time = Math.floor( ( new Date().getTime() / 1000 ) );
            $( document ).find( "body" ).find( "iframe" ).remove(); /* remove any old iframes */
            $( document ).find( "body" ).prepend( '<iframe src="http://fls.doubleclick.net/activityi;src=2390413;type=2010-575;cat=vote-263;ord=' + time + '?" width="1" height="1" frameborder="0"></iframe>' );
        }

        if( popup )
        {
            alert( "Thank you for voting!" );
        }
    }
    catch( err )
    {
        /* nothing */
    }
    canVote = false;
}
