

newJsScroller = {
	scrollerNrElements : 4,
	create : function(params){
		var container = $(params.container);

		var divs = $(params.container).getElementsByTagName("div");
		var lnks = $(params.container).getElementsByTagName("a");

		container.innerContainer = divs[1];
		container.innerMask = divs[0];
		container.scrollElements = [];
		container.scrollIndex = 0;
		container.maxScrollIndex = 0;

		container.mainScroll = new Fx.Scroll(container.innerMask, {
			wait: false,
			duration: 1000,
			offset: {'x': 0, 'y': 0},
			transition: Fx.Transitions.Quad.easeInOut
		});

		var children = container.innerContainer.childNodes;
		for (var i=0; i<children.length; i++){
			if (children[i].id && whi.has_class(children[i], 'front_scroll_element')){
				children[i].scrollElementId = container.scrollElements.push(children[i])-1;
			}
		}
		container.maxScrollIndex = container.scrollElements.length-1;


		container.left_arrow = lnks[0];
		container.left_arrow.parentScroll = container;
		container.left_arrow.onclick = this.scrollLeft;

		container.right_arrow = lnks[lnks.length - 1];
		container.right_arrow.parentScroll = container;
		container.right_arrow.onclick = this.scrollRight;

		this.checkDisableArrows.apply(container);

		//mainScroll.toElement('photo_'+scrollPicId);

	},
	checkDisableArrows : function(){
		if (this.scrollIndex == 0){
			whi.add_class(this.left_arrow,'scroller_left_arrow_disabled');
		}else{
			whi.remove_class(this.left_arrow,'scroller_left_arrow_disabled');
		}
		if (this.scrollIndex >= this.maxScrollIndex - newJsScroller.scrollerNrElements){
			whi.add_class(this.right_arrow,'scroller_right_arrow_disabled');
		}else{
			whi.remove_class(this.right_arrow,'scroller_right_arrow_disabled');
		}
	},
	scrollLeft : function(){
		var to_id = '';
		if (this.parentScroll.scrollIndex - newJsScroller.scrollerNrElements >= 0){
			this.parentScroll.scrollIndex -= newJsScroller.scrollerNrElements;
			to_id = this.parentScroll.scrollElements[this.parentScroll.scrollIndex].id;
		}/* else if(this.parentScroll.scrollIndex != 0){
			this.parentScroll.scrollIndex = 0;
			to_id = this.parentScroll.scrollElements[this.parentScroll.maxScrollIndex].id;
		} */
		if (to_id !='' ){
			this.parentScroll.mainScroll.toElement(to_id);

			newJsScroller.checkDisableArrows.apply(this.parentScroll);
		}
	},
	scrollRight : function(){
		var to_id = '';
		if (this.parentScroll.scrollIndex + newJsScroller.scrollerNrElements <= this.parentScroll.maxScrollIndex){
			this.parentScroll.scrollIndex += newJsScroller.scrollerNrElements;
			to_id = this.parentScroll.scrollElements[this.parentScroll.scrollIndex].id;
		}/* else if(this.parentScroll.scrollIndex != this.parentScroll.maxScrollIndex){
			this.parentScroll.scrollIndex = this.parentScroll.maxScrollIndex - 4;
			to_id = this.parentScroll.scrollElements[this.parentScroll.scrollIndex].id;
		} */
		if (to_id !='' ){
			this.parentScroll.mainScroll.toElement(to_id);

			newJsScroller.checkDisableArrows.apply(this.parentScroll);
		}
	}
}
