window.addEvent('domready', function() {

	var hC = 0;

	$('super_prev').addEvent('click', function() {
		hC = hC-1;
		var req = new Request.HTML({
			url: 'http://' + location.hostname + '/inc_super_oferta/offset/' + hC,
			method: 'get',
			onComplete: function() {
				var p = new Preloader();
				$$('.preSuperOferta img').each(function(img) {
				p.addEventOnLoad(img.src, function() {
					img.getParent().setStyle('background', 'none');
					img.setStyle('opacity', 0)
					img.style.display = 'block';
					img.tween('opacity', 1)
				});
				p.addToQueue(img.src);
			});
			},
			update: 'super_oferta_okno'}).send();
	});

	$('super_next').addEvent('click', function() {
		hC = hC+1;
		var req = new Request.HTML({
			url: 'http://' + location.hostname + '/inc_super_oferta/offset/' + hC,
			method: 'get',
			onComplete: function() {
				var p = new Preloader();
				$$('.preSuperOferta img').each(function(img) {
				p.addEventOnLoad(img.src, function() {
					img.getParent().setStyle('background', 'none');
					img.setStyle('opacity', 0)
					img.style.display = 'block';
					img.tween('opacity', 1)
				});
				p.addToQueue(img.src);
			});
			},
			update: 'super_oferta_okno'}).send();
	});

	if( $('super_oferta') ) {
		$$('div.super_produkt').addEvents({
			'mouseenter': function(){
				this.tween('background-image', 'url(../../grafika/super_wybrana.gif)');
			},
			'mouseleave': function(){
				this.tween('background-image', 'none');
			}
		});
	}

	if( $('super_prev') ) {
		$('super_prev').addEvents({
			'mouseenter': function(){
				this.tween('background-image', 'url(../../grafika/super_prev_pressed.gif)');
			},
			'mouseleave': function(){
				this.tween('background-image', 'url(../../grafika/super_prev.gif)');
			}
		});
	}

	if( $('super_next') ) {
		$('super_next').addEvents({
			'mouseenter': function(){
				this.tween('background-image', 'url(../../grafika/super_next_pressed.gif)');
			},
			'mouseleave': function(){
				this.tween('background-image', 'url(../../grafika/super_next.gif)'); 
			}
		});
	}

});
