extcsvArray = new Array(".csv");
   function csv_file_only(form, file ) {
		if (file.length == 0){
			alert("You must select csv file" );
			return false;
		}
		if (file==null ) {
			alert("You must select csv file" );
			return false;
		}
        allowSubmit = false;
        if (!file) return;
        while (file.indexOf("\\") != -1)
            file = file.slice(file.indexOf("\\") + 1);
            ext = file.slice(file.indexOf(".")).toLowerCase();
            for (var i = 0; i < extcsvArray.length; i++) {
                if (extcsvArray[i] == ext) { allowSubmit = true; break; }
            }
            if (allowSubmit) {
                    return true;
            }
            else {
                    alert("Please only upload files that end in types:  "
                           + (extcsvArray.join("  ")) + "\nPlease select a new "
                           + "file to upload and submit again.");
                    return false
            }
     }

     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 deleteFileInput(container_id) {
         var container = document.getElementById(container_id);
         container.deleteChild();
     }

     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');
         }
    }
    function removeFile(listbox_id) {
         var container = document.getElementById(listbox_id);
             deleteFileInput('listbox_id');
     }
     window.inputId = 'file_input';

function remove(box) {
    for(var i=0; i<box.options.length; i++) {
        if(box.options[i].selected && box.options[i] != "") {
            box.options[i].value = "";
            box.options[i].text = "";
        }
    }
    BumpUp(box);
}

function BumpUp(abox) {
	for(var i = 0; i < abox.options.length; i++) {
		if(abox.options[i].text == "")  {
			for(var j = i; j < abox.options.length - 1; j++)  {
				abox.options[j].value = abox.options[j + 1].value;
				abox.options[j].text = abox.options[j + 1].text;
			}
			var ln = i;
			break;
   		}
	}
	if(ln < abox.options.length)  {
		abox.options.length -= 1;
		BumpUp(abox);
	}
}



