//
// copyright 2007 Tom Dowling
			 <!--
				var loop = false
				
        function show_me(image_server) {
           var t = locateImage("CurrentPic");
           t.src= image_server;
           //alert(image_server + t);
					// var L = TheimgFiles.length;
					// TheimgFiles[L] = image_server;
					// if( Cursor == (L-1) ){ moveCursor(1,0); }
        }

        function get_image() {
           x_show_now(show_me);
           setTimeout("get_image()", 60*1000);
        }
				
        function start_imagetimer(){
                 setTimeout("get_image()", 60*1000);
                 
        }
                
				function show_Full(id, FullImage) {
					var theImage = locateImage(id);
					if( theImage ){
							theImage.src = FullImage;
					}
					
 				}
				
				function locateImage(name){
					var theImage = false;
						if( document.images ){
								theImage = document.images[name];
						}
						if( theImage ){
								return theImage;
						}
						return( false );
				}
				
// // // // // // // // // // // // // // // // // 
				// (c) copyright 2006 Tom Dowling
				//
				var TheimgFiles = new Array();  //global scope
				var CacheFlag = new Array(); //place to capture where we've preloaded
				var CacheImage = new Array(); //place to hold cached images
				var CacheThumb = new Array(); //place to hold cached thumbs
				var CacheFlagThumb = new Array(); //place to capture thumbs we've preloaded
				var Cursor; //pointer to current image
				var CursorDirection = -1; //play direction <0 means old to new
				var Playing = 0;  //flag to let us know we're playing
				var RequestStop = 0; //set this to stop at next op
				
				 
				function preloadImages(){  //get the list of images for the history bar
					TheimgFiles = preloadImages.arguments;
					 					
				}
				
				function selectImage(id, ImageIndex){
				  var theImage = locateImage(id);
 					var i =  parseInt(Cursor) - parseInt(ImageIndex);
					if( i < 1 ){ i = 1; }
					if( i > TheimgFiles.length ){ i = TheimgFiles.length; }
					//alert('index ' + i + ' cursor ' + Cursor );
					if( theImage ){
					         // here's our chance to preload more images
									// roll thru and see if we've cached already
							if( !CacheFlag[i] ){
									CacheFlag[i] = 1;
									CacheImage[i] = new Image(1280,960);
									CacheImage[i].src = TheimgFiles[0] + TheimgFiles[i];
									 
							}
							 
							theImage.src = CacheImage[i].src;
					}  
					if( theImage ){
								return theImage;
						}
						return( false );
				}
				
				
				
				function moveCursor(direction, request){
				  Cursor += parseInt(direction);
					if( request ){RequestStop = 1; } //stop Play if underway
					if( Cursor < 8 ){ //at base and dont need to move thumbs
							Cursor = 8;
					}else if( Cursor >= TheimgFiles.length ){
							Cursor = TheimgFiles.length -1; //cap Cursor to max
					}
					 	
						  for( i=0 ; i<8 ; i++ ){
								thumb = 'thumb'+i;
						  	theImage = locateImage(thumb);
							  j = Cursor -i;
							  if( theImage ){
									if( !CacheFlagThumb[j] ){
										CacheFlagThumb[j] = 1;
									  CacheThumb[j] = new Image(80,60);
									  CacheThumb[j].src = TheimgFiles[0] + 'T_' + TheimgFiles[j];
									}
									theImage.src = TheimgFiles[0] + 'T_' + TheimgFiles[j];
							  } 
					  	}
							selectImage('CurrentPic', 0); //show the full sized image at the Cursor
				}
				 
				 
				 function start_playCursor(direction){
				   CursorDirection = direction;
					 document.getElementById("play8").value = "Stop";
					 document.getElementById("play8").className = "activebg";
					 if( direction < 0 ){
					   document.getElementById("play1").className = "playonbg";
					   document.getElementById("play0").className = "";
					 }else{
					 	 document.getElementById("play1").className = "";
					   document.getElementById("play0").className = "playonbg";
					 }
					 RequestStop = 0; //let's get rolling
					if( !Playing ){
					  playCursor();	
					} //else we were playing so we'll just allow changing direction	 
				 }
				 
				 function playCursor( ){
				   if( Playing && RequestStop ){
					 		 Playing = 0;
							 RequestStop = 0;
							 document.getElementById("play1").className = "";
					     document.getElementById("play0").className = "";
							 document.getElementById("play8").value = "Loop";
							 document.getElementById("play8").className = "";
					 }else{
				     //if( Cursor >0 && Cursor < TheimgFiles.length ){ // as long as there is something to play, do it
					   if( Cursor < TheimgFiles.length ){
						   moveCursor(CursorDirection, 0); //move to newer pictures
					     setTimeout("playCursor()", 2000);
						   Playing = 1; //we're playing
							 if( Cursor == 8 ){RequestStop = 1;}  //we're sitting on oldest, so stop
				     }else{
					     Playing = 0; //we've stopped playing
							 RequestStop = 0; //clear pending request
					   }
					 }
				 }
				 
				 var CursorPlayEight;
				 var CursorPlayMax = 20; 
				 var Cmin = 1;
				 var Cmax = 60;
				  
					function maxChange(value){  //slider value comes here
				     CursorPlayMax = parseInt(Cmin + parseFloat(value) * (Cmax - Cmin));
						  				
					}
				
				  function start_playEight(max){
					 if( max > 0 ){ 
					   CursorPlayMax = max;
						 $('slider1').innerHTML='minutes: '+ CursorPlayMax;
					 }
					 CursorPlayEight = 0; //start at cursor
					 CursorDirection = 1;
					  
					 RequestStop = 0; //let's get rolling
					 document.getElementById("play1").className = "";
					     document.getElementById("play0").className = "";
					if( !Playing ){
						document.getElementById("play8").value = "Stop";
						document.getElementById("play8").className = "activebg";
						playEight();
					}else{
						RequestStop = 1;
					} 
				 }
				 
				 function playEight( ){  //fun with a quick loop thru the 8 preview thumbs
				   if( Playing && RequestStop ){
					 		 Playing = 0;
							 RequestStop = 0;
							 document.getElementById("play8").value = "Loop";
							 document.getElementById("play8").className = "";
					 }else{
				        
						   selectImage('CurrentPic', CursorPlayEight); //display pictures
					     setTimeout("playEight()", 100);
						   Playing = 1; //we're playing
							 CursorPlayEight += CursorDirection;
							 if( CursorPlayEight < 0 ){
							   CursorPlayEight = 1; CursorDirection = 1;}
							 else if( CursorPlayEight > CursorPlayMax ){
							 	 CursorPlayEight = CursorPlayMax -1; CursorDirection = -1;
							 }  //rotate as necessary
				     }
				 }	
				
				 function jumpToHour(httpfile){ //flip over to hour view
				 			
							var URL = httpfile + "?src=" + TheimgFiles[Cursor];
							 
							window.location = URL						
							 
							window.event.returnValue=false;
 
							return false ;
							 
					}
	 
	
	 
// // // // // // // // // // // // // // // // // 			 
				//-->

