function elemToggler() {
	var app = this;

	app._step = 10;
	app._accel = 3;
	app._delay = 50;
	app._minheight = 20;
	app.functions = new exUtils();
	app.heights = new Object();
	app.minHeights = new Object();


	app.setEventHandlers = function() {
		var divs = document.getElementsByTagName('div');
		var k = 0;

		for (var i = 0; i < divs.length; i++) {
			if (app.functions.hasClass('toggle', divs[i].className)) {

				k++;
				var e = divs[i];
				if (!e.getAttribute('id')) e.setAttribute('id', 'toggler_E' +k);
				if (e.clientHeight) {
					app.heights[e.getAttribute('id')] = e.clientHeight;
				} else if (e.offsetHeight) {
					app.heights[e.getAttribute('id')] = e.offsetHeight;
				} else {
					app.heights[e.getAttribute('id')] = app._minheight;
				}

				var handles = app.functions.filterChildNodesRecursive(e, null, 'toggle_handle');
				if (handles.length > 0) {
					var h = app._minheight;
					if (handles[0].clientHeight) {
						h = handles[0].clientHeight +handles[0].clientHeight *1.1;
					} else if (handles[0].offsetHeight) {
						h = handles[0].offsetHeight +handles[0].offsetHeight *0.5;
					}
					app.minHeights[e.getAttribute('id')] = h;

					if (app.functions.hasClass('closed', e.className)) {
						e.style['height'] = app.minHeights[e.getAttribute('id')] + 'px';
					}

					app.functions.addEvent(handles[0], 'click', function()
					{
						var parent = this.parentNode;

						// Öffnen
						if (app.functions.hasClass('closed', parent.className)) {
							app.functions.transform(
								parent,
								app.minHeights[parent.getAttribute('id')],
								app.heights[parent.getAttribute('id')],
								app._step,
								app._accel,
								app._delay,
								function(elem, w) {
									elem.style['height'] = w + 'px';
								},
								function(elem) {
									elem.className = app.functions.removeClass(elem.className, 'closed');
								} );
						}

						// Schließen
						else {
							app.functions.transform(
								parent,
								app.heights[parent.getAttribute('id')],
								app.minHeights[parent.getAttribute('id')],
								app._step,
								app._accel,
								app._delay,
								function(elem, w) {
									elem.style['height'] = w + 'px'
								},
								function(elem) {
									elem.className = app.functions.addClass(elem.className, 'closed');
								} );
						}
					} );
				}
			}
		}
	}
}

var toggler;
toggler = new elemToggler();
toggler.functions.addEvent(window, 'load', function() { toggler.setEventHandlers(); } );

