function ResearchFirms() {};

ResearchFirms.prototype.init = function() {
	
	var researchFirmTable = Element.parseSelector('table.researchFirmTable', 'WSOD', 'first');
	
	var researchFirmSortableTable = new TableSort(researchFirmTable, this.resetAltRowStyles, this);
	
	this.addPrintEvent();
}

ResearchFirms.prototype.resetAltRowStyles = function(table) {
	
	var allRows = Element.parseSelector('tbody tr', table);
	var evenRows = Element.parseSelector('tbody tr', table, 'even');
	
	Element.removeClass(allRows, 'altRow');
	Element.addClass(evenRows, 'altRow');
}

ResearchFirms.prototype.addPrintEvent = function() {
	var p = Element.parseSelector('a.printIcon', 'WSOD', 'first');
	
	Events.add({
		element:p,
		type:'click',
		handler:this.wsodPrintPreview,
		context:this
	});
}

ResearchFirms.prototype.wsodPrintPreview = function() {
	
	var url = window.location.href +'?print=true';
	
	window.open(url,'','width=800,height=600, menubar=1, resizable=1, scrollbars=1');
	
	/*
	url = url.substring(0, url.indexOf('/reports/')+8) + '/Release2/research/printPreview.asp';
	
	var w = window.open(url,'sweet','width=800,height=600,resizable=1,scrollbars=1');
	Events.add({
	    element: w,
	    type: "load",
	    handler: function(e, el) {
			var toPrint = Element.get('WSOD');
			var wsod = Element.cloneNode(toPrint, true);			
			Element.addChild(el.document.body, wsod);
	    },
	    context: this
	});
	*/
}

var researchFirms = new ResearchFirms();