/*
  CATALOGTREE 4.0
  Copyright (C) 2007 Pyrrhon Software

  Lutz Ißler
  Talstr. 27
  04103 Leipzig
  GERMANY

  Web:    www.pyrrhon.com
  Email:  lutz@pyrrhon.com

  Design by catalogtree, Arnhem, THE NETHERLANDS

  Permission granted to use this file and associated files
  only on the specified website.
*/



var colors = new Array("cyan", "magenta", "yellow");

function on(id) {
	for (var i=0; i<index[id].length; i++) {
		var el = document.getElementById("index_"+index[id][i]);
		if (el) {
			el.setAttribute("class", colors[i%3]);
		}
	}
}

function off(id) {
	for (var i=0; i<index[id].length; i++) {
		var el = document.getElementById("index_"+index[id][i]);
		if (el) {
			el.removeAttribute("class");
		}
	}
}

$(function() {
	var chunkHeights = new Array();
	var totalHeight = 0;
	$("#index > .section").each(function() {
		var h = $(this).height();
		totalHeight += h;
		chunkHeights.push(h);
	});
	var colHeight = totalHeight/Math.floor($(window).width()/(120+11));
	var bestSplits = [];
	var height = 0;
	for (var i=0; i<chunkHeights.length; i++) {
		height += chunkHeights[i];
		if (height>colHeight) {
			bestSplits.push(i);
			height = 0;
		}
	}
	var lastSplit = 0;
	for (var i=0; i<bestSplits.length; i++) {
		$("#index > .section:lt("+(bestSplits[i]-lastSplit)+")").wrapAll('<div class="col"></div>');
		lastSplit = bestSplits[i];
	}
	$("#index > .section").wrapAll('<div class="col"></div>');
});
