var TimeoutId = -1;

$(document).ready(function(){
   mlv2_visible_id = getId($('.mlv2_visible').attr('id'));
   
   $('a.mlv1').hover(function(){
	 clearTimeout(TimeoutId);

	 current_elem_id = getId($(this).attr('id'));
	 
	//if(!((current_elem_id == 3 || current_elem_id == 4) && (mlv2_visible_id == 11))
	//  && (mlv2_visible_id != current_elem_id))
	  if((mlv2_visible_id != current_elem_id))
		HideSelectedMenu($(this));
   },function(){
	   TimeoutId = setTimeout("ShowSelectedMenu();",200);
   });
  $('.mlv2').hover(function(){
	 clearTimeout(TimeoutId);
   },function() {
	 TimeoutId = setTimeout("ShowSelectedMenu();",200);
   })   
});

function ShowSelectedMenu()
{
    $('.mlv2').fadeOut(50);
    $('div[id=mlv2_'+mlv2_visible_id+']').removeClass('mlv2');	 
	$('div[id=mlv2_'+mlv2_visible_id+']').addClass('mlv2_visible');	 	
}

function HideSelectedMenu(th)
{
    $('.mlv2').fadeOut(50);
    $('div[id=mlv2_'+mlv2_visible_id+']').removeClass('mlv2_visible');	 
    $('div[id=mlv2_'+mlv2_visible_id+']').addClass('mlv2');	 
    //$('div[id=mlv2_'+getId($(this).attr('id'))+']').fadeOut(50);
		
    $('div[id=mlv2_'+getId(th.attr('id'))+']').fadeIn(200);

}
/*
$(document).ready(function(){
   $('span').hover(function(){
	 clearTimeout(TimeoutId);
	 $(this).addClass('hover');
	 $('.mlv2').fadeOut(50);
	 $('div[id=mlv2_'+getId($(this).attr('id'))+']').fadeOut(50);$('div[id=mlv2_'+getId($(this).attr('id'))+']').fadeIn(200);
   },function(){
     $(this).removeClass('hover');
	 TimeoutId = setTimeout( "$('.mlv2').fadeOut(50);", 200);
   });
  $('.mlv2').hover(function(){
	 clearTimeout(TimeoutId);
   },function() {
	 TimeoutId = setTimeout( "$('div[id=mlv2_"+getId($(this).attr('id'))+"]').fadeOut(50);", 200);
   })   
});
*/
/*
$(document).ready(function(){
   $('span').hover(function(){
	 clearTimeout(TimeoutId);
	 $(this).addClass('hover');
	 $('.mlv2').fadeOut(50);
	 $('div[id='+$(this).attr('id')+']').fadeOut(50);$('div[id='+$(this).attr('id')+']').fadeIn(200);
   },function(){
     $(this).removeClass('hover');
	 TimeoutId = setTimeout( "$('.mlv2').fadeOut(50);", 200);
   });
  $('.mlv2').hover(function(){
	 clearTimeout(TimeoutId);
   },function() {
	 TimeoutId = setTimeout( "$('div[id="+$(this).attr('id')+"]').fadeOut(50);", 200);
   })   
});
*/
function getId(Identifier)
{
  if (!Boolean(Identifier)) return;
  
  ID = Identifier.split("_",2);
  if (!Boolean(ID[1])) 
    return;
  else
    return ID[1];
}


/*
$(document).ready(function(){
   $('span').hover(function(){
	 clearTimeout(TimeoutId);
	 $(this).addClass('hover');
	 $('.mlv2_visible').removeClass('mlv2_visible');
	 $('div[id='+$(this).attr('id')+']').addClass('mlv2_visible');
   },function(){
     $(this).removeClass('hover');
	 TimeoutId = setTimeout( "$('div[id="+$(this).attr('id')+"]').removeClass('mlv2_visible')", 200);
   });
  $('.mlv2').hover(function(){
	 clearTimeout(TimeoutId);
   },function() {
	 TimeoutId = setTimeout( "$('div[id="+$(this).attr('id')+"]').removeClass('mlv2_visible')", 200);
   })   
 
});
*/