/*******************************************************************************
* Filmstrip Script
* Description: This creates a navigational filmstrip
* Copyright © 2009 by Andrew Y. Tan. All Rights Reserved.
*******************************************************************************/

// Move Filmstrip Left
function move_filmstrip_left() {
	
	// If the filmstrip has not reached the end, move left
	if (filmstrip_left > ((-1)*(filmstrip_num_strips)*filmstrip_width)) {
		
		// Move Filmstrip Left Animation
		for (var i=0; i<filmstrip_width/filmstrip_speed; i++) {
			filmstrip_left -= filmstrip_speed;
			setTimeout("document.getElementById('filmstrip').style.left='"+filmstrip_left+"px'",5*i);
		}
	
	}
}

// Move Filmstrip Right
function move_filmstrip_right() {
	
	// If the filmstrip has not reached the end, move right
	if (filmstrip_left < 0) {
		
		// Move Filmstrip Right Animation
		for (var i=0; i<filmstrip_width/filmstrip_speed; i++) {
			filmstrip_left += filmstrip_speed;
			setTimeout("document.getElementById('filmstrip').style.left='"+filmstrip_left+"px'",5*i);
		}
	
	}
}

// Move Filmstrip To Item
function move_to_filmstrip_item(id) {
	
	// If the filmstrip is to the left of the desired item, move right
	if (filmstrip_left < ((-1)*filmstrip_width*(id-1))) {
		
		var steps = (((-1)*((filmstrip_width*(id-1))+filmstrip_left))/filmstrip_speed);
		// Move Filmstrip Left Animation
		for (var i=0; i<steps; i++) {
			filmstrip_left += filmstrip_speed;
			setTimeout("document.getElementById('filmstrip').style.left='"+filmstrip_left+"px'",5*i);
		}
		
	}
	
	// If the filmstrip is to the right of the desired item, move left
	if (filmstrip_left > ((-1)*filmstrip_width*(id-1))) {
		
		var steps = ((filmstrip_left+(filmstrip_width*(id-1)))/filmstrip_speed);
		// Move Filmstrip Left Animation
		for (var i=0; i<steps; i++) {
			filmstrip_left -= filmstrip_speed;
			setTimeout("document.getElementById('filmstrip').style.left='"+filmstrip_left+"px'",5*i);
		}
		
	}
}
