var z = 1;
var totalDivs=0;

function gotofront(id)
{
	z=totalDivs;
	var divID = document.getElementById('post_'+id);
	divID.style.zIndex = z.toString();

}
function gotoback(id)
{
	z=(totalDivs+1)-id;
	var divID = document.getElementById('post_'+id);
	divID.style.zIndex = z.toString();
}

function replace_divs(aantalDivs)
{
	totalDivs=aantalDivs;
	z=aantalDivs;
	var pos = aantalDivs * 20;
	for(var i=1; i<=aantalDivs; i++)
	{
		doReplace(i, pos, pos);
		pos = pos - 15;
	}
	z=aantalDivs;
}

function doReplace(item, x, y) {
	var divID = document.getElementById('post_'+item);
	divID.style.zIndex = z.toString();
	z=z-1;

}