// we use this just as a namespace
jQuery.fn.acco = function () {};

// attach the click event using the live function
// will bind to each matching elem, even if added later to the dom
// does not work on ios
jQuery.fn.acco.clickhandler =function () {
  var $next = $(this).next();
  if ($next.is(':visible')) {
    $next.slideUp('slow');
    $(this).removeClass('acco-selected');

  } else {
    $next.slideDown('slow');
    $(this).addClass('acco-selected');
  }
  var $siblings = $(this).siblings('.acco-header');
  $siblings.removeClass('acco-selected');
  $siblings.next().slideUp();
  return false;
}
// does not work on ios
//$('.acco .acco-header').live('click',jQuery.fn.acco.clickhandler );

$('.acco .acco-header').live('mouseenter',function () {
  $(this).addClass('hover');
  return false;
});

$('.acco .acco-header').live('mouseleave',function () {
  $(this).removeClass('hover');
  return false;
});
// set the height property
// make shure this function gets called when the divs are visible
jQuery.fn.acco.adjust = function () {
  $('.acco .acco-header').next().each(function () {
    //console.log($(this).html());
    var h = $(this).show().outerHeight(true);
    $(this).hide();
    //console.log('height adjust:'+h);
    if (h != 0) {
      $(this).css('height', h);
    }
  });
};


