
var Tools = {

	opacity : function( node, value ) {
	
		node.style.filter='alpha(opacity='+(value*100)+')';
		node.style.MozOpacity= value;
		node.style.KhtmlOpacity = value;
		node.style.opacity   = value;	
		
		if( value == 1 ) {
			node.style.filter = null;
			node.style.MozOpacity = null;
			node.style.KhtmlOpacity = null;
		}
	},
	
	select : function( node ) {
	
		if( node.getAttribute( 'id' ) != 'selected-tab' ) {
			
			var oldNode = document.getElementById( 'selected-tab' );
			var oldTab = document.getElementById( oldNode.getAttribute( 'tab' ) );
			var newTab = document.getElementById( node.getAttribute( 'tab' ) );
			
			oldTab.style.display = 'none';
			newTab.style.display = 'block';
			
			oldNode.setAttribute( 'id', '' );
			node.setAttribute( 'id', 'selected-tab' );
			
		}
	}
}


function Displayer( o, min, max, speed, max_start ) {

	this.isMoving = false;
	this.node = o;
	this.isShowing = false;
	this.value = max_start ? max : min;
	this.min = min;
	this.max = max;
	this.speed = speed ? speed : 10;
7
	if( !document.displayers ) {
		document.displayers = new Array();
	}
	
	this.i = document.displayers.length;
	document.displayers[this.i] = this;
	
	Tools.opacity( o, this.value/100 );

	this.show = function() {
		this.isShowing = true;
		this.start();
	}
	
	this.hide = function() {
	
		this.isShowing = false;
		this.start();
	}
	
	this.start = function() {
	
		if( !this.isMoving ) {
			this.isMoving = true;
			this.update();
		}
	}
	
	this.update = function() {

		if( this.isShowing ) {
			this.value+=5;

			if( this.value > this.max ) {
				return this.end();
			}
		}
		else {
			this.value-=5;
			
			if( this.value < this.min ) {
				return this.end();
			}
		}
		
		Tools.opacity( o, this.value/100 );
		
		setTimeout( 'document.displayers[' + this.i + '].update()', this.speed );
	}
	
	this.end = function() {
	
		this.isMoving = false;
	}
	

}