$(document).ready(function() {
    $('input.inner-label').each(function() {
        if($(this).val() === '') {
            $(this).val($(this).attr('value'));
        }

        $(this).focus(function() {
            if($(this).val() === $(this).attr('value')) {
                $(this).val('').addClass('focused');
            }
        });

        $(this).blur(function() {
            if($(this).val() === '') {
                $(this).val($(this).attr('value')).removeClass('focused');
            }
        });
    });

  ieHover();
});

function vote(id, slug, direction, app, model) {
    var url = '/voting/' + app + '/' +  model + '/' + slug + '/' + direction + 'vote/';
    console.log(url);
    $.post(url, {
        HTTP_X_REQUESTED:'XMLHttpRequest'
    },
    function(data) {
        if (data.success == true) {
            if (direction == 'up')
                $('.level').text(parseInt($('.level').text()) + 1);
            else if (direction == 'down')
                $('.level').text(parseInt($('.level').text()) - 2);
            else
                $('.level').text(parseInt($('.level').text()) - 1);
        } else {
            alert(data.error_message);
        }
    }, 'json')
}

/*parametrs [selector, hover_class]*/
function ieHover() {
    hoverForIE6(".tools .rating", "hover");
    hoverForIE6(".tools .comments", "hover");
    hoverForIE6(".tools .read", "hover");
    hoverForIE6(".btn-rss", "hover");
    hoverForIE6("#nav li", "hover");
}
