floatheader = new Object();
floatheader.timeout = 500;
floatheader.closetimer = 0;
floatheader.closeitem = 0;

floatheader.open = function()
{	
  floatheader.canceltimer();
  floatheader.close();
  floatheader.closeitem = $(this).find('ul').eq(0).css('visibility', 'visible');
}
floatheader.toggle = function(event)
{
  if ((floatheader.closeitem) && (floatheader.closeitem.css('visibility') == 'visible'))
  {
    if (this.id == 'floatfilterlist')
      return;
    floatheader.canceltimer();
    floatheader.closeitem.css('visibility', 'hidden');
  }
  else if (floatheader.closeitem)
  {
    floatheader.canceltimer();
    floatheader.closeitem.css('visibility', 'visible' );
  }
  if (event)
    event.stopPropagation();
}
floatheader.close = function()
{
  if (floatheader.closeitem) 
    floatheader.closeitem.css('visibility', 'hidden');
}
floatheader.timer = function()
{
  floatheader.closetimer = window.setTimeout(floatheader.close, floatheader.timeout);
}
floatheader.canceltimer = function()
{
  if(floatheader.closetimer)
  {	
    window.clearTimeout(floatheader.closetimer);
    floatheader.closetimer = null;
  }
}
floatheader.binditem = function()
{
  $(this)
    .bind('mouseover', floatheader.open)
    .bind('mouseout',  floatheader.timer)
    .bind('click', floatheader.toggle)
    .each( 
      function(index) {
        width = $(this).width() - $(this).find('ul').eq(0).width();
        if (width > 0)
          width = 0;
        $(this).find('ul').eq(0).css('margin-left', width );
      }
    );
}
$(document).ready( function()
{	
  $('.floatheader > li').each( floatheader.binditem );
  //$('.floatheader > li').bind('mouseover', floatheader.open);
  //$('.floatheader > li').bind('mouseout',  floatheader.timer);
  //$('.floatheader > li').bind('click', floatheader.toggle);
  //$('.floatheader > li').each( 
  //  function(index) {
  //    width = $(this).width() - $(this).find('ul').eq(0).width();
  //    $(this).find('ul').eq(0).css('margin-left', width );
  //  }
  //);
  //document.onclick = floatheader.close;
});
jQuery(function( $ ) {
  $.easing.elasout = function(x, t, b, c, d) {
    var s=1.70158;var p=0;var a=c;
    if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
    if (a < Math.abs(c)) { a=c; var s=p/4; }
    else var s = p/(2*Math.PI) * Math.asin (c/a);
    return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
  };
});


