$(document).ready(function() { 
    /*ready*/ /* öüóúéáíőű */

    /*$(".content .topnews").tabs({ fx: { opacity: 'toggle'} });*/
    var height = 320;
    var item = 5;
    $(".content .topnews ul li:first").addClass("ui-tabs-selected");
    $(".content .topnews ul li a").mouseenter(function() {
        var index = parseInt($(this).attr('rel').replace("#tn", ""), 10);

        $(".content .topnews .ribbon").stop().animate({ marginTop: height * index + "px" }, /*150*/0);
        $(this).parent().parent().find("li").removeClass("ui-tabs-selected");
        $(this).parent().addClass("ui-tabs-selected");
        return false;
    });

    var index = 1;
    var pause = false;
    $(".content .topnews ul li a").hover(function() { pause = true; }, function() { pause = false; });
    $(".content .topnews")
    .hover(function() { pause = true; }, function() { pause = false; })
    .everyTime(10000, function(i) {

        if (!pause) {
            //$(this).tabs('select', index++);
            var margin = parseInt($(this).find(".ribbon").css("margin-top").replace("px", ""), 10) - height;
            //console.log(margin);
            if (margin <= height * item * -1)
                margin = 0;

            $(this).find(".ribbon")//.css("margin-top", margin + "px");
            .stop().animate({ marginTop: margin + "px" }, /*150*/0);

            $(this).parent().parent().find("li").removeClass("ui-tabs-selected");
            $(".content .topnews ul li").find("a[rel='#tn" + (margin / height) + "'],a[rel='#tn-" + (margin / height) + "']").parent().addClass("ui-tabs-selected");


            //if (index > 4)
            //index = 0;

        }
    });

    /*//ready*/
});