ILR.namespace("cahrsPubs.workingPapers");

ILR.cahrsPubs.workingPapers = {
	
	xhrContainer : "workingPaperDisplay",
	activityIndicator : "/images/animations/activityIndicators/indicator_big_b31b1b.gif",
	yearSelectId : "year",
	
	
	init : function(){

		// Make changes to the form styles for the JavaScript-enabled version
		var els = ["view", "selectedWorkingPapers", "selectYear"];
		YAHOO.util.Dom.addClass(els, "jsVersion");
		
		YAHOO.util.Event.addListener(this.yearSelectId, "change", function() {
			this.getData();
		}, this, true);
		
		// The page must reload displaying the data for the selected year		
		this.getData();
		
	},
	
	handleSuccess : function(o) {

		ILR.animation.fadeOutIn(o.responseText, this.xhrContainer);

	},
	
	getData : function() {
		
		var resource = "/cahrs/customcf/embeddedApps/cahrsPubs/workingPapers/showWorkingPapers.cfm", 
			query = "?year=" + document.getElementById(this.yearSelectId).value,
			callback = { success: this.handleSuccess, scope: this };
			
		document.getElementById("yearTitle").firstChild.nodeValue = document.getElementById(this.yearSelectId).value;
		transaction = YAHOO.util.Connect.asyncRequest("GET", resource + query, callback, null);	
		
		ILR.animation.showActivityIndicator(this.activityIndicator, this.xhrContainer);		
	}
	
};


YAHOO.util.Event.addListener(window, "load", ILR.cahrsPubs.workingPapers.init, ILR.cahrsPubs.workingPapers, true);
