if (typeof Array.prototype.indexOf == 'undefined') {
    Array.prototype.indexOf = function(value) {
        for (var i = 0; i < this.length; i++)
            if (this[i] == value) return i;

        return -1;
    }
}
jQuery(document).ready(function() {
  var hb_ids = jQuery.cookie('hb_ids');
  if (hb_ids == null || hb_ids == '') hb_ids = [];
  else if (hb_ids.indexOf(',') >= 0) hb_ids = hb_ids.split(',');
  else hb_ids = [hb_ids];

  for (var i=0; i<hb_ids.length; i++) {
      jQuery('#hsbc_'+hb_ids[i]).hide();
  }

  jQuery("td[id^='hsbt_']").css('cursor', 'pointer');
  jQuery("td[id^='hsbt_']").click(function(){
    var cid = this.id.replace('hsbt_', 'hsbc_');
    var id = cid.replace('hsbc_', '');
    if (jQuery('#'+cid).is(':hidden')) {
        jQuery('#'+cid).show();
        hb_ids.splice(hb_ids.indexOf(id), 1);
        jQuery.cookie('hb_ids', hb_ids, {expires: 356});
    } else {
        jQuery('#'+cid).hide();
        if (hb_ids.indexOf(id) == -1) {
            hb_ids.push(id);
            jQuery.cookie('hb_ids', hb_ids, {expires: 356});
        }
    }

	if (jQuery('.hbi_'+id).is('.hbis')) {
		jQuery('.hbi_'+id).removeClass('hbis').addClass('hbih');
	} else {
    	jQuery('.hbi_'+id).removeClass('hbih').addClass('hbis');
    }
    return false;
  });
});