/**
 * @author Daniele Corti - GESTWEB Research s.r.l. * All the contents of this file belog to GESTWEB Research s.r.l. - Italy
 */

var startPadLeft = 10, endPadLeft, classGeneral;
var fxs = [];
function setMenu(id, diff)
{	
	if($(id))
		classGeneral = $(id).getProperty('class');

	$$('#'+id+" li div").each(function(item, index){
		var fx = fxs[index];
		if(!fx)
		{
			fx = new Fx.Morph(item, {duration: 200});
			fxs[index] = fx;
		}
		
		endPadLeft = startPadLeft + diff;
		
		
			item.addEvents({
				'mouseenter': function(){
					if (this.getParent().getProperty('class') != 's'+classGeneral) {
						fx.cancel();
						fx.start({
							'padding-left': endPadLeft
						});
					}
					item.setStyle('text-decoration', 'underline');
				},
				'mouseleave': function(){
					if (this.getParent().getProperty('class') != 's'+classGeneral) {
						fx.cancel();
						fx.start({
							'padding-left': startPadLeft
						});
					}
					item.setStyle('text-decoration', 'none');
				}/*,
				'click': function(){
					var url = this.getProperty('href');
					window.location.href = url;
				}*/
			})
		
	})
}

function hoverMenu(id){
	var ulClass = $(id).getElement('ul').getProperty('class');
	$$('#'+id+" li[class!=NOThis]").each(function(item){
		var src = pathToAdd+'images/button/bt_up_';
		if(item.hasClass('s'+ulClass))
			src = pathToAdd+'images/button/bt_down_';
		item.setStyle('background-image', 'url('+src+item.getProperty('src')+')');
		item.setStyle('background-repeat', 'no-repeat');
		item.addEvents({
			'mouseenter': function(){
				item.setStyle('background-image', 'url('+pathToAdd+'images/button/bt_over_'+item.getProperty('src')+')');
			},
			'mouseleave': function(){
				item.setStyle('background-image', 'url('+src+item.getProperty('src')+')');
			}
			/*,
			'click': function(){
				var url = this.getProperty('href');
				window.location.href = url;
			}*/
		})
	})
}
