// ie, the roots of all the image names  (for plotBlank, plot is the root) 
// the following is the convention where 'img' is one of the above entries... 
//  -	img.jpg = 		the image at less than 100 opacity... not rolled over
// 	-	img.gif = 		the animation to get it from 0 to img.jpg 
//  -	imgBlank.jpg =	the image underneath the animated image, i.e., the calendar
//  - 	img-Over.jpg = 	the image at full blast opacity.. .


				


 var imgs= [ "bios" , "familyTrees" ,"wallpapers" ,"plots", "loveStories" ];
 var imgObs =[]; 

		// the basic thread constants well need 
var delay = 3000 ;
var refName = 'stateHandler();' ;
var last  ;

		// the class that will help me manipulate images...
function ImageState(   s){
	var root = s;
	var img =document.images[s] ;
	var b  ="images/index/" ;
	var over = false; 
	this.animate = function()  
		{img.src = b+ root+".gif";  };
 	this.getRoot = function()
		 { return root; } ;
	this.showAll = function ()
		 { img.src = b+root+ "-over.jpg" ; };
	this.show = function() 
		{ img.src = b+root+".jpg" ;} ;
	this.hide = function() 
		{ img.src =b+ root + "Blank.jpg" ;   };
	this.isOver = function() 
		 { return over; };
	this.setOver = function( s){
 		 over = s; } ; 
}
 	// handles the main algorithm
function stateHandler () {

	for(var i=0;i< imgObs.length ;i++){ 

			if( Math.random() > .4 ) {
				if( i!= last ) 	{
					if(  !imgObs[i].isOver() ) {
						imgObs[i].animate() ;
						last= i ;
					 }
				} else { 
					if( i-1 >= 0) {
						if( !imgObs[i-1].isOver()  ) {
							imgObs[i-1].animate () ; 
							last = i-1 ;
						}
					}
					else {
						if(  !imgObs[i+1].isOver() ) {
							last =i+1 ;
							imgObs[i+1].animate () ;
						}
					}
				}
			last=i; 
		} else {	
			if( !imgObs[i].isOver()) 
							imgObs[i].hide();
		}	  
	}
	window.setTimeout(refName ,delay) ;
}

 
 
 
 
 
 
 
 
 
 
// utility stuff.....
// get it? MM = Macromedia..
// SM = Steve Miggas? oh boy that's 'punny'
function SM_show (name) {
	for(var i=0;i< imgObs.length ;i++) 
		if(imgObs[i].getRoot() == name) 
		{
			imgObs [i].setOver(true) ;
			imgObs[i].showAll( ) ; 
			return ; 
		}

	
} 
function SM_hide ( name) {
	for(var i=0;i< imgObs.length ;i++) 
		if(imgObs[i].getRoot() == name) 
		{
			imgObs [i].setOver(false) ;
			imgObs[i].hide() ; 
			return ; 
		}
	 }

