function initControls()
{
	var tools  = $('tools');
	
	function ajaxComplete()
	{
		removeSpinner( $('tools') );
		//$('tools').removeClass('spinner');
		$$('#tools a')[1].focus();
	}
	
	tools.init = function()
	{
		var el = $('actClose');
		var elements = $$('#tools a');
		if ( elements[0].title )
		{
			new Tips(elements); 
		}
		
		el.setProperty("href", "javascript:foo()");
		
		el.addEvent('click', function() 
		{
			$('tools').switchState( null, this );
		});
		
		elements.each( function(el)
		{
			id = "" + el.getProperty("id")
			
			if ( id != "actClose")
			{
				var idSuffix = id.replace(/^([a-zA-Z_]+)-([0-9a-zA-Z_]+)$/, "$2");
				
				if ( document.cssPattern.test(idSuffix) ) 
				{
					el.getChildren().addClass('here');
				}
			}
		});
	}
	
	tools.switchState = function( ajaxObj, caller )
	{
		var element = $('tools');
		
		if (caller.id == 'actClose')
		{
			element.slider.slideOut();
			element.hidden = true;
			element.actual = null;
			return;
		}
		
		setSpinner( $('tools') );
		//$('tools').addClass('spinner');
		
		if (element.actual == null || element.actual == caller)
		{
			switch ( element.hidden )
			{
				case true:
					ajaxObj.request();
					element.slider.slideIn();
					element.hidden = false;
					element.actual = caller;
				break;
				
				case false:
					element.slider.slideOut();
					element.hidden = true;
					element.actual = null;
				break;
			}
		}
		else
		{
			switch ( !element.hidden )
			{
				case true:
					ajaxObj.request();
					element.actual = caller;
				break;
				
				case false:
					element.slider.slideOut();
					element.hidden = true;
					element.actual = null;
				break;
			}
		}
	}
	
	//elimino l'url dai punsanti di apertura delle opzioni
	$('actCarattere').setProperty("href", "javascript:foo()");
	$('actSkin').setProperty("href", "javascript:foo()");
	$('actPagina').setProperty("href", "javascript:foo()");
		
	//inizializzazione azioni barra utilità
	$('actCarattere').addEvent('click', function() 
	{
		$('tools').switchState( $('tools').ajaxCarattere, this );
	});
	
	$('actSkin').addEvent('click', function() 
	{
		$('tools').switchState( $('tools').ajaxSkin, this );
	});
	
	$('actPagina').addEvent('click', function() 
	{
		$('tools').switchState( $('tools').ajaxPagina, this );
	});
	
	tools.ajaxCarattere = new Ajax('/_skin/_elements/tools/testo.htm', {method: 'get', update: ('tools'), onComplete:ajaxComplete});
	tools.ajaxSkin = new Ajax('/_skin/_elements/tools/skin.htm', {method: 'get', update: ('tools'), onComplete:ajaxComplete});
	tools.ajaxPagina = new Ajax('/_skin/_elements/tools/pagina.htm', {method: 'get', update: ('tools'), onComplete:ajaxComplete});
		
	tools.ajaxSkin.addEvent('onComplete', tools.init);
	tools.ajaxPagina.addEvent('onComplete', tools.init);
	tools.ajaxCarattere.addEvent('onComplete', tools.init);
		
	tools.setStyle('display', 'block');
	tools.slider = new Fx.Slide('tools', {duration:500, transition: Fx.Transitions.Sine.easeInOut} );
	
	if ( !$('openTools') ) 
	{
		tools.slider.hide();
		tools.hidden = true;
		tools.actual = null;
	}
	else
	{
		var tab = window.location.search.replace(/(.+)?tab=(.+)(.+)?/, "$2");
		
		switch (tab)
		{
			case 'testo':
				tools.actual = $('actCarattere');
			break;
			
			case 'skin':
				tools.actual = $('actSkin');
			break;
			
			case 'pagina':
				tools.actual = $('actPagina');
			break;
		}
		
		tools.hidden = false;
		tools.init();
	}
}



