calculate column
function calculateColumn(index, column) { return (index%column)+ (Math.floor(1-((index/column)-Math.floor(index/column))))*column; }