function InfoTabListener(infoTabEvent, navigationHolder) {
	this.navigationHolder = navigationHolder;
	this.infoTabEvent = infoTabEvent;
	this.infoTabEvent.openInfoTab.subscribe(this.openInfoTab, this);
	this.infoTabEvent.printInfoTab.subscribe(this.printInfoTab, this);
}

InfoTabListener.prototype.setMainLayout = function(mainLayout) {
	this.mainLayout = mainLayout;
}

/** Open the information tab at the correct anchor. */
InfoTabListener.prototype.openInfoTab = function(type, args, me) {
	me.openInfoTabAnchor(args[0]);
}

/**
 * Print the contents of the information tab. This is done by opening a
 * window with the same location and call print and close on that window.
 */
InfoTabListener.prototype.printInfoTab = function(type, args, me) {
	var loc = document.getElementById('info-frame').src;
	var printWin = open(loc,'','width=500,height=600');
	printWin.print();
/*	printWin.close(); */
}

/** Info button on input toolbar. */
InfoTabListener.prototype.showInfoForCurrentPage = function() {
	this.openInfoTabAnchor(this.navigationHolder.getCurrentPageNr());
}

/** Info button on input toolbar. */
InfoTabListener.prototype.openInfoTabAnchor = function(anchor) {
	if (!this.mainLayout) return;
	this.mainLayout.showPanel('information');
	var loc = document.getElementById('info-frame').src;
	var index = loc.indexOf('#');
	if (index > -1) {
		loc = loc.substring(0, index);
	}
	document.getElementById('info-frame').src = loc + '#' + anchor;
}

