/**
 * Layered Navigation
 * 
 * @author Jost Neumann, neumann@die-ordnung.de
 * 
 */
Event.observe(window, 'load', function(){

	// Get the mainmenu buttons (LI elements)
	var ulObj = $$('.mainmenu ul').first();
	var liObjs = ulObj.immediateDescendants();

	liObjs.each(function(liObj){
		try {
			// Get the submenu ul. 
			// If present register events on mainmenu button
			var subUlObj = liObj.getElementsBySelector('ul');
			if( !ulObj ){ return; }
            subUlObj = subUlObj.first();
			if( subUlObj ){
				subUlObj.hide();
				
				Event.observe(liObj, 'mouseover', function(evt){
					liObj.addClassName('hover');
					subUlObj.show();
				});
				
				Event.observe(liObj, 'mouseout', function(evt){
					liObj.removeClassName('hover');
					subUlObj.hide();
				});
				
			}
		} catch(x){}
	});

});



/**
 * This creates a visual effect for the 
 * references pages that show a list of images in a 
 * textpic content element. Those images that are wrapped 
 * by a link are supposed to be marked somehow.
 * 
 * So this basically look for all links and puts an element to 
 * the right and to the bottom of the link to create a minimal 
 * 3d like visual effect.
 * 
 */
Event.observe(window, 'load', function(){
	
	$$('.col-fulltop .references .csc-textpic-imagewrap a').each(function(elm, i){
		var c = Builder.node('div', {'class':'cover-link'});

		elm.style.position = 'relative';
		elm.appendChild(c);
		
		c = $(c);
		
		c.setStyle({
		        'position' : 'absolute',
				'top' : '0',
				'left' : '0'
		});
		c.clonePosition(elm, {
				'setWidth' : true, 
				'setHeight' : true, 
				'setLeft' : false, 
				'setTop': false
		});
		c.setStyle({
				'width' : c.getWidth()-4 + 'px',
				'height' : c.getHeight()-4 + 'px',
				'border' : '2px solid #047a5c'
		});
		
		Event.observe(elm, 'mouseover', function(evt){
			c.setStyle({
				'border' : '1px solid #047a5c',
				'margin' : '1px 0 0 1px'
			});
		});

		Event.observe(elm, 'mouseout', function(evt){
			c.setStyle({
				'border' : '2px solid #047a5c', 
				'margin' : '0px 0 0 0px'
			});
		});
		
		
	});
	
});


