// JavaScript Document

function Writers(){}
	
Writers.prototype.writePhoneNum = function(a, b, c){
	// Obscures phone from spiders
	document.write( a + "." + b + "." + c );
}

Writers.prototype.writeEmail = function( un, domain, tld ){
	var output = "<a href=\"" + "mail" + "to:" + un + "@" + domain +"." + tld + "\">"+ un + "@" + domain +"." + tld + "</a>";
	document.write(output);
}

var writers = new Writers(); // hides email address/phone numbers

// Google Analytics
var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-3337075-8']);
  _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);
  })();
  
  if(typeof jQuery == 'function') { /* use jQuery if it exists because it is a more elegant solution */
	jQuery(function () {
		jQuery('a:not([href*="' + document.domain + '"])').click(function () {
			pageTracker._trackPageview('/outgoing/' + jQuery(this).attr('href'));
		});
	});
}
else { /* use regular Javascript if jQuery does not exist */
	window.onload = function () {
		var links = document.getElementsByTagName('a');
		for (var x=0; x < links.length; x++) {
			links[x].onclick = function () {
				var mydomain = new RegExp(document.domain, 'i');
				if(!mydomain.test(this.getAttribute('href'))) {
					pageTracker._trackPageview('/outgoing/' + this.getAttribute('href'));
				}
			};
		}
	};
}
