jQuery(window).ready( function(){

    jQuery('#menuist-chk').remove();
    jQuery('#menuist').append('<div id="menuist-chk"></div>');

    if( jQuery('#menuist a.active').length > 0 ) {

	var that = jQuery('#menuist a.active');
	var thatwidth = that.outerWidth();

	// trovo l'indice dell'active rispetto agli elementi del menu
	var el = jQuery('#menuist a');
	
	var widthsum = 0;

	for (k=0;k<el.size();k++){

	    if( jQuery(el[k]).hasClass('active') ){
		break;
	    } else{
		widthsum = widthsum + jQuery(el[k]).outerWidth();
	    }

	}

	var cursorspace = parseInt(jQuery('#menuist-chk').css('width')) / 2;

	jQuery('#menuist-chk').css('top','-10'+'px');
	jQuery("#menuist-chk").css('left',  (widthsum - cursorspace + ( Math.ceil( parseInt(thatwidth) / 2 ))  ) +'px');


    }

});

