function man_menu_init() {
  
  var MODULE_URL = null;
  $('script').map(function(i) { 
    if (this.src.match(/man_menu_init\.js(\?.*)?$/)) {
      MODULE_URL = this.src.replace(/\/man_menu_init\.js(\?.*)?$/, '');
    }
  });  
  
  $("*[sancho_entity_type='ManMenu']").each(function(i) {   
    ////////////////////// START TOOLTIP ////////////////////////  
    $('#camargue_tooltip').unbind('mouseup');
  	$(this).bind('mouseup', function(e) { 
      //this one line will disable the right mouse click menu  
      if(!e.ctrlKey) $(document)[0].oncontextmenu = function() {return false;}       
      var rightclick;
      if (!e) var e = window.event;
      if (e.which) rightclick = (e.which == 3);
      else if (e.button) rightclick = (e.button == 2);
      if (rightclick) {
      	Camargue.Tooltip.hide(); 
        Camargue.Tooltip.keepVisible = true;
        Camargue.Tooltip.empty();  
      	var params = '';        
        params += 'sancho_entity_id=' + $(this).attr('sancho_entity_id');  
        params += '&sancho_page_area_name=' + $(this).parents("*[sancho_entity_type='SanchoContentSlot']").parent().attr('id');  
        params += '&sancho_cur_toc_id=' + Sancho.curTocId; 				                
        ///////////// START ACTIONS //////////////        
      	var credits = 'module: _ menu _ v.0.4 _ vendor: _ <a href="http://www.manadv.com">man</a> _ last update: _ 04-01-10';
        Camargue.Tooltip.addBlockTitle('Manage menu');  
        Camargue.Tooltip.addLink('Add menu entry', MODULE_URL + '/add_entry.php' + '?' + params, credits, {type: 'add', modalWidth: 550, modalHeight: 480, modalName: 'man_menu_add_entry'});          
				///////////// END ACTIONS ///////////////
      	Camargue.Tooltip.show(e);
        e.stopPropagation();
      }            
    });
    $('*').click(function(){
    	Camargue.Tooltip.hide(); 
    });    
    //////////////////////// END TOOLTIP //////////////////////////              
	});  
  
  
    $("*[sancho_entity_type='SanchoTocEntry']").each(function(i) {  			
  		if ($(this).parents("*[sancho_entity_type='SanchoTocEntry']").length == 0 || $(this).parents('#header_menu_content').length == 0) { // no 2nd level on main menu
      ////////////////////// START TOOLTIP ////////////////////////  
      $('#camargue_tooltip').unbind('mouseup');
    	$(this).bind('mouseup', function(e) { 
        //this one line will disable the right mouse click menu  
        if(!e.ctrlKey) $(document)[0].oncontextmenu = function() {return false;}       
        var rightclick;
        if (!e) var e = window.event;
        if (e.which) rightclick = (e.which == 3);
        else if (e.button) rightclick = (e.button == 2);
        if (rightclick) {
        	Camargue.Tooltip.hide(); 
          Camargue.Tooltip.keepVisible = true;                        	                   					            
          Camargue.Tooltip.empty();  
          var params = '';        
          params += 'sancho_entity_id=' + $(this).attr('sancho_entity_id');
          params += '&sancho_content_slot_id=' + $(this).parents("*[sancho_entity_type='SanchoContentSlot']").attr('sancho_entity_id');      
          params += '&sancho_page_area_name=' + $(this).parents("*[sancho_entity_type='SanchoContentSlot']").parent().attr('id'); 
          params += '&sancho_cur_toc_id=' + Sancho.curTocId; 				
          ///////////// START ACTIONS //////////////        
        	// add parent stuff
          var credits = 'module: _ menu _ v.0.4 _ vendor: _ <a href="http://www.manadv.com">man</a> _ last update: _ 04-01-10';
          Camargue.Tooltip.addBlockTitle('Manage menu');  
        	var parent_params = '';        
          parent_params += 'sancho_entity_id=' + $(this).parents("*[sancho_entity_type='ManMenu']").attr('sancho_entity_id');  
          parent_params += '&sancho_page_area_name=' + $(this).parents("*[sancho_entity_type='ManMenu']").parent().parent().attr('id');
          parent_params += '&sancho_cur_toc_id=' + Sancho.curTocId; 					                  
          Camargue.Tooltip.addLink('Add menu entry', MODULE_URL + '/add_entry.php' + '?' + parent_params, credits, {type: 'add', modalWidth: 550, modalHeight: 480, modalName: 'man_menu_add_entry'});          
          Camargue.Tooltip.addSeparator();  
          var params = '';        
          params += 'sancho_entity_id=' + $(this).attr('sancho_entity_id'); 
          params += '&man_menu_menu_id=' + $(this).parents("*[sancho_entity_type='ManMenu']").attr('sancho_entity_id'); 
          params += '&sancho_page_area_name=' + $(this).parents("*[sancho_entity_type='ManMenu']").parent().parent().attr('id');
          params += '&sancho_content_slot_id=' + $(this).parents("*[sancho_entity_type='ManMenu']").parent().attr('sancho_entity_id');
          params += '&sancho_cur_toc_id=' + Sancho.curTocId; 					                
          Camargue.Tooltip.addBlockTitle('Manage this entry');  
          Camargue.Tooltip.addLink('Edit entry', MODULE_URL + '/edit_entry.php' + '?' + params, credits, {type: 'edit', modalWidth: 550, modalHeight: 480, modalName: 'man_menu_edit_entry'}); 
          Camargue.Tooltip.addLink('Remove entry', MODULE_URL + '/remove_entry.php' + '?' + params, credits, {type: 'delete', modalWidth: 550, modalHeight: 110, modalName: 'man_menu_remove_entry'});     
  				///////////// END ACTIONS ///////////////
        	Camargue.Tooltip.show(e);
          e.stopPropagation();      
        }            
      });
      $('*').click(function(){
      	Camargue.Tooltip.hide(); 
      });    
      //////////////////////// END TOOLTIP //////////////////////////     
		}         
	});
  
  
  
  
  
  

   
  
  ////////////////////////////// INIT MENU CLIENT BEHAVIORS ///////////////////////////
  //effect: sliding_submenu
  function sliding_submenu(navigation_id, pad_out, pad_in, time, multiplier)
  {
  	// creates the target paths
  	var list_elements = navigation_id + " li.sliding-element";
  	var link_elements = list_elements + " a";
  	
  	// initiates the timer used for the sliding animation
  	var timer = 0;
  	
  	// creates the slide animation for all list elements 
/*
  	$(list_elements).each(function(i)
  	{
  		// margin left = - ([width of element] + [total vertical padding of element])
  		$(this).css("margin-left","-180px");
  		// updates timer
  		timer = (timer*multiplier + time);
  		$(this).animate({ marginLeft: "0" }, timer);
  		$(this).animate({ marginLeft: "10px" }, timer);
  		$(this).animate({ marginLeft: "0" }, timer);
  	});
*/
  
  	// creates the hover-slide effect for all link elements 		
  	$(link_elements).each(function(i)
  	{
  		$(this).hover(
  		function()
  		{
  			$(this).animate({ paddingLeft: pad_out }, 50);
  		},		
  		function()
  		{
  			$(this).animate({ paddingLeft: pad_in }, 50);
  		});
  	});
  }
  
  // main submenu vars
  var timeout    = 1000;
  var closetimer = 0;
  var mmenuitem  = 0;
  
	//ini submenu
  $('#content_menu ul:first').attr('id', 'sidebar_menu');
  $('#sidebar_menu li').addClass('sliding-element');
	$('#sidebar_menu > li:not(.selected) > ul').hide();
	
	//set selected main menu
	offsetLeft = $('span.current').prev().offset().left;
	offsetWidth = $('span.current').prev().width();
	$('span.current').css({'left': offsetLeft+'px', 'width': offsetWidth+'px'});
	if ($.browser.msie && $.browser.version < 8) {
		$('span.current').css({'margin-top': '16px'});
	}

	// main menu: ini
	$('#header_menu_content ul > li > ul').css('display', 'none');
	
	// main submenu functions
	function mmenu_open() {
		mmenu_canceltimer();
		mmenu_close();
		pos = $(this).offset().left - 38;
		mmenuitem = $(this).find('ul').eq(0).css({display:'block',left:pos});
	}
	function mmenu_close() {
		if(mmenuitem) mmenuitem.css('display', 'none');
	}
	function mmenu_timer() {
		closetimer = window.setTimeout(mmenu_close, timeout);
	}
	function mmenu_canceltimer() {
		if(closetimer){
			window.clearTimeout(closetimer);
			closetimer = null;
		}
	}
	// end: main submenu functions
	
	//assign events main menu
	$('#header_menu_content ul > li:has(ul)').bind('mouseover', mmenu_open);
	$('#header_menu_content ul > li:has(ul)').bind('mouseout',  mmenu_timer);
	
	//close main menu
	document.onclick = mmenu_close;
	
	//submenu
	sliding_submenu("#sidebar_menu", 2, 0, 150, .8);
	
	
	// for IE 6,7,8
	$('#header_menu_content > ul > li').each(function(i){
		$(this).find('ul > li:last-child').addClass('iefixmenu');
	});

} 

  
