$(document).ready(function() {
	
/* Open some external links in new windows
================================================== */
$('a[rel="external"]').click( function() {
window.open( $(this).attr('href') );
return false;
});

/* Click to read more
================================================== */
$('.expand').css('width', $('.expand').width() + 'px').hide().prev().append('<a class="more" href="#"> [+]</a>').click(function() {
$(this).next(':hidden').slideDown().prev().find('.more').hide();
 return false;
  })

/* Tabs
================================================== */
	$('.tabs').each(function () {
    var $links = $(this).find('a'),
      panelIds = $links.map(function() { return this.hash; }).get().join(","),
      $panels = $(panelIds),
      $panelwrapper = $panels.filter(':first').parent(),
      delay = 500,
      heightOffset = 5;
      
    $panels.hide();
    $links.click(function () {
     
      var link = this, 
        $link = $(this);
        
      // ignore if already visible
      if ($link.is('.active')) {
        return false;
      }
      
      $links.removeClass('active');
      $link.addClass('active');
 
      $panelwrapper.stop().animate({
        height: 0
      }, delay, function () {
        var height = $panels.hide().filter(link.hash).show().height() + heightOffset;
        
        $panelwrapper.animate({
          height: height
        }, delay);
      });
    });
     $links.filter(window.location.hash ? '[hash=' + window.location.hash + ']' : ':first').click();

});
});


/* IOS viewport scaling bug fix - https://gist.github.com/903131
================================================== */
!function(doc) {
  var addEvent = 'addEventListener',
      type = 'gesturestart',
      qsa = 'querySelectorAll',
      scales = [1, 1],
      meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];

  function fix() {
    meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
    doc.removeEventListener(type, fix, !0);
  }
  if ((meta = meta[meta.length - 1]) && addEvent in doc) {
    fix();
    scales = [.25, 1.6];
    doc[addEvent](type, fix, !0);
  }
}(document);
