// JavaScript Document
window.addEvent('domready', function(){	

	// rollover for angebote home
	var homeangebote = $$('#items ul li a');
	homeangebote.addEvent('mouseover', function(event){
		if (this.className != 'act') {
			this.style.backgroundImage = this.style.backgroundImage.replace('.gif','_ro.gif');
		}
	});
	homeangebote.addEvent('mouseout', function(event){
		if (this.className != 'act') {
			this.style.backgroundImage = this.style.backgroundImage.replace('_ro.gif','.gif');
		}
	});
	
	
	// scroll for home
	// determine maxium scroll (end of angebote)
	var maxscroll = (homeangebote[0].getSize().size.x+5)*homeangebote.length-$('items').getSize().size.x;
	//
	var periodical;
	// scroll right
 	var scrollRight = function() {
		var xitems = $('items').getSize().scroll.x;	
		xitems+=5;
		if (xitems <= maxscroll) {
			$('items').scrollTo(xitems, 0);
		}
	}
	$('arrow-right').addEvent('mouseover', function(event){
		scrollRight();
		periodical = scrollRight.periodical(15);
	});
	$('arrow-right').addEvent('mouseout', function(event){
		$clear(periodical);
	}); 
	// scroll left
	var scrollLeft = function() {
		var xitems = $('items').getSize().scroll.x;	
		xitems-=5;
		$('items').scrollTo(xitems, 0);
	}
	$('arrow-left').addEvent('mouseover', function(event){
		scrollLeft();
		periodical = scrollLeft.periodical(15);
	});
	$('arrow-left').addEvent('mouseout', function(event){
		$clear(periodical);
	});
});