
var SlideShow = new (function() {
    var clipWidth = 345;
    var clipHeight = 140;
    var clipLeft = 0;
    var left = 0;
    var lyrwidth = 0;
    var time,amount,theTime,theHeight,DHTML;

    function initSlideShow() {

    	DHTML = (document.getElementById || document.all || document.layers)
    	if (!DHTML) return;
    	
    	var x = new getObj('slideshow');
    	
    	elems = pDomApi.getElementsByClassName(eId('slideshow'), 'div', 'productsBarProduct');
    	width = elems.length * 116;
    	
    	eId('slideshow').style.width = width + 'px';
    	
    	if (document.getElementById || document.all) {
    		lyrwidth = x.obj.offsetWidth;
    		x.style.clip = 'rect(0px,'+(clipLeft+clipWidth)+'px,'+clipHeight+'px,'+clipLeft+'px)';
    	}
    }

    function scrollayer(layername,amt,tim) {
    	if (!DHTML) return;
    	thelayer = new getObj(layername);
    	if (!thelayer) return;
    	amount = amt;
    	theTime = tim;
    	realscroll();
    }

    function realscroll() {
    	if (!DHTML) return;

    	clipLeft += amount;
    	left -= amount;

    	if (clipLeft < 0 || clipLeft+clipWidth > lyrwidth) {
    		clipLeft -= amount;
    		left += amount;
    		return;
    	}
    	if (document.getElementById || document.all) {
    		clipstring = 'rect(0px,'+(clipLeft+clipWidth)+'px,'+clipHeight+'px,'+clipLeft+'px)';
    		thelayer.style.clip = clipstring;
    		thelayer.style.left = left + 'px';
    	}
    	time = setTimeout(realscroll,theTime);
    }

    function stopScroll() {
    	if (time) clearTimeout(time);
    }

    pDomApi.addEvent(window, 'load', initSlideShow);
    pDomApi.addEvent(window, 'domload', function() { actionAttacher.attach(); });
    actionAttacher.addTagEvent(new PrezentDomApi.TagEvent('a', 'slideScrollRight', 'mouseover', function() { scrollayer('slideshow',3,10); return false; }));
    actionAttacher.addTagEvent(new PrezentDomApi.TagEvent('a', 'slideScrollRight', 'mouseout', stopScroll));
    actionAttacher.addTagEvent(new PrezentDomApi.TagEvent('a', 'slideScrollLeft', 'mouseover', function() { scrollayer('slideshow',-3,10); return false; }));
    actionAttacher.addTagEvent(new PrezentDomApi.TagEvent('a', 'slideScrollLeft', 'mouseout', stopScroll));
})();
