$(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,action,value,level) {
    var url = '/voting/' + app + '/' +  model + '/' + slug + '/' + direction + 'vote/';
    $.post(url, {
        HTTP_X_REQUESTED:'XMLHttpRequest'
    },
    function(data) {
	if(level == undefined){
	    level = ".level";
	}
        if (data.success == true) {
	    if (direction == 'up')
                $(level).text(parseInt($(level).text()) + value);
	    else if (direction == 'down'){
		$(level).text(parseInt($(level).text()) - value);
	    }else{

		if (action == 'up'){
		    $(level).text(parseInt($(level).text()) - 1);
		}else{
                    $(level).text(parseInt($(level).text()) + 1);
		}
	    }
        } else {
	    if(data.error_message == 'Not authenticated.'){
		window.location.replace('/accounts/login/?next='+window.location.pathname);
	    }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");
}

