window.addEvent('domready',function() { 

	highlight_anchors=function(item_id){
		if (item_id != 'top'){
			if(!$(item_id)) {
				if(typeof $$(item_id)[0] == 'undefined' || typeof $$(item_id)[0].id == 'undefined'){
					return false;
				} else item_id=$$(item_id)[0].id;
			}

			// bisogna specificare un colore di partenza, altrimenti l'fx.start da' errore in IE se si specifica un background-color verso cui eseguire la transizione
			$(item_id).style.backgroundColor = "#2d3031";

			var fx = new Fx.Styles(item_id, {duration:400, wait:false});		

			fx.start({
				'background-color': '#ccc',
				'padding': '10px',
				'margin-bottom': '10px'
					}).chain(function(){
						this.start({
							'background-color': '#2d3031'
						});
					});						
		}
		return true;
	}

 	var el = window.location.hash.substring(1);
 	if(el){
		window.scrollTo(0,0);
		var scroll = new Fx.Scroll(window, { wait: false, transition: Fx.Transitions.Quad.easeOut });
		scroll.toElement(el);		
		highlight_anchors(el);		
	}
	
	
	//setup smoothscroll
	new SmoothScroll({ duration: 800, onComplete:function(){
		highlight_anchors(this.anchor);
	}});

});
