$(document).ready(function () {
//    $('.details').hide();
    $("#reviews .head").click(function(){
        //var detail = '#' + $(this).attr("detail");
        var detail = 'recenzia-' + $(this).attr("detail") + '.html';
        window.location = detail;
        //$(detail).slideToggle("slow");
    });

    var scroll_path = window.location.pathname;
    if(scroll_path.match(/recenzia-([0-9]+)/) != null){
        var scroll_id = scroll_path.match(/recenzia-([0-9]+)/)[0];
    	$('html, body').animate({
    		scrollTop: $("#" + scroll_id).offset().top - 20
    	}, 1000);
    }

//    if(window.location.hash) {
//        var hash = window.location.hash.substring(1);
//        $('#' + hash).show();
//    }

    $(".klikatko").click(function(){
        var helpful = $(this).attr("value");
        var cookie = $.cookies.get( 'helpful' + helpful);
        if(cookie == null){
            $(this).hide();
            $.cookies.set( 'helpful' + helpful, helpful );
            $.ajax({
            		url: ajaxPath + 'helpful.php',
            		dataType: "text",
            		type: 'POST',
            		data: ({
            			'id': helpful
            		}),
            		success: function(data) {
                        $("#helpful_" + helpful)
                            .delay(1000)
                            .queue(function(n) {
                                $(this).hide();
                                $("#gone_" + helpful).slideToggle("slow");
                                n();
                            });
            		}
            	});

    
        }else{
            $("#helpful_" + helpful).hide();
            $("#gone_" + helpful).show();
        }
    
    });
});

