/**
Determine whether links' hrefs point to this site
and if not, decorate them with target attributes & 
external site images.
 */
 
var LinkDecorator = {
	
	isExternal : function( link ) {
		var externalLink = false;
		var a = $( link );
		var domain = location.protocol + '//' + location.hostname;
		if( !(a.href.startsWith( domain )) ) {
			externalLink = true;
		}
		return externalLink;
	},
	
	decorate : function( link ) {
		link.setAttribute( 'target', 'ext_site' );
		Element.addClassName( link, 'external' );
	},
	
	execute : function() {
		var links = $A( document.getElementsByTagName( 'a' ) );
		links.each( function( link ) {
			if( LinkDecorator.isExternal( link ) ) {
				LinkDecorator.decorate( link );
			}
		});
	}
};