
var num_articles = 0;
var animation_active = false;

function switch_article(index, runtime) {
if(!animation_active || (animation_active && runtime)) {
animation_active = true;

var tmp = null;
var active = document.getElementById('article' + index);
if(index < (num_articles - 1)) {
var below = document.getElementById('article' + (index + 1));
} else {
var below = null;
}

if(parseInt(active.style.top) != (index * 24)) {
if(parseInt(active.style.top) < (index * 24)) {
for(var i = index; i < num_articles; i++) {
tmp = document.getElementById('article' + i);
if(parseInt(tmp.style.top) != (i * 24)) {
tmp.style.top = (parseInt(tmp.style.top) + 6) + 'px';
}
}
} else if(parseInt(active.style.top) > (index * 24)) {
for(var i = index; i > 0; i--) {
tmp = document.getElementById('article' + i);
if(parseInt(tmp.style.top) != (i * 24)) {
tmp.style.top = (parseInt(tmp.style.top) - 6) + 'px';
}
}
}

window.setTimeout('switch_article(' + index + ', true);', 20);
} else if(below && parseInt(below.style.top) != ((index + 1) * 24 + 162)) {
if(parseInt(below.style.top) < ((index + 1) * 24 + 162)) {
for(var i = (index + 1); i < num_articles; i++) {
tmp = document.getElementById('article' + i);
if(parseInt(tmp.style.top) != (i * 24 + 162)) {
tmp.style.top = (parseInt(tmp.style.top) + 6) + 'px';
}
}
} else if(parseInt(below.style.top) > ((index + 1) * 24 + 162)) {
for(var i = (index + 1); i < num_articles; i++) {
tmp = document.getElementById('article' + i);
tmp.style.top = (parseInt(tmp.style.top) - 6) + 'px';
}
}

window.setTimeout('switch_article(' + index + ', true);', 20);
} else {
for(var i = 0; i < num_articles; i++) {
tmp = document.getElementById('article' + i);
if(i == index) {
if(active.className != 'article_open') {
active.className = 'article_open';
document.getElementById('aimg_' + i).src = '/_topics/article_open.gif';
}
} else {
if(tmp.className != 'article_closed') {
tmp.className = 'article_closed';
document.getElementById('aimg_' + i).src = '/_topics/article_closed.gif';
}
}
}

animation_active = false;
}
}
}
