// Required variable defaults
var _tmbn_hbs_role = "";

function _tmbnDaysHBS() {
	var curr, next, today, unit;
	unit = 1000 * 3600 * 24;
	curr = new Date(2007,3,30);
	next = new Date(2007,8,17);
	today = new Date();today.setHours(0,0,0,0);

	diff = Math.round((curr - today) / unit);
	var o = {num: diff, pre: 'Only ', post: ' days before', img: 'HBS2007a.png'};
	if (diff == 0) {
		o.pre = 'Now is ';
		o.num = 'Day 1';
		o.post = ' of';
	} else if (diff < 0 ) {
		o.num = Math.round((next - today) / unit);
		o.img = 'HBS2007b.png';
	}
	return o;
}

function _tmbnRoleHBS() {
	var _pre = 'a';
	if (_tmbn_hbs_role == 'Attendee') {
		_pre = 'an'
	} else if (_tmbn_hbs_role != 'Speaker') {
		_tmbn_hbs_role = 'Supporter'
	}
	return _pre;
}

function _tmbnOutputHBS() {
	who = _tmbnRoleHBS();
	day = _tmbnDaysHBS();
	var s = "";
//	s += '<div id="bn_days">' + day.pre + '<span class="bn_days">' + day.num + '</span>' + day.post + '</div>';
	s += '<div id="bn_banner">';
	s += '<a href="http://trusted.md/conference">';
	s += '<img border="0" src="http://trusted.md/files/widgets/' + day.img + '" alt="Healthcare Blogging Summit"/>';
	s += '</a>';
	s += '</div>';
	s += '<div id="bn_role">I am ' + who + ' <span class="bn_role">' + _tmbn_hbs_role + '</span></div>';
	return s;	
}


function _tmbnOutputHTR() {
	var ver = "http://trusted.md/files/HealthTrain%20-%20the%20Open%20Healthcare%20Manifesto%20-%20v0.1.pdf";
	var s = "";
	s += '<div id="bn_banner">';
	s += '<a href="http://trusted.md/manifesto">';
	s += '<img border="0" src="http://trusted.md/files/widgets/HTR.png" alt="HealthTrain - the Open Healthcare Manifesto"/>';
	s += '</a>';
	s += '</div>';
	s += '<div id="bn_ver">Download <a href="' + ver + '">v0.1</a></div>';
	return s;	
}

function _tmbnDrawWidget() {
	var s = '<style type="text/css">@import url(http://trusted.md/files/widgets/style.css);</style>';
	s += '<div id="tmbn">';
	if (_tmbn_wtype == 'healthtrain') {
		s += _tmbnOutputHTR();
	} else {
		s += _tmbnOutputHBS();		
	}
	s += '<div id="bn_widget">';
	s += '<a href="http://trusted.md/widgets"> >> Install this widget!</a>';
	s += '</div>';
	s += '</div>';
    document.write(s);	
}