// JavaScript Document

var HeaderScrollingManager = {
	
	init: function(){
		
		if($('header_scrolling_elements')){
			new NoobSlide({
						//mode: 'vertical',
						box: $('header_scrolling_elements'),
						items: $$('#header_scrolling_elements .header_scrolling_elements_item'),
						size: 966,
						fxOptions:{
							duration: 1500,
							wait: false
						},
						addButtons:{
							previous: $('header_scrolling_navigations_previous'), 
							next: $('header_scrolling_navigations_next')
						},
						onWalk: function(){
							if(this.items.length == 1){
								if($('header_scrolling_navigations_previous')){
									$('header_scrolling_navigations_previous').setStyle('z-index','-10');
								}
								if($('header_scrolling_navigations_next')){
									$('header_scrolling_navigations_next').setStyle('z-index','-10');
								}
								return;
							}
							if(this.currentIndex == 0){
								if($('header_scrolling_navigations_previous')){
									$('header_scrolling_navigations_previous').setStyle('z-index','-10');
								}		
								if($('header_scrolling_navigations_next')){
									$('header_scrolling_navigations_next').setStyle('z-index','10');
								}
							}else if(this.currentIndex == (this.items.length-1)){
								if($('header_scrolling_navigations_next')){
									$('header_scrolling_navigations_next').setStyle('z-index','-10');
								}
								if($('header_scrolling_navigations_previous')){
									$('header_scrolling_navigations_previous').setStyle('z-index','10');
								}
							}else{
								if($('header_scrolling_navigations_next')){
									$('header_scrolling_navigations_next').setStyle('z-index','10');
								}
								if($('header_scrolling_navigations_previous')){
									$('header_scrolling_navigations_previous').setStyle('z-index','10');
								}
							}
						}
						
				}
			);
		}
	}
	
};

window.addEvent('domready', function(){	
		HeaderScrollingManager.init();
	}
);

