// JavaScript Document: 2010-01-26, mortenson@aarc.org
// Make sure to load jQuery too!
	$(document).ready(function() {
		// Get display dimensions
		var bw = $("body").width();
		var dh = $(window).height() * .85;
		var mtpW = $('#mtpExpl').width();
		var mtpH = $('#mtpExpl').height();
		var vdpW = $('#vdpExpl').width();
		var vdpH = $('#vdpExpl').height();
		// Set position of missed treatments explanation div
		if (bw - 140 > mtpW) {
			$('#mtpExpl').css('left',((bw - mtpW)/2 + 140) + 'px');	
		} else {
			$('#mtpExpl').css('right',0);
		}
		if (dh > mtpH) {
			$('#mtpExpl').css('top',(dh - mtpH)/2 + 'px');
		} else {
			$('#mtpExpl').css('top','12px').height(dh).css('font-size','.8em');
		}
		// Set position of vent days/patient explanation div
		if (bw + 140 > vdpW) {
			$('#vdpExpl').css('left',((bw - vdpW)/2 - 140) + 'px');	
		} else {
			$('#vdpExpl').css('left',0);
		}
		if (dh > vdpH) {
			$('#vdpExpl').css('top',(dh - vdpH)/2 + 'px');
		} else {
			$('#vdpExpl').css('top','12px').height(dh).css('font-size','.8em');
		}
		// Handle display when DB returns insufficient data message
		$('span.data:contains("[Insufficient data]")').addClass('tiny');    
		// If IE, then add round corner sprites to dashboard DIVs...
		if (navigator.userAgent.indexOf('MSIE') >= 0 | navigator.userAgent.indexOf('Opera') >= 0) {
			$('div.dashbd').prepend('<div class="cnrTL"></div>')
			.prepend('<div class="cnrTR"></div>')
			.append('<div class="cnrBL"></div>')
			.append('<div class="cnrBR"></div>');
		}
		//  Fade in/out explanatory text
		$('#lAboutMtp').click(function() {
			$('#mtpExpl').fadeIn('fast');
		});
		$('#lCloseMtp').click(function() {
			$('#mtpExpl').fadeOut('fast');
		});
		$('#lAboutVdp').click(function() {
			$('#vdpExpl').fadeIn('fast');
		});
		$('#lCloseVdp').click(function() {
			$('#vdpExpl').fadeOut('fast');
		});
});

