
window.addEvent('domready',function(){
	
	if (typeof(_items) != 'undefined') {
		var startItem = 0; //or   0   or any
		//var thumbs_mask = $('thumbs_mask').setStyle('left',(startItem*891)+'px').set('opacity',0.8);
		var fxOptions = {property:'left',duration:1000, transition:Fx.Transitions.Sine.easeOut, wait:false}
		
		var nS = new noobSlide({
			size: 710,
			box: $('all_pictures'),
			items: _items,
			autoPlay: true,
			handles: $$('#thumbs_images div'),
			fxOptions: fxOptions,
			onWalk: function(currentItem){
				
			// TODO: set the left and right hand navigation links on the main image.
				if (this.nextIndex != 0) {
					$('next_photo').addClass('next_enabled');
					//alert("can go next");
				} else {
					$('next_photo').removeClass('next_enabled');
				}
				
				if (this.previousIndex != (this.items.length - 1)) {
					$('prev_photo').addClass('prev_enabled');
					//alert("can go next");
				} else {
					$('prev_photo').removeClass('prev_enabled');
				}
				
				$$('.gallery_thumb').each(function(item){
					item.setProperty('src', 'images/gallery_off.gif');
				})
				$('thumbnail_' + (currentItem*1)).setProperty('src', 'images/gallery_on.gif');
			
			},
			startItem: startItem
		});
		//walk to first with fx
		nS.walk(0);
		
		$('next_photo').addEvent('click', function(){
			if (nS.nextIndex != 0) {
				nS.walk(nS.nextIndex);
			}
		});
		
		$('prev_photo').addEvent('click', function(){
			if (nS.previousIndex != (nS.items.length - 1)) {
				nS.walk(nS.previousIndex);
			}
		});
	}
	

});
