var d = new Date();
var curr_year = d.getFullYear();

document.write(''+
'<div id="footer" class="clearfix">\n'+
	'<ul>\n'+
		'<li><a href="https://www.survey.arrow.com/se.ashx?s=218043747221A91F" rel="windowCenter" class="popupwindow">Feedback</a></li>\n' +
		'<li><a href="http://' + env + '.arrownac.com/terms/">Terms of Use</a></li>\n'+
		'<li><a href="http://' + env + '.arrownac.com/privacy/">Privacy Policy</a></li>\n'+
		'<li><a href="http://' + env + '.arrownac.com/sitemap/">Sitemap</a></li>\n'+
	'</ul>\n'+
	'<p id="copy">&copy; ' + curr_year + ' <a href="http://www.arrow.com/" rel="windowCenter" class="popupwindow">Arrow Electronics</a>, Inc. All rights reserved.</p>\n'+
'</div>\n'+

//webtrends setup
'<!-- START OF SmartSource Data Collector TAG -->\n'+
'<!-- Copyright (c) 1996-2011 WebTrends Inc.  All rights reserved. -->\n'+
'<!-- Version: 9.3.0 -->\n'+
'<!-- Tag Builder Version: 3.1  -->\n'+
'<!-- Created: 2/25/2011 12:04:43 PM -->\n'+
'<script src="/assets/global/js/webtrends.js" type="text/javascript"></script>\n'+
'<!-- ----------------------------------------------------------------------------------- -->\n'+
'<!-- Warning: The two script blocks below must remain inline. Moving them to an external -->\n'+
'<!-- JavaScript include file can cause serious problems with cross-domain tracking.      -->\n'+
'<!-- ----------------------------------------------------------------------------------- -->\n'+
'<script type="text/javascript">\n'+
'//<![CDATA[\n'+
'var _tag=new WebTrends();\n'+
'_tag.dcsGetId();\n'+
'//]]>\n'+
'</script>\n'+
'<script type="text/javascript">\n'+
'//<![CDATA[\n'+
'_tag.dcsCustom=function(){\n'+
'// Add custom parameters here.\n'+
'//_tag.DCSext.param_name=param_value;\n'+
'}\n'+
'_tag.dcsCollect();\n'+
'//]]>\n'+
'</script>\n'+
'<!-- END OF SmartSource Data Collector TAG -->\n'

);

/* GOOGLE ANALYTICS */ 
var _gaq = _gaq || [];
if(document.domain == 'www.arrownac.com'){ 
  _gaq.push(['_setAccount', 'UA-21048962-1']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['_trackPageLoadTime']);
} else if (document.domain == 'components.arrow.com'){
  _gaq.push(['_setAccount', 'UA-21048962-2']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['_trackPageLoadTime']);
};
(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);
})();
$(document).ready(function(){
  $('a').each(function (){
    if($(this).attr('href') !== undefined ) {
      if($(this).is('a#submit_search')) {
        $(this).click(function(){
          _gaq.push(['_trackEvent', 'E-Commerce', 'Part Search'])
        });
      }
      else if($(this).is('a#login_submit')) {
        $(this).click(function(){
          _gaq.push(['_trackEvent', 'E-Commerce', 'My Arrow'])
        });
      }
      else if($(this).is('a#cart')) {
        $(this).click(function(){
          _gaq.push(['_trackEvent', 'E-Commerce', 'Shopping Cart'])
        });
      }
      else if($(this).is('a#forgot_password')) {
        $(this).click(function(){
          _gaq.push(['_trackEvent', 'E-Commerce', 'Forgot Password'])
        });
      }
      else if($(this).is('a[href^="mailto"]')) {
        $(this).click(function(){
          _gaq.push(['_trackEvent', 'Email', $(this).attr('href')])
        });
      }
      else if($(this).is('div.adbx a[href^="http://247.arrownac.com"]')) {
        $(this).click(function(){
          _gaq.push(['_trackEvent', 'Banners', 'Sidebar Banners', + $(this).attr('href')])
        });
      }
      else {
        $(this).click(function(){
          _gaq.push(['_trackPageview', $(this).attr('href')])
        });
      }
    }
  });
});
