function game(counter){
    this.click = function(element){
        counter += 1;
        if (counter < 4) {
            $.get("/play/click/" + element.id, function(data){
                $(element).html(data);
                $('#game-result').html(parseInt($('#game-result').html()) + parseInt(data));
            });
        }
        if (counter == 3){
            this.writeresult();
        }
    };

    this.writeresult = function(){
        $('#top3ranking').html('Updating database ...');
        $.get("/play/writeresult", function(data){
            $('#top3ranking').html(data);
        });
    }
}


    //function game(element){
    //    if (i < 3) {
    //        new Ajax.Request('/play/click/' + element.id, {
    //            method: 'get',
    //            onSuccess: function(transport){
    //                if (transport.responseText.blank != false) {
    //                    new Effect.Highlight(element);
    //                    element.update(transport.responseText);
    //                    $('game-result').update(parseInt($('game-result').innerHTML) + parseInt(transport.responseText));
    //                    i += 1;
    //                }
    //                if (i == 3) {
    //                    new Effect.Highlight('top3ranking');
    //                    $('top3ranking').update('Updating database ...');
    //                    // Ajax request with database update
    //                    new Ajax.Request('/play/writeresult', {
    //                        method: 'get',
    //                        onSuccess: function(transport) {
    //                        $('top3ranking').update(transport.responseText);
    //                    }});
    //                    }
    //                }
    //            }
    //        )}
    //    }
