var duration = 1.5;
var interval = 4.0;
var rows_visible = 4;
if (navigator && navigator.appName == 'Microsoft Internet Explorer') {
	var rv = -1;
	var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
	if (re.exec(navigator.userAgent) != null) 
		rv = parseFloat(RegExp.$1);
	
	if (rv == 7) {
		rows_visible = 5;
	}
}

var to = setTimeout(init_activity, interval * 1000);


function get_e(id) {
    return document.getElementById(id);
}

function init_activity() {
    var o = get_e('recent_activity_container');
    if (o) {
        var lis = init_ul(o);
        var row_h = lis[2].offsetTop - lis[1].offsetTop;

        o.style.height = ((rows_visible + 1) * row_h) + "px";

        shift_down(lis, row_h);
    }
}

function init_ul(o) {
    var ltemp = o.getElementsByTagName("LI");
    var lis = [];

    for (i=0; i<ltemp.length; i++) {
        lis.push(ltemp[i]);
        var li = lis[i];
        li.style.position = "relative";
        li.style.top = "0px";
	if (i >= rows_visible && i != ltemp.length - 1) {
		setOpacity(li, 0.0);//new OpacityTween(li, Tween.strongEaseOut, 100, 0, duration).start();
	}
    }

    return lis;
}

function shift_down(lis, row_h) {
    var last = lis[lis.length - 1];

    last.style.top = (-1 * (parseInt(last.id) + 1) * row_h) + "px";
    var op = new OpacityTween(last, Tween.strongEaseIn, 0,100,duration * 0.75)
    op.start();

    for (i=0; i<lis.length; i++) {
        var a = lis[i];
        var y = parseInt(a.style.top);
        var t = new Tween(a.style, 'top', Tween.regularEaseOut, y, y + row_h, duration, 'px');
        t.start();

        if (i == (rows_visible - 1)) {
            op = new OpacityTween(a, Tween.strongEaseOut, 100,0,duration);
            op.start();
        }
    }

    lis.unshift(lis.pop());
    setTimeout(function(){shift_down(lis, row_h);}, (duration + interval) * 1000);
}




