function validateUploadForm()
{
	if ( Trim(fUpload.Name.value) == "" )
	{
		alert("Please enter your \"Name\".");
		document.fUpload.Name.focus();
		return false;
	}
	setCookie("Name", Trim(fUpload.Name.value));

	if ( Trim(fUpload.Phone.value) == "" )
	{
		alert("Please enter your \"Phone number\".");
		document.fUpload.Phone.focus();
		return false;
	}
	setCookie("Phone", Trim(fUpload.Phone.value));

	if ( Trim(fUpload.Email.value) == "" )
	{
		alert("Please enter your \"Email address\".");
		document.fUpload.Email.focus();
		return false;
	}
	setCookie("Email", Trim(fUpload.Email.value));

	if ( Trim(fUpload.Company.value) != "" )
	{
		setCookie("Company", Trim(fUpload.Company.value));
	}

	if ( Trim(fUpload.Specifics.value) == "" )
	{
		alert("Please enter a \"Description\" of your data files.");
		document.fUpload.Specifics.focus();
		return false;
	}

	maxfiles = fUpload.Data_File.length;

	for ( i = 0 ; i < maxfiles && Trim(fUpload.Data_File[i].value) == "" ; i++ )
	{
		; // do nothing...
	}
	if ( i >= maxfiles )
	{
		alert("Please select at least one \"file\" to upload.");
		document.fUpload.Data_File[0].focus();
		return false;
	}

	// check for duplicate file names
	for ( i = maxfiles-1 ; i >= 1 ; i-- )
	{
		for ( n = i-1 ; n >= 0 ; n-- )
		{
			if ( Trim(fUpload.Data_File[i].value) != "" && Trim(fUpload.Data_File[i].value) == Trim(fUpload.Data_File[n].value) )
			{
				alert("Duplicate file found. You can NOT upload the same file twice.\n\nOne occurance of \"" + fUpload.Data_File[i].value + "\" being removed.");
				finput[i].innerHTML = '<input type="file" name="Data_File" size=36 onchange="handleFiles()" onkeyup="handleFiles()">';
			}
		}
	}

	submitButton.innerHTML = "<font color='red'><b>Sending data files, please wait...</b></font>";
	document.body.style.cursor="wait";

	return true;
}

function handleFiles()
{
	maxfiles = document.fUpload.Data_File.length;

	for ( i = maxfiles-1 ; i >= 1 ; i-- )
	{
		var ctxt = "";
		if ( document.getElementById("Data_File" + i) )
		{
			ctxt = Trim(document.getElementById("Data_File" + i).value);
		}
		var ptxt = "";
		if ( document.getElementById("Data_File" + (i-1)) )
		{
			ptxt = Trim(document.getElementById("Data_File" + (i-1)).value);
		}

		if ( ctxt == "" && ptxt != "" )
		{
			document.getElementById("ftext" + i).innerHTML = "File #" + (i+1) + ":";
			document.getElementById("finput" + i).innerHTML = '<input type="file" id="Data_File' + i + '" name="Data_File" size=36 onchange="handleFiles()" onkeyup="handleFiles()">';
		}
		else if ( ctxt == "" && ptxt == "" )
		{
			document.getElementById("ftext" + i).innerHTML = "";
			document.getElementById("finput" + i).innerHTML = '<input type="hidden" name="Data_File" value="">';
		}

		if ( ctxt != "" )
		{
			i = 0;
		}
	}
}

function fillInDefaults()
{
	var Name = Trim(getCookie("Name"));
	var Phone = Trim(getCookie("Phone"));
	var Email = Trim(getCookie("Email"));
	var Company = Trim(getCookie("Company"));

	document.fUpload.Name.value = Name;
	document.fUpload.Phone.value = Phone;
	document.fUpload.Email.value = Email;
	document.fUpload.Company.value = Company;

	if ( Name == "" )
	{
		document.fUpload.Name.focus();
	}
	else if ( Phone == "" )
	{
		document.fUpload.Phone.focus();
	}
	else if ( Email == "" )
	{
		document.fUpload.Email.focus();
	}
	else if ( Company == "" )
	{
		document.fUpload.Company.focus();
	}
	else
	{
		document.fUpload.Specifics.focus();
	}
}

