/**
 * @requires jQuery
 */

function InfoRequest() {};
		
InfoRequest.prototype =
{
	hideFileContainers : function()
	{			
		var fileContainers = this.getFileContainers();
		var i;
		for (var i  = 0; i < fileContainers.length; i++)
		{
			fileContainers[i].style.display = 'none';
		};		
	},
	
	getFileContainers : function()
	{
		var fileContainers = this.getFilesContainer().getElementsByTagName('DIV');
		var fileContainerClass = 'irFiles';
		var i;
				
		var actualFileContainers = [];
		for (i = 0; i < fileContainers.length; i++)
		{
			if (fileContainers[i].className.indexOf(fileContainerClass) != -1)
			{
				actualFileContainers.push(fileContainers[i]);
			};
		};
		return actualFileContainers;
	},
	
	getFilesContainer : function()
	{
		if (!this._filesContainer)
			this._filesContainer = document.getElementById('irFilesContainer');
			
		return this._filesContainer;
	},
	
	showFolder : function(folderID)
	{
		var folder = document.getElementById(folderID);
		var fileContainers = this.getFileContainers();
		for (var i = 0; i < fileContainers.length; i++)
		{
			fileContainers[i].style.display = 'none';
			this.swapIndicator(fileContainers[i].id, "hide");
		};

		folder.style.display = 'block';
		this.swapIndicator(folder.id, "show");
		
	},
	
	hideFolder : function()
	{
	},
	
	swapIndicator : function(folderID)
	{
		var oIcon = document.getElementById(folderID + "_indicator");		
		var doHide;
		
		if (arguments.length > 1)
		{
			doHide = arguments[1] == "hide";			
		}
		else
		{
			doHide = oIcon.src.indexOf('_show') != -1;
		};
		
		
		if (oIcon)
		{	
			oIcon.src = (doHide) ? oIcon.src.replace('_hide', '_show') : oIcon.src.replace('_show', '_hide');
		};
	},
	
	/**
	 * @method selectAllInDir
	 * @param required {numeric} folderID
	 * @param {boolean} doSelect - Should all items be selected or de-selected? 
	 * 								true will select, false will de-select. Defaults to true.
	 * 
	 * @requires jQuery
	 */
	selectAllInDir : function(folderID)
	{		
		var doSelect = (arguments.length > 1) ? arguments[1] : true;		
		//var inputs = $("#" + folderID + " input[name='infoRequestContent',type='checkbox']");
		var inputs = $("#" + folderID + " input[name='infoRequestContent']:checkbox");
		
		inputs.each(function() {			
			$(this).attr('checked', doSelect);
		});
	}
};