function addFileInput(input_name,container_id)
{
	var container = document.getElementById(container_id);
	var newInput = document.createElement("input");
	newInput.setAttribute('type','file');
	newInput.setAttribute('name',input_name);
	var random = Math.random();
	var random = random * 10;
	newInput.setAttribute('id','file_' + random);
	window.inputId = 'file_' + random;
	container.appendChild(newInput);
}
function hideInput(listbox_id)
{
	var input = document.getElementById(window.inputId);
	if (input.value != "") 
	{
		input.style.display = 'none';
		addFileToList(listbox_id);
		return true;
	}
	else return false;
}
function addFileToList(listbox_id)
{
	var input = document.getElementById(window.inputId);
	var container = document.getElementById(listbox_id);
	var newOption = document.createElement("option");
	var newOptionText = document.createTextNode(input.value);
	newOption.appendChild(newOptionText);
	container.appendChild(newOption);
}
function attachFile(listbox_id, input_name, container_id)
{
	if (hideInput('files'))
		addFileInput('files[]','file_attach');
}

window.inputId = 'file_input';
