// Start general analytics code
var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-7900719-1']);
  _gaq.push(['_trackPageview']);

(function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


// Function for tracking outbound links  
function recordOutboundLink(link, category, action) {
  try {
	_gat._getTrackerByName()._trackEvent(category, action);

    if (link.target == "_blank") {
    	// Do nothing, it will work as is
    } else {
        setTimeout('document.location = "' + link.href + '"', 100)
   }
  }catch(err){}
}

// Update all outbound links to be tracked as "Outbound Links" events
$(document).ready(function() {
	$('a').each(function(){
		var anchorHref = $(this).attr('href');

		if (!(typeof anchorHref == 'undefined') && !anchorHref.match(/mitsubishielectric-usa\.com/) && !anchorHref.match(/meus\.presentekwebs\.com/) && !anchorHref.match(/mits\.local/) && !anchorHref.match(/meus\.local/) && !anchorHref.match(/^\//) && !anchorHref.match(/^\.\.\//) && anchorHref.match(/^http/))
		{
			$(this).click(function(){
				var outbound_link_url = anchorHref;
				//alert('Exit Page: ' + exit_page_url + '   --   ' + 'Outbound Link: ' + outbound_link_url);
				recordOutboundLink(this, 'Exit Pages', outbound_link_url);
			});
		}
	});
});
