//<![CDATA[
$(document).ready(function () {
	var TemplateB = Template.extend();
	TemplateB.init = function() {
		this.renderStraplines();
		this.renderTitles('#c-main h3, #foot-panel dt');
		ModuleManager.init('#column2-of-2 .module300-glass');
		$('img.thumb').pngfix();
		$('#column2-of-2 .module300-glass .content dt img').pngfix();
	}
	TemplateB.init();
});

/**
 * Manage the collapsing/expanding modules
 **/
var ModuleManager = 
{
	_accessor: null
	,
	init: function (accessor) {
		this._accessor = accessor;
		this.setStates('');
		// scope hack
		var that = this;
		// bind click events
		$(this._accessor + ' .head').each(
			function (index) {
				$(this).css('cursor', 'pointer');
				$(this).bind('click', {scope: that, obj: $(this)}, that.handleClick);
			}
		);
	}
	,
	setStates: function (state)	{
		$(this._accessor).each(
			function () {
				$(this).removeClass('expanded');
				$(this).removeClass('collapsed');
				$(this).addClass(state);
			}
		)
	}
	,
	handleClick: function (event) {
		var o = $(event.data.obj).parent();
		if (o.is('.expanded')) {
			event.data.scope.setStates('');
		} else {
			event.data.scope.setStates('collapsed');
			o.removeClass('collapsed').addClass('expanded');
		}
	}
}
//]]>