$(document).ready(function(){
	if (user.jsSupportLevel==0){return;}
	$("html").addClass("js").addClass("jsSupportLevel"+user.jsSupportLevel);
	$("a[href^='http://' ]").not("[href^='http://"+window.location.host+"']").each(function(){
		if ($("img",this).length>0 && $(this).hasClass('pop')){
			this.title= "Link opens in a new window";
			$(this).click(function(){
			    window.open(this.href);
				return false;
			});
		} else if ($("img",this).length>0){
			// ignore if anchor contains an image
		} else {
			if (this.title&&this.title.length){
				this.title+= " (opens in a new window)";
			} else {
				this.title= "Link opens in a new window";
			}
				$(this).append('<img class="external" alt="external link" src="/global/images/misc/external.gif" />').click(function(){
			    window.open(this.href);
				return false;
			});
		}
	});
	$("a[href$='.pdf']").each(function(){
		if (this.title&&this.title.length){
			this.title+= " (opens in a new window)";
		} else {
			this.title= "Link opens in a new window";
		}
		$(this).append('<img class="external" alt="external link" src="/global/images/misc/external.gif" />').click(function(){
		    window.open(this.href);
			return false;
		});
	});
	$('div.navbar ul a[text="© 2009 Map of Medicine. All rights reserved."]').hide();
	(function(){
		if (!document.getElementsByTagName){return;}
		var existentimg = new Image;
		existentimg.onload = function(){
			$('html').addClass('img');
			var nonexistentimg = new Image;
			nonexistentimg.onload = function(){
				$('html').removeClass('img');
			}
			nonexistentimg.src="http://void";
		}
		if (document.images.length)
		existentimg.src = document.images[0].src; 
	})();
})
