function vote(pollId)
{
    var form = '#poll_' + pollId;
    var options = {
        dataType: 'json',
        beforeSubmit: function(){
            $(form + ' span.wait').fadeIn("fast");
            $('input[@type="submit"]').attr({disabled:"disabled"});
        },
        success: function(data){
            $('input[@type="submit"]').removeAttr("disabled");
            if (data.success == true) {
                $(form + ' div#mess_' + pollId).html(data.message);
                // Building result html by responce data
                if (poll = data.polls[0]) {
                    var rhtml = '';
                    var opts = poll.options;
                    for (var i = 0, c = opts.length; i < c; i++) {
                        var p = Math.round(opts[i].procents * 2.55);
                        rhtml += "<div class='voterow'>\n"
                               + "  <div class='answtext'>" + opts[i].text + " <sup><span class='votes'>(" + opts[i].votes + ")</span></sup></div>"
                               + "  <div class='indic' style='width:" + ((Math.round(p / 1.65)) + 1) + "px; background: rgb(" + (255 - p) + ", " + p + ", 0);'></div>"
                               + "  <div class='proc'>" + opts[i].procents + "%</div>"
                               + "  <div class='clear'></div>"
                               + "</div>";
                    }
                    $('#res_wrapp_' + pollId).html(rhtml);
                    rhtml = '';
                }
            } else {
                if (data.errors) {
                    //$(form + ' div#mess_' + pollId).html(data.message);
                    for (var elem in data.errors) {
                        $(form + ' div#mess_' + pollId).html('<p>' + data.errors[elem] + '</p>');
                        break;
                    }
                }
            }
            $(form + ' span.wait').fadeOut("fast");
        }
    }
    $(form).ajaxSubmit(options);
    return false;
};

function increaseImage(img, width, height, marginTop, speed)
{
	$(img).attr('src', $(img).attr('src').replace(/small_/, 'big_'));
	$(img).animate({ 
		width: width,
		height: height,
		marginTop: marginTop
	}, speed);
}
function decreaseImage(img, width, height, marginTop, speed)
{
	$(img).animate({ 
		width: width,
		height: height,
		marginTop: marginTop
	}, speed);
	$(img).attr('src', $(img).attr('src').replace(/big_/, 'small_'));
}

function cacheImage(imgPath)
{
	(new Image()).src = imgPath;
}