Cufon.replace('.cufon');
Cufon.replace('#MinorNavigation a, #MajorNavigation ul li ul li a',{ hover: true});

var videoOverlay = {
	
	init:function(){
		
		$(".videos a[rel]").overlay({
			
			top:'8%',
			
			expose: {
				color: '#000',
				opacity: 0.9,
				loadSpeed: 'medium'
			},

			onBeforeLoad: function() {
				// grab wrapper element inside content
				var overlay = this.getOverlay().find(".video");
				overlay.load(this.getTrigger().attr("href"));
			},
			
			onLoad: function() {
				// load in addthis
				//$.getScript("http://s7.addthis.com/js/250/addthis_widget.js");
			},
			
			onClose:function(){
				// grab wrapper element inside content
				var overlay = this.getOverlay().find(".video");				
				overlay.html('');				
			}

		});
		
	}
	
};

var cufonKFix = {
	
	replace:function(){
		$('.cufon').each(function(){
			$(this).html($(this).html().replace(/k/g,'k<span style="font-size:.7em">&nbsp;&nbsp;</span>'));
			$(this).html($(this).html().replace(/K/g,'K<span style="font-size:.7em">&nbsp;&nbsp;</span>'));
		});
	},
	
	overlayReplace:function(){
		$('.overlay .cufon').html($('.overlay .cufon').html().replace(/k/g,'k<span style="font-size:.7em">&nbsp;&nbsp;</span>'));
		$('.overlay .cufon').html($('.overlay .cufon').html().replace(/K/g,'K<span style="font-size:.7em">&nbsp;&nbsp;</span>'));
	}
	
}

$(document).ready(function() {
	
	$(".external-download").click(function() {
		var explodedurl = $(this).attr("href");
		var ext = explodedurl.substring(explodedurl.lastIndexOf('.'));
		explodedurl = explodedurl.substring(0, explodedurl.lastIndexOf('.'));
		_gaq.push(['_trackPageview', explodedurl]);
	});
	
	videoOverlay.init();
	
	$('.back-to-top a').click(function(){
		$('html, body').animate({scrollTop:0}, 300);
		return false;		
	});
	
	$('#MajorNavigation ul:first > li:not(.selected)').hover(function(){
		$('#MajorNavigation ul li.selected ul').toggle();
		$(this).toggleClass('hover');
	});
	
});
