function ScrollVideo(cont, path, settings) {
    var oThis = this;
    
    this.cache      = {};
    this.page       = 0;
    this.last_error = 0;
    this.timeout    = document.all ? 20 : (navigator.userAgent.indexOf("Firefox")!=-1 ? 20 : 15);
    
    !settings && (settings = {});
    !settings['speed'] && (settings['speed'] = 750);
    !settings['perpage'] && (settings['perpage'] = 5);
    !settings['last_page'] && (settings['last_page'] = 10);
    
    this.init = function (cont) {
        var left = document.createElement('a'),
            right = document.createElement('a'),
            clear = document.createElement('div'),
            videos = document.createElement('div');
        
        
        left.className = 'link-left';
        right.className = 'link-right';
        
        left.onclick = function () { oThis.scrollLeft(); };
        right.onclick = function () { oThis.scrollRight(); };
        
        this.h4 = prevNode(cont.parentNode);
        this.h4 = this.h4.firstChild.nodeType == 1 ? this.h4.firstChild : nextNode(this.h4.firstChild);
        settings.title = !settings.title || settings.title == '' ? this.h4.innerHTML : settings.title;
        this.print_title();
        
        videos.className = 'scroller';
        
        this.videos = document.createElement('div');
        this.videos.pages = [];
        this.videos.pages[0] = document.createElement('div');
        this.videos.pages[1] = document.createElement('div');
        
        
        this.videos.pages[0].className = 'video-list first';
        this.videos.pages[1].className = 'video-list last';
        
        this.videos.pages[0].is_visible = true;
        this.videos.pages[1].is_visible = false;
        
        this.videos.style.width = '9999px';
        this.videos.appendChild(this.videos.pages[0]);
        this.videos.appendChild(this.videos.pages[1]);
        
        videos.appendChild(this.videos);
        
        clear.className = 'clear';
        
        cont.className = 'video-scroll';
        cont.appendChild(left);
        cont.appendChild(videos);
        cont.appendChild(right);
        cont.appendChild(clear);
        
        this.getData(this.page, function (res) { oThis.videos.pages[0].innerHTML = res; if (Thumbs) (new Thumbs({delay: 900})).init(); });
    }
    
    this.getData = function (page, func) {
        if(this.cache[page]) {
            func(this.cache[page]);return;
        }
        
        var request = {
            url: path,
            data: { page: page},
            
            onSuccess: function (res) { oThis.cache[page] = res; func(res); },
            onFailure: function (res) { oThis.last_error = 1; }
        }
        
        AJAX(request);
    }
    
    this.scrollLeft = function() {
        if(this.page > 0) {
            this.getData(this.page-1, function (res) { oThis.slide('left', res);oThis.page--;oThis.print_title();});
        }
    }
    
    this.scrollRight = function() {
        if(this.last_error == 0) {
            this.getData(this.page + 1, function (res) { oThis.slide('right', res);oThis.page++;oThis.print_title();});
        }
    }
    
    this.slide = function (dir, res) {
        if (this.move_timeout) return;
        
        switch(dir) {
            case 'left':
                if(this.page == 0) return;
                
                if(this.videos.pages[0].is_visible == false) {
                    oThis.videos.pages[0].innerHTML = res;
                    this.videos.insertBefore(this.videos.pages[0], this.videos.pages[1]);
                    obj = this.videos.pages[0];
                    
                    this.videos.pages[0].style.marginLeft = -this.videos.pages[0].clientWidth+'px';
                    this.videos.pages[1].style.marginLeft = '0px';
                    
                } else {
                    oThis.videos.pages[1].innerHTML = res;
                    this.videos.insertBefore(this.videos.pages[1], this.videos.pages[0]);
                    obj = this.videos.pages[1];
                    
                    this.videos.pages[1].style.marginLeft = -this.videos.pages[0].clientWidth+'px';
                    this.videos.pages[0].style.marginLeft = '0px';
                }
                
                
                
                if (Thumbs) (new Thumbs({delay: 900})).init();
                
                var speed_px = this.videos.pages[0].clientWidth * this.timeout / settings.speed;
                
                !this.offset && (this.offset = this.videos.pages[0].clientWidth);
                
                this.move_timeout = setTimeout(function () {oThis.move_timeout = setInterval( function () {oThis.move(obj, 'left', speed_px); }, oThis.timeout );}, 120);
            break;
            
            case 'right':
                if(this.videos.pages[0].is_visible == false) {
                    oThis.videos.pages[0].innerHTML = res;
                    this.videos.insertBefore(this.videos.pages[1], this.videos.pages[0]);
                    obj = this.videos.pages[1];
                } else {
                    oThis.videos.pages[1].innerHTML = res;
                    this.videos.insertBefore(this.videos.pages[0], this.videos.pages[1]);
                    obj = this.videos.pages[0];
                }
                
                this.videos.pages[1].style.marginLeft = '0px';
                this.videos.pages[0].style.marginLeft = '0px';
                
                if (Thumbs) (new Thumbs({delay: 900})).init();
                
                var speed_px = this.videos.pages[0].clientWidth * this.timeout / settings.speed;
                
                !this.offset && (this.offset = 0);
                
                this.move_timeout = setTimeout(function () {oThis.move_timeout = setInterval( function () {oThis.move(obj, 'right', speed_px); }, oThis.timeout );}, 120);
            break;
        }
    }
    
    this.move = function (obj, dir, speed_px) {
        switch(dir) {
            case 'right':
                if(this.offset >= this.videos.pages[0].clientWidth) {
                    if (this.move_timeout) {
                        clearInterval(this.move_timeout);
                        delete this.move_timeout;
                    }
                    
                    obj.style.marginLeft = -this.videos.pages[0].clientWidth+'px';
                    obj.is_visible = false;
                    if (this.videos.pages[1] == obj) this.videos.pages[0].is_visible = true;
                    else this.videos.pages[1].is_visible = true;
                    
                    delete this.offset;
                    return;
                }
                
                obj.style.marginLeft = -this.offset+'px';
                
                this.offset += speed_px;
            break;
            
            case 'left':
                if(this.offset <= 0) {
                    if (this.move_timeout) {
                        clearInterval(this.move_timeout);
                        delete this.move_timeout;
                    }
                    
                    obj.style.marginLeft = '0px';
                    obj.is_visible = true;
                    if (this.videos.pages[1] == obj) this.videos.pages[0].is_visible = false;
                    else this.videos.pages[1].is_visible = false;
                    
                    delete this.offset;
                    return;
                }
                
                obj.style.marginLeft = -this.offset+'px';
                
                this.offset -= speed_px;
            break;
            
            
        }
    }
    
    this.print_title = function () {
        this.h4.innerHTML = settings.title + ' <strong>('+(this.page * settings.perpage + 1)+' to ' + ((this.page + 1) * settings.perpage) +' of '+settings.last_page * settings.perpage+')</strong>' ;
    }
    
    if(cont) this.init(cont);
}