// JavaScript Document

// Social media functions
function mailPage() {
	mail_str = "mailto:?subject=Check out " + document.title;
	mail_str += "&body=I thought you might be interested in " + document.title;
	mail_str += ". You can view it at, " + location.href;
	location.href = mail_str;
}
function tweetThis(){
	window.open('http://twitter.com/home?status=Check out this great article about ' + document.title + ' at ' + location.href);
}
function facebookThis(){
	window.open('http://www.facebook.com/sharer.php?u=' + location.href + "&t=" + document.title);
}
function deliciousThis(){
	window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550');
}
function diggThis(){
	window.open('http://digg.com/submit?url=' + location.href + '&title=' + document.title);
}
function stumbleThis(){
	window.open('http://www.stumbleupon.com/submit?url=' + location.href + '&title=' + document.title);
}

// Opens new browser window for links of rel=external for W3C Validation

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		var relvalue = anchor.getAttribute("rel");
		if (anchor.getAttribute("href")) {
			var external = /external/;
			var relvalue = anchor.getAttribute("rel");
			if (external.test(relvalue)) { anchor.target = "_blank"; }
		}
	}
}
window.onload = externalLinks; 

