window.addEvent('domready', function() {
    // bild-slider startseite
    if ($('slideshow')) {
        new NivooSlider($('slideshow'), {
            animSpeed: 750,
            effect: 'fold',
            interval: 5000,
            orientation: 'vertical',
            slices: 15
        });
    }
    
    $$('.product').each(function(el, id){
        el.addEvents({
            'mouseenter': function(){
        		itemGroupHover('.product', 'highlight', id);
            },
            'mouseleave': function(){
            	itemGroupHover('.product', 'clear');
            }
        });
    });
});

function itemGroupHover(elements, type, index) {
	switch (type) {
	case 'clear':
	    $$(elements).each(function(el){
	    	el.set('tween', {duration: 'short'});
	    	el.fade('in');
	    });
		break;
	case 'highlight':
	    $$(elements).each(function(el, id){
	    	if (id != index) {
		    	el.set('tween', {duration: 'short'});
	    		el.fade(0.5);
	    	}
	    });
		break;
	}
}
