/***********************************************************************
*
*	thumbmenu.js: Functionality for Dynamic Image Menu
*	Written 2007 by Rich Fallis, developer@ecommercialpro.com
*
************************************************************************/

var selected_div='';			// Initialize name of thumb holder div as global
var scroller=0;					// Initialize timer integer as global
var slow=80;					// Interval in ms
var fast=40;					// Interval in ms
var step_size=0;				// Global to step vars
var slow_step=2;				// Distance traveled per function call of list_up()/list_down() at slow rate
var fast_step=12;				// Distance traveled per function call of list_up()/list_down() at fast rate
var div_height=90;				// Height of the divs containing the images
var container_height=445;		// Height of the div or iframe containing this collection

/** Defined on calling page:
var selected					// Item selected
var i							// Increment/Decrement position
var scroll_limit				// Set limit for scrolling down
**/

function set_opacity(obj, opacity) {
	obj.style.opacity = opacity;
	obj.style.filter = 'alpha(opacity=' + opacity*100 + ')';
}

function init(){
	if(i!=0)
		set_opacity(document.getElementById('up'), 1.0);
	if(i==scroll_limit)
		set_opacity(document.getElementById('down'), .5);
	selected_string='image_holder_'.selected;
	div=document.getElementById(selected_string);
}

function show_selection(obj){
	current_div=document.getElementById('image_holder_'+selected);
	current_div.style.backgroundImage='url(/images/clear_pixel.gif)';
	new_div_string='image_holder_' + obj.id.substr(6);
	new_div=document.getElementById(new_div_string);
	new_div.style.backgroundImage='url(/images/border-thumb.jpg)';
	selected=obj.id.substr(6);
}


function list_up(){
	if(i<0)	set_opacity(document.getElementById('up'), 1.0);
	if(i>scroll_limit){
		set_opacity(document.getElementById('down'), 1.0);
		i=i-step_size;
		document.getElementById('carrier_div').style.top=i + 'px';
		}
	else
		set_opacity(document.getElementById('down'), .5);
	}
	
function list_down(){
	if(i>scroll_limit)	set_opacity(document.getElementById('down'), 1.0);
	if(i<0){
		set_opacity(document.getElementById('up'), 1.0);
		i=i+step_size;
		document.getElementById('carrier_div').style.top=i + 'px';
		}
	else
		set_opacity(document.getElementById('up'), .5);
	}
	
function go_up(rate){
	(rate==slow) ? step_size=slow_step : step_size=fast_step;
	scroller=clearInterval(scroller);
	scroller=setInterval('list_up()', rate);
	}
	
function go_down(rate){
	(rate==slow) ? step_size=slow_step : step_size=fast_step;
	scroller=clearInterval(scroller);
	scroller=setInterval('list_down()', rate);
	}
	
function halt(){
	scroller=clearInterval(scroller);
	}