//(function($){
var headline_count1;
var headline_count2;
var headline_count3;
var headline_count4;
var headline_interval1;
var headline_interval2;
var headline_interval3;
var headline_interval4;
var old_headline1 = 0;
var old_headline2 = 0;
var old_headline3 = 0;
var old_headline4 = 0;
var current_headline1 = 0;
var current_headline2 = 0;
var current_headline3 = 0;
var current_headline4 = 0;

$(document).ready(function(){
    headline_count1 = $("div.headline1").size();
    headline_count2 = $("div.headline2").size();
    headline_count3 = $("div.headline3").size();
    headline_count4 = $("div.headline4").size();
    
    $("div.headline1:eq(" + current_headline1 + ")").css('top', '5px');
    $("div.headline2:eq(" + current_headline2 + ")").css('top', '5px');
    $("div.headline3:eq(" + current_headline3 + ")").css('top', '5px');
    $("div.headline4:eq(" + current_headline4 + ")").css('top', '5px');

    headline_interval1 = setInterval(headline_rotate1, 7000);
    headline_interval2 = setInterval(headline_rotate2, 7500);
    headline_interval3 = setInterval(headline_rotate3, 8000);
    headline_interval4 = setInterval(headline_rotate4, 8500); 
    
    $('#scrollup1').hover(function() {
        clearInterval(headline_interval1);
    }, function() {
        headline_interval1 = setInterval(headline_rotate1,7000);
        headline_rotate1();
    });

    $('#scrollup2').hover(function() {
        clearInterval(headline_interval2);
    }, function() {
        headline_interval2 = setInterval(headline_rotate2, 7500);
        headline_rotate2();
    });

    $('#scrollup3').hover(function() {
        clearInterval(headline_interval3);
    }, function() {
        headline_interval3 = setInterval(headline_rotate3, 8000);
        headline_rotate3();
    });
    
    $('#scrollup4').hover(function() {
        clearInterval(headline_interval4);
    }, function() {
        headline_interval4 = setInterval(headline_rotate4,8500);
        headline_rotate4();
    });
  
});

function headline_rotate1() {
    current_headline1 = (old_headline1 + 1) % headline_count1;
    
    $("div.headline1:eq(" + old_headline1 + ")").animate({top: -205},"slow", function() {
        $(this).css('top', '210px');
    });

    $("div.headline1:eq(" + current_headline1 + ")").animate({ top: 5 }, "slow");
    old_headline1 = current_headline1;
}

function headline_rotate2() {
    current_headline2 = (old_headline2 + 1) % headline_count2;

    $("div.headline2:eq(" + old_headline2 + ")").animate({ top: -205 }, "slow", function() {
        $(this).css('top', '210px');
    });

    $("div.headline2:eq(" + current_headline2 + ")").animate({ top: 5 }, "slow");
    old_headline2 = current_headline2;
}

function headline_rotate3() {
    current_headline3 = (old_headline3 + 1) % headline_count3;

    $("div.headline3:eq(" + old_headline3 + ")").animate({ top: -205 }, "slow", function() {
        $(this).css('top', '210px');
    });

    $("div.headline3:eq(" + current_headline3 + ")").animate({ top: 5 }, "slow");
    old_headline3 = current_headline3;
}

function headline_rotate4() {
    current_headline4 = (old_headline4 + 1) % headline_count4;

    $("div.headline4:eq(" + old_headline4 + ")").animate({ top: -205 }, "slow", function() {
        $(this).css('top', '210px');
    });

    $("div.headline4:eq(" + current_headline4 + ")").animate({ top: 5 }, "slow");
    old_headline4 = current_headline4;
}
//})(jQuery.noConflict());