


jQuery.fn.dropDown = function(cfg) {
	// Definisce se chiudere l'elemento di menu per il clear.                                    //
	cfg.close			= cfg.close 		|| true;
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	// GESTIONE DELLE CLASSI PER L'INTERFACCIA GRAFICA.                                          //
	//                                                                                           //
	// Imposto le classi corrette per i vari elementi del menu.                                  //
	$(this).attr('class', 'dropDown');				// Classe dell'UL principale.                //
	$(this).wrap('<div class="dropDown"></div>');	// Div esterno che racchiude il menu.        //
	
	// Applico lo span interno ai link del menu a tendina.                                       //
	$(this).find("a").each(function() { $(this).html('<span class="lnkText">' + $(this).html() + '</span>'); });
	
	// Applico la classe drop ai menu con submenu per la gestione grafica.                       //
	$(this).find('li ul li').each(function() {
		if ( $(this).find('ul').length > 0 ) {
			$(this).children('a').attr('class', 'drop');
		}
	});
	
	// Aggiungo un elemento dopo il menu per chiudere il "clear" utilizzato nel css.             //
	if ( cfg.close == true ) { $(this).append('<div style="clear:both;"></div>'); }
	//                                                                                           //
	// fine GESTIONE DELLE CLASSI PER L'INTERFACCIA GRAFICA.                                     //
	///////////////////////////////////////////////////////////////////////////////////////////////
	
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	// GESTIONE DELLE AZIONI SUGLI ELEMENTI DEl MENU.                                            //
	//                                                                                           //
	$(this).find('li').hover(function() {
		// Visualizza il tronco sottostante.                                                     //
		$(this).addClass('sfhover');
		//jDebug( $(this).parent().parent().children('a').html() );
		
		$(this).parent().parent().children('a').addClass('over');
	}, function() {
		// Nasconde il tronco sottostante.                                                       //
		$(this).removeClass('sfhover');
		//jDebug('');
		$(this).parent().parent().children('a').removeClass('over');
	});
	//                                                                                           //
	// fine GESTIONE DELLE AZIONI SUGLI ELEMENTI DEl MENU.                                       //
	///////////////////////////////////////////////////////////////////////////////////////////////
	
} // End Plugin ///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////


/*
Codice necessario per far funzionare il menu sotto IE. Bisonga assegnare l'id della lista
da trasformare in menu.

---
<script type="text/javascript" src="dropDownMenu.js"></script>
<script type="text/javascript">dropDownMenu("id_lista");</script>
---
*/