// ImageLogic.js
	var g_images = [];
	
	var g_animationManager = new AnimationManager( 10 );	
	
	
	var g_current_slide = 0;
	var g_slides = [];
		
	g_animationManager.on_finished = function()
	{
		nohighlight(g_images[g_current_slide]);
		g_current_slide++;
  		if ( g_current_slide < g_slides.length ){  			
  			highlight(g_images[g_current_slide]);
  			pause(1000);
	  		g_slides[ g_current_slide ].start(); 	
		}

	}
			
	function loadImages(images){
		for (var i in images){
			var obj = document.getElementById(images[i]);			
			var ii = new ImageInfo( obj.src, obj.width, obj.height, obj )
			g_slides.push(new Animation( g_animationManager, ii,3,[new KenBurnsFader( ii, 100 )] ));	
		}
	}
	
	function loadObjects(images){
		for (var i in images){
			g_images.push(document.getElementById(images[i]));
		}
	}
		
	function rotate(){				
		loadImages(["photo1","photo2","photo3"]);
		loadObjects(["small1","small2","small3"]);		
		g_slides[ g_current_slide ].start();
	}
	
	function pause(numberMillis) {
        var now = new Date();
        var exitTime = now.getTime() + numberMillis;
        while (true) {
            now = new Date();
            if (now.getTime() > exitTime)
                return;
        }
    }
	
	//Swap classes for small images to change border color
	function highlight(obj){
		if (obj){
			obj.className="smallphotohighlight";
		}
	}
	
	function nohighlight(obj){
		if (obj){
			obj.className="smallphoto";
		}
	}