
function init() {
	new Navi('navContainer', 'nav-produkte');
//	new Navi('navContainer', 'nav-loesungen');
//	new Navi('navContainer', 'nav-service');
	new Navi('navContainer', 'nav-geschichte');
	new Navi('navContainer', 'nav-kontakt');
//	new Navi('navContainer', 'nav-login');
	
	Custom.init();
	
	// afterglow
	Event.observe(document, 'mouseover', hideAfterGlow);
	// archive
	highlightArchivedItems();
}

var afterGlowObjects = new Array();
function hideAfterGlow(e) {
	
	var target = Element.extend(Event.element(e));
	// afterGlow herausfinden
	while(target != null && target.hasClassName && !(target.hasClassName('afterGlow') || target.hasClassName('itemElement'))) {
		target = Element.extend(target.parentNode);
	}
	
	
	for(var i=0; i<afterGlowObjects.length; i++) {
		if(target == null || (target != afterGlowObjects[i] && target != afterGlowObjects[i].afterGlow))
			afterGlowObjects[i].afterGlow.hide();
	}
}
function showAfterGlow(div, nummer) {
	if(!div.afterGlow) {
		var afterGlow 	= document.createElement('table');
		
		var tableGlowTBODY = document.createElement('tbody');
		afterGlow.appendChild(tableGlowTBODY);
		
		var afterGlowTR = document.createElement('tr');
		tableGlowTBODY.appendChild(afterGlowTR);
		
		var afterGlowTD = document.createElement('td');
		afterGlowTR.appendChild(afterGlowTD);
		
		Element.extend(div);
		Element.extend(div.parentNode);
		Element.extend(afterGlow);
		
		afterGlow.hide();
		afterGlow.addClassName('afterGlow');
//		afterGlow.onmouseout = function() { this.hide(); }.bind(afterGlow);
		
		var img = document.createElement('img');
		img.src = 'img/afterGlow.png';
		afterGlowTD.appendChild(img);
		
		div.insert({ before: afterGlow });
		div.afterGlow = afterGlow;

		img.style.width 	= (div.getWidth()+37) + 'px';
		img.style.height 	= (div.parentNode.getHeight()+16) + 'px';
		
		afterGlowObjects.push(div);
	}
	div.afterGlow.show();
}

function highlightArchivedItems() {
	
	var items = $('maintable').select('div.archived');
	
	for(var i=0; i<items.length; i++) {

		var item = items[i];
		var archive	= new Element('div', { 'class': 'archivedItem'});
		
		var img = document.createElement('img');
		img.src = 'img/archive.png';
		archive.appendChild(img);
		
		archive.style.width 	= (item.getWidth()+38) + 'px';
		archive.style.height 	= (item.parentNode.getHeight()+19) + 'px';

		img.style.width 	= (item.getWidth()+37) + 'px';
		img.style.height 	= (item.parentNode.getHeight()+18) + 'px';
		
		item.insert({ before: archive });
	}
	
}
