var tagOverId = 0;

function dynamicTagBox(button_id,box_id)
{  
  Event.observe(window,'load',prepareTagBox.curry(box_id,button_id));
}

function openTagBox(box_id,event)
{
  clearTimeout(tagOverId);
  new Effect.Appear($(box_id), { duration: 0.0 });
  event.preventDefault();
}

function closeTagBox(box_id,event)
{
  clearTimeout(tagOverId);
  tagOverId = setTimeout ( fadeBox.curry(box_id), 500 );
  event.preventDefault();
}

function fadeBox(box_id,event)
{
  new Effect.Fade($(box_id), { duration: 0.0 });
}

function prepareTagBox(box_id,button_id)
{
  Event.observe(button_id,"click",function (event) { event.preventDefault() });
  Event.observe(button_id,"mouseover",openTagBox.curry(box_id));
  Event.observe(box_id,"mouseover",openTagBox.curry(box_id));
  Event.observe(button_id,"mouseout",closeTagBox.curry(box_id));
  Event.observe(box_id,"mouseout",closeTagBox.curry(box_id));
}