$(function(){
	if (user.jsSupportLevel==0){return;}
	map.checkimg();
	if (user.jsSupportLevel>2 && window.Cufon){
		initCufon();
	}
	$("html").addClass("js").addClass("jsSupportLevel"+user.jsSupportLevel);
	$("b.external[href^='http://' ]").not("[id^='button']").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;
			});
			$(this).data('hasexternalicon',true)
		}
	});
	$("b[href$='.pdf']").each(function(){
		if (!$(this).data('hasexternalicon')) {
			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*='/global/']").click(function(event){
		if (!window.pageTracker || !pageTracker._trackPageview || !event.target || !event.target.href){return}
		try {
			var url = event.target.href.toString().split('/global/')[1];
			pageTracker._trackPageview('/x-internal-asset/global/'+url);
			//if (window.console && console.log) console.log('tracking url:/global/'+url)
		} catch (e) {}
	});
	$('div.navbar ul a[text="© 2009 Map of Medicine. All rights reserved."]').hide();
})


function initCufon() {
        if (window.isIE9){Cufon.set('engine', 'canvas');}
	Cufon.set('fontFamily', 'FranklinGothic');
	Cufon.replace('h1');
	Cufon.replace('h2');
	Cufon.replace('h3');
        Cufon.replace('a#buttonGetStarterPack>span');
        Cufon.replace('a#buttonLearnMore>span');
	Cufon.replace('.btn-access strong', { fontFamily: 'FranklinGothicbold'});
}


