function getElementPosition(elemID){
    var obj = document.getElementById(elemID);
    var curLeft = curTop = 0;
    if (obj.offsetParent) {
        do {
            curLeft += obj.offsetLeft;
            curTop += obj.offsetTop;
        } while (obj = obj.offsetParent);
    }
    return {
        left: curLeft,
        top: curTop
    };
}
function setStars(postId, starCount, elementHead) {
    if (!elementHead) {
        elementHead = "v-";
    }
    for (i = 1; i <= 5; i++) {
        document.getElementById(elementHead + postId + "-" + i).src = '/static/image/star_none.png';
    }
    for (i = 1; i <= starCount; i++) {
        document.getElementById(elementHead + postId + "-" + i).src = '/static/image/star_full.png';
    }
}
function vote(postId, starCount) {
    jQuery.get(
        "/post/vote",
        {
            post_id: postId,
            value:   starCount
        },
        function(data){
            setStars(postId, starCount, "r-");
            if ( data['json_data']['status'] ) {
                document.getElementById("status-" + postId).innerHTML = data['json_data']['status'];
            }
        },
        'json'
    );
    document.getElementById('vote-create-' + postId).style.display = 'none';
    document.getElementById('vote-' + postId).setAttribute("onmouseover", "");
}