$(document).ready(function(){

        // Open external links in a new window. External = not on this domain, or having a rel of 'external'.

	$("#content-header a[href^=http]").each(
		function(){
			if(this.href.indexOf(location.hostname) == -1 || this.rel == 'external') {
				$(this).attr('rel', 'external')
					.attr('title', 'External link (will open in new window)');
					$(this).click(function(){ window.open(this.href); return false;
					});
			}
	
		}
	);
	$("#content a[href^=http]").each(
		function(){
			if(this.href.indexOf(location.hostname) == -1 || this.rel == 'external') {
				$(this).attr('rel', 'external')
					.attr('title', 'External link (will open in new window)');
					$(this).click(function(){ window.open(this.href); return false;
					});
			}
	
		}
	);
	$("#content-secondary a[href^=http]").each(
		function(){
			if(this.href.indexOf(location.hostname) == -1 || this.rel == 'external') {
				$(this).attr('rel', 'external')
					.attr('title', 'External link (will open in new window)');
					$(this).click(function(){ window.open(this.href); return false;
					});
			}
	
		}
	);


        // Force calendar links to open on the current page (don't point to actual calendar asset)

        $("#content-header #calendar a").each(
                function(){
                        questionMarkPos = this.href.indexOf('?');
                        if (questionMarkPos > 0) {
                                $(this).attr('href', this.href.substring(questionMarkPos, this.href.length));
                        }
                }
        );
});
