



function external_links() {
   $('#content a').each(function(i) {
      // Makes content well links target="_blank"
      if ($(this).attr('href').match(/^http/)) {
         $(this).attr({target: "_blank"});
      }
   });
   $('a').each(function(i) {
      if ($(this).attr('href').match(/twitter\.com/)) {
         $(this).click(function() {
            pageTracker._trackPageview("/exitlinks/twitter.com/" + $(this).html());
            return true;
         });
      }
      if ($(this).attr('href').match(/amazon\.com/)) {
         $(this).click(function() {
            pageTracker._trackPageview("/exitlinks/amazon.com/" + $(this).html());
            return true;
         });
      }
      if ($(this).attr('href').match(/harvardbusiness\.org/)) {
         $(this).click(function() {
            pageTracker._trackPageview("/exitlinks/harvardbusiness.org/" + $(this).html());
            return true;
         });
      }
   });
}




$(document).ready(function() {
   external_links();
   featureHide();
   changeLocationHide();
   $('#feature1').hover(
      function() {
         $('#feature1_overlay').fadeIn("slow");
      },
      function() {
         $('#feature1_overlay').fadeOut("slow");
      }
   );
   $('#feature2').hover(
      function() {
         $('#feature2_overlay').fadeIn("slow");
      },
      function() {
         $('#feature2_overlay').fadeOut("slow");
      }
   );
   $('#feature3').hover(
      function() {
         $('#feature3_overlay').fadeIn("slow");
      },
      function() {
         $('#feature3_overlay').fadeOut("slow");
      }
   );




   
   $('a#change_location').click(function() {
      $('#change_location_overlay').show();
   });
   $('a#change_location_close').click(function() {
      changeLocationHide();
   });
   
   
   /* left nav accordion */
   var active_accordion = $('#accordion_list h3>a').index($('a.active'));
   $('#accordion_list').accordion({
      autoHeight: false,
      header: 'h3',
      alwaysOpen: false,
      active: active_accordion
   });
});

function featureHide() {
   $('#feature1_overlay').hide();
   $('#feature2_overlay').hide();
   $('#feature3_overlay').hide();
}

function changeLocationHide() {
   $('#change_location_overlay').hide();
}




function strategynEvents() {
  if (!document.getElementsByTagName) return false;

  var links = document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("mcmsSearch")) {
      links[i].onclick = function() {
        document.getElementById('searchForm').submit();
        return false;
		}
    } //if
  } //for
  var inputs = document.getElementsByTagName("input");
  for (var i=0; i < inputs.length; i++) {
    if (inputs[i].className.match("clearClick")) {
      inputs[i].onfocus = function() {
        if (document.getElementById('search_text')) document.getElementById('search_text').value='';
        return false;
      }
    }
  }
}
window.onload=strategynEvents;




function GATrackPageview(url) {
   try {
      pageTracker._trackPageview(url);
   } catch (e) {
      // pageTracker not available
   }
}

function GATrackEvent(category, action, label) {
   try {
      pageTracker._trackEvent(category, action, label);
   } catch (e) {
      // pageTracker not available
   }
}
