function makeScrollbar(content,scrollbar,handle,horizontal,ignoreMouse){
	var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y));
    
    var parts = Math.ceil((horizontal?(content.getScrollSize().x/content.getSize().x):(content.getScrollSize().y/content.getSize().y)));
	
    if (content.getScrollSize().y <= content.getHeight()) {
			$('scroll').setStyle('display', 'none');
			return false;
	}
    else {
            $('scroll').setStyle('display', 'block');
    }
	
    var slider = new Slider(scrollbar, handle, {
        snap: true,
		steps: steps,
        offset: -14,
		mode: (horizontal?'horizontal':'vertical'),
		onChange: function(step){
			// Scrolls the content element in x or y direction.
          var x = (horizontal?step:0);
          var y = (horizontal?0:step);
			
            content.scrollTo(x,y);
		}
	}).set(0);
    
	if( !(ignoreMouse) ){
		// Scroll the content element when the mousewheel is used within the 
		// content or the scrollbar element.
		$$(content, scrollbar).addEvent('mousewheel', function(e){	
			e = new Event(e).stop();
			var step = slider.step - e.wheel * 30;	
			slider.set(step);					
		});
	}
	// Stops the handle dragging process when the mouse leaves the document body.
	$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
}
			
window.addEvent('domready', function(){
    if($('scroll')) makeScrollbar( $('content-scroll-area'), $('scroll'), $('scroll-handle') );
// new  one - begin

    if($('vino_scroll')) {
        var myScroll = new Fx.Morph('vino_scroll', {duration: 'long', transition: Fx.Transitions.Sine.easeOut});
        
        var intervalPrev;
        var intervalNext;
        
        var vino_scroll_width = $('vino_scroll').getElements('.w-20').length * 78;
        $('vino_scroll').setStyle('width', vino_scroll_width + 'px');
        
        $('vino_prev').addEvent('mouseover', function(){
            intervalPrev=setInterval(function(){
                if($('vino_scroll').getStyle('left').toInt() < 0) {
                //  console.log(Math.abs($('vino_scroll').getStyle('left').toInt()) + '.' +   $('vino_scroll').getStyle('left').toInt())
                    myScroll.start({'left': $('vino_scroll').getStyle('left').toInt()+78});
                }
            },1)
            
            return false;
        });
        
        $('vino_next').addEvent('mouseover', function(){
            intervalNext=setInterval(function(){
                if(vino_scroll_width + $('vino_scroll').getStyle('left').toInt() > 78*5) {
             // console.log(Math.abs($('vino_scroll').getStyle('left').toInt()) + '.' + $('vino_scroll').getStyle('left').toInt());
                    myScroll.start({'left': $('vino_scroll').getStyle('left').toInt()-78});
                }
            },1)   
            return false;
        }); 
        
        $('vino_prev').addEvent('mouseout', function(){clearInterval(intervalPrev)});
        $('vino_next').addEvent('mouseout', function(){clearInterval(intervalNext)});
    }

// new  one - end
    
    if(typeof window.showContainer == 'function') {
        showContainer();
    }
    if(typeof window.addMenuEvents == 'function') {
        addMenuEvents();
    }
    if(typeof window.initialReload == 'function') {
        initialReload();
    }
//    makeWineScroll();
});

function makeWineScroll() {
    if($('vino_scroll')) {
        var myScroll = new Fx.Morph('vino_scroll', {duration: 'long', transition: Fx.Transitions.Sine.easeOut});
        
        var vino_scroll_width = $('vino_scroll').getElements('.w-20').length * 78;
        $('vino_scroll').setStyle('width', vino_scroll_width + 'px');
        
        $('vino_prev').addEvent('mouseover', function(){
            if(Math.abs($('vino_scroll').getStyle('left').toInt()) > 0) myScroll.start({'left': $('vino_scroll').getStyle('left').toInt()+78});
            return false;
        });
        
        $('vino_next').addEvent('mouseover', function(){
            if(Math.abs($('vino_scroll').getStyle('left').toInt()) < vino_scroll_width-5*78) myScroll.start({'left': $('vino_scroll').getStyle('left').toInt()-78});
            return false;
        }); 
    }
}

function showContainer() {
//	$('content-area').fade('in', {duration: 5000, wait: true});
	$('content-area').tween('opacity', [0, 1], {duration: 10000});
}

function hideContainer() {
    $('content-area').tween('opacity', [1, 0], {duration: 10000});
}
