/*
 *	ImageBand class
 * 	
 * 	used for the content-box
 *
 * 	fades, scrolls appears the larger preview image (scroll_preview_band)
 *  scrolls the thumbnails band (scroll_left, scroll_right)
 *	de-/activates the left and right flesh for the thumbnails band
 *
 *	one addtional string helper function (contains)
 */
 
String.prototype.contains = function(t) { return this.indexOf(t) >= 0 ? true : false }


var ImageBand = {
	timeout: 0,
	preview_cur_pos: 0,
	
	scroll_preview_band : function (new_pos)
	{
		var scrollable = document.getElementById('content-box-image-preview-band-scrollable') ;
		if (-this.preview_cur_pos == new_pos) return ; 
		amount_to_scroll = -new_pos - this.preview_cur_pos ; 
		this.preview_cur_pos  = -new_pos ; 
		
		if (navigator.appName == "Microsoft Internet Explorer") {
			if (navigator.appVersion.contains('MSIE 6.0')) {
				Effect.MoveBy(scrollable, 0, amount_to_scroll, { duration: 0.0 }) ; return ; 
			}
		}
		
		Effect.Fade(scrollable, { duration: 0.1}) ; 
		this.timeout = setTimeout(function(){ Effect.MoveBy(scrollable, 0, amount_to_scroll, { duration: 0.0 })}, 100) ;
		this.timeout = setTimeout(function(){ Effect.Appear(scrollable, { duration: 0.1})}, 100) ; 
	},
	
	scroll_left : function ()
	{
		clearTimeout(this.timeout) ;
		var scrollable = document.getElementById('content-box-band-scrollable') ; 
		var parent = document.getElementById('content-box-band') ; 
		var cur_pos = scrollable.offsetLeft ; 
		if (cur_pos < 0 && cur_pos % 635 == 0) 
		{
			this.timeout = setTimeout(function(){ new Effect.MoveBy(scrollable, 0, 635, { duration: 0.5}) },10) ;
			if (cur_pos + 635 == 0) {
				ImageBand.disable_flesh_left() ;
			}
			if (cur_pos + scrollable.offsetWidth > 0){
				ImageBand.enable_flesh_right() ;
			}
		}
	},
	
	scroll_right : function ()
	{
		clearTimeout(this.timeout) ;
		var scrollable = document.getElementById('content-box-band-scrollable') ;
		var parent = document.getElementById('content-box-band') ;
		var cur_pos = -scrollable.offsetLeft ; 
		if (cur_pos + 635 < scrollable.offsetWidth && cur_pos % 635 == 0)
		{
			this.timeout = setTimeout(function(){ new Effect.MoveBy(scrollable, 0, -635, { duration: 0.5 }) },10) ;
			if (cur_pos + 2 * 635 >= scrollable.offsetWidth) {
				ImageBand.disable_flesh_right() ;
			}
			if (cur_pos == 0) {
				ImageBand.enable_flesh_left() ;
			}
		}
	},
	
	enable_flesh_left : function ()
	{
		var flesh_left = document.getElementById('flesh-left') ; 
		flesh_left.src = '/interface/flesh-left.gif' ; 
	},
	
	disable_flesh_left : function ()
	{
		var flesh_left = document.getElementById('flesh-left') ; 
		flesh_left.src = '/interface/flesh-left-disabled.gif' ; 
	},
	
	enable_flesh_right : function ()
	{
		var flesh_right = document.getElementById('flesh-right') ; 
		flesh_right.src = '/interface/flesh-right.gif' ; 
	},
	
	disable_flesh_right : function ()
	{
		var flesh_right = document.getElementById('flesh-right') ; 
		flesh_right.src = '/interface/flesh-right-disabled.gif' ; 
	}
};
