function initTabs() {
  var counter = 1;        
  $('.tab').each(function() {
    var headings = $(this).find('h2');
    if(headings.length > 0) {  
      var tab = $('#' + $(this).attr('id') + 'Tab');
      var navHtml = '<ul>';

      headings.each(function() {     
        if($.trim($(this).text()).length > 1) {
          var headingId = 'heading' + counter;
          $(this).attr('id', headingId);
          navHtml += '<li><a id="href'+ headingId +'" href="#' + headingId + '">' + $(this).text() + '</a></li>';
          counter++;
        }
      });

      navHtml += '</ul>';
      tab.append(navHtml);
    }
  });

  // add dropdown effect
  $('.tabs .navigation li').hover(
    function() {
      $(this).find('ul').show();
    },
    function() {
      $(this).find('ul').hide();
    }
  );

  // add show/hide logic
  $('.tabs .navigation a').click(function() {
    var href = $(this).attr('href');
    var hash = href.substring(href.indexOf('#')); // IE returns fullurl#hash not #hash only
    var partial = $(hash);

    $('.tab').hide(); // hide all

    if(partial.get(0).nodeName == 'DIV') {
      showChildren(partial);
      hideNext(partial.find('h2:gt(0)'));
    } else {
      showChildren(partial.parents('.tab'));
      hidePrev(partial);
      hideNext(partial.nextAll('h2'));
      hideNext(partial.parent('span').nextAll('h2'));
      hideNext(partial.parent('span').nextAll('span').find('h2'));
    }

    // colour changes
    $('.tabs .navigation a').removeClass('selected').addClass('unselected');
    $(this).parents('li').find('a').removeClass('unselected').addClass('selected');

    //back to top
    setTimeout('ftnScrollHotel()',1);
  });

  // hide all but first tab
  $('.tab:gt(0)').hide();
  $('.tabs .navigation a:first').addClass('selected');
}

function showChildren(collection) {
  collection.show().find('*').not('script').show(); // show on a script can display text
}

function hideNext(collection) {
  collection.hide();
  collection.nextAll('*').hide();
  collection.parent('span').nextAll('*').hide();
}

function hidePrev(collection) {
  collection.prevAll('*').hide();
  collection.parent('span').prevAll('*').hide();
}

function ftnScrollHotel() {
  window.scrollTo(0,250);
}