document.observe('dom:loaded', function() {
	new menuEffect();
});

var menuEffect = Class.create({

	// Properties
	fadeDuration: 0.4,

	initialize: function(){
		$$("a.qmparent").invoke('observe', 'mousemove', this.linkMouseOver.bind(this));
		$$("a.qmparent").invoke('observe', 'mouseout', this.linkMouseOut.bind(this));
	},
	
	// Mouse event handlers
	linkMouseOver: function(e){
        	var el = e.element();
		if(el && !el.hasClassName('qmselected')){
			new Effect.Morph(el, {
				style: 'color:#7D7D7D',
				duration: this.fadeDuration,
				queue: {
					position: 'end',
					scope: el.identify(),
					limit: 2
				}
			});
	        }	
	},	
	
	linkMouseOut: function(e){
        	var el = e.element();
		if(el && !el.hasClassName('qmselected')){
			new Effect.Morph(el, {
				style: 'color:#B0AFAA',
				duration: this.fadeDuration,
				queue: {
					position: 'end',
					scope: el.identify(),
					limit: 3
				}
			});
	        }		
	}

});



function toggleSearch(expand){
        var duration = 0.7;
	if(expand){
		$('sitesearchbox').morph('width:243px;background:#F4F4F4',{duration:duration});
		$('sitesearch').morph('width:214px',{duration:duration});
                new Effect.Opacity('search-button', { from: 0.5, to: 0.9, duration: duration });
	}else{
		$('sitesearchbox').morph('width:143px;background:#FFFFFF',{duration:duration,delay:0.5});
		$('sitesearch').morph('width:114px',{duration:duration,delay:0.5});
                new Effect.Opacity('search-button', { from: 0.9, to: 0.5, duration: duration });
        }
}

function js_toggleComments(){
	var statoCommenti = $F('comment_status');
	if (statoCommenti == "close"){
		$('comment_status').setValue("open");
		$('comment_form').appear();
	}else{
		$('comment_status').setValue("close");
		$('comment_form').fade();
	}
        return false;
}

