﻿// JScript File
var TmpstVerticalScroller = new Class({
	initialize: function(element, options) {
		this.setOptions({
		    imageCount: 0,
            
			thmbScrollerMinimizedOpacity: 0.4,
			thmbScrollerMinimizedHeight: 20,
			thmbScrollerMaximizedOpacity: 0.4

		}, options);
		this.imageCount = this.options.imageCount;
		this.thmbScrollerWrapper = element;
		this.thmbScrollerElement = $("photogallery_thumbnails");
		this.initThmbScroller();
		this.currentThmbIndex = null;
	},
	initThmbScroller: function () {
	    this.thmbScrollerWrapper.scroller = new Scroller(this.thmbScrollerElement, {
		    area: 50,
		    velocity: 0.1
	    })
    	
	    this.thmbScrollerWrapper.elementScroller = new Fx.Scroll(this.thmbScrollerWrapper, {
		    duration: 400,
		    onStart: this.thmbScrollerWrapper.scroller.stop.bind(this.thmbScrollerWrapper.scroller),
		    onComplete: this.thmbScrollerWrapper.scroller.start.bind(this.thmbScrollerWrapper.scroller)
	    });
	    
	    this.thmbScrollerWrapper.elementScroller.scrollTo(0,0);
	    
		for(i=0;i<this.imageCount;i++)
		{
		    var oThmb = new Fx.Style($('photogallery_thumbnail' + (i+1)), "opacity", {duration: 200}).set(0.4);
		    oThmb.thmbIndex = (i+1);
		    
		    if(i == 0){
		        this.currentThmb = oThmb;
		        oThmb.clearTimer();
		        oThmb.custom(0.99);
		    }
		    
    		oThmb.element.addEvents({
		        'mouseover': function (myself) {
			        myself.clearTimer();
			        myself.custom(0.99);
		        }.pass(oThmb, this),
		        'mouseout': function (myself) {
		            if(this.currentThmb.thmbIndex != myself.thmbIndex){
			            myself.clearTimer();
			            myself.custom(0.4);
			        }
		        }.pass(oThmb, this),
		        'click': function (myself) {
		            if(this.currentThmb.thmbIndex != myself.thmbIndex){
		                this.currentThmb.clearTimer();
		                this.currentThmb.custom(0.4)
		            }
		            this.currentThmb = myself;
					myself.custom(0.99);
				}.pass(oThmb, this)
			});
		}
	    
    }
});

TmpstVerticalScroller.implement(new Events);
TmpstVerticalScroller.implement(new Options);
