﻿
var clearUploadsFlag = true;
var UploadComponentID  = new Array();
//This function clears the file input fields of
// the r.a.d.upload instance if the clearUploadsFlag flag is set to false
function clearUploads()
{
	if (clearUploadsFlag)
	{		
	    
        for(var n = 0 ;  n< UploadComponentID.length; n++){
	        var theRadUploadInstance = window[(UploadComponentID[n])];
	        if(theRadUploadInstance){
	            var radUploadTable = document.getElementById((UploadComponentID[n]) + "ListContainer");
	            
	            for (var i=0; i<radUploadTable.rows.length; i++)
	            {
		            theRadUploadInstance.ClearFileInputAt(i);
	            }	
	        }
	    }	
	}
}

//This function changes the original form submit function
// in order to clear the file upload input fields:
function changeOriginalSubmit()
{

	var theForm = document.forms[0];
	var originalSubmit = theForm.submit;
	theForm.submit = function()
	{
		clearUploads();
		this.submit = originalSubmit;
		this.submit();
	}
	if (window.attachEvent)
	{
		theForm.attachEvent("onsubmit", clearUploads);
	}
	else if (window.addEventListener)
	{
		theForm.addEventListener("submit", clearUploads, false);
	}
}
