// JavaScript Document
// boat gallery function
//for thumbnail bar
	var imgLeft=1; 	 
	var imgRight=4;	 
	
	//for slide show
	var autoIndex=0; 
	var gallery = new Array();
	var text = new Array();
	var title = new Array();
	var imgGal = new Array(); //for preload function
	
	var imgLeft_act='../../images/liveaboards/nav_left.jpg';
	var imgLeft_ina='../../images/space.gif';
	var imgRight_act='../../images/liveaboards/nav_right.jpg';
	var imgRight_ina='../../images/space.gif';
	function thumPrev(){
		if(gallery.length<=imgRight){
			$('imgThmLeft').src=imgLeft_ina;
			$('imgThmRight').src=imgRight_ina;
		}else{
		  if(imgLeft>0){
			imgLeft  = (imgLeft - 1);
			imgRight = (imgRight - 1);
			thumb();
			$('imgThmLeft').src=imgLeft_act;
			$('imgThmRight').src=imgRight_act;

		  }else{		
			$('imgThmLeft').src=imgLeft_ina;
		  }
		}
	}
	function thumNext(){
		if(gallery.length<=imgRight){
			$('imgThmLeft').src=imgLeft_ina;
			$('imgThmRight').src=imgRight_ina;
		}else{
		  if(imgRight< (gallery.length-1)){
			imgLeft  = (imgLeft + 1);
			imgRight = (imgRight + 1);
			thumb();
			$('imgThmLeft').src=imgLeft_act;
			$('imgThmRight').src=imgRight_act;
		  }else{
			$('imgThmLeft').src=imgLeft_act;
			$('imgThmRight').src=imgRight_ina;
		  }
		}
	}
	function thumb(){
		for(var i=0;i<gallery.length;i++){
			var name= 'thumb'+i;
			if(i>=imgLeft && i<=imgRight) $(name).show();
			else $(name).hide();
		}
	}
	function setPicNumDiv(){
		var strshow = parseInt(autoIndex) + 1;
		$('picNum').update(strshow);
	}
	
	var t; //time var
	var speed = 5; //time to change picture(seconds)
	function autoSlideBigImage(){
		
		$('imgBig').src=imgGal[autoIndex].src;//gallery[autoIndex];
		$('imgBig').title=title[autoIndex];
		$('imgBig').alt=title[autoIndex];

		$('showText').update(text[autoIndex]);	
		setPicNumDiv();
		autoIndex++;
		if(autoIndex==imgGal.length) autoIndex=0;
		
		speed = $('selSpeed').options[$('selSpeed').selectedIndex].value;
		t = setTimeout("autoSlideBigImage()",(parseInt(speed)*1000));
		
	}
	function changeBigImage(index){
		btPause_click();
		autoIndex=index;		
		$('imgBig').src=imgGal[autoIndex].src;//gallery[autoIndex];
		$('imgBig').title=title[autoIndex];
		$('imgBig').alt=title[autoIndex];
		
		$('showText').update(text[autoIndex]);		
		setPicNumDiv();
		
	}
	function btStart_click(){
		speed = $('selSpeed').options[$('selSpeed').selectedIndex].value;
		
		$('btStart').hide();
		$('btPause').show();
		
		autoSlideBigImage();
	}
	function btPause_click(){
		clearTimeout(t);
		$('btStart').show();
		$('btPause').hide();
	}
	function btLeft_click(){
		btPause_click();
		autoIndex = parseInt(autoIndex)-1;
		if(autoIndex < 0) autoIndex=(imgGal.length - 1);
		
		changeBigImage(autoIndex);
	}
	function btRight_click(){
		btPause_click();
		
		autoIndex = parseInt(autoIndex)+1;		
		if(autoIndex >= imgGal.length) autoIndex=0;
		
		changeBigImage(autoIndex);
	}
