extArray = new Array(".gif", ".jpg", ".png", ".jpeg");
function CheckFileType() 
{
	var form = document.getElementById('regForm');
	var allowSubmit = false;
	
	for(var j = 0; j < 5; j++)
	{		
		allowSubmit = false;
		fileInput = document.getElementById('image0' + (j + 1));
		file = fileInput.value;
		if (!file) 
		{
			allowSubmit = true;		
		} else {
			while (file.indexOf("\\") != -1)
			{
				file = file.slice(file.indexOf("\\") + 1);
			}	
			ext = file.slice(file.indexOf(".")).toLowerCase();
			for (var i = 0; i < extArray.length; i++) {
				if (extArray[i] == ext) { 
					allowSubmit = true;
					break; 
				}
			}
		}
		if (allowSubmit == false)
		{
			alert("Please only upload files that end in types:  " 
			   + (extArray.join("  ")) + "\nPlease select a new "
			   + "file to upload and submit again.");	
			 return allowSubmit;		
		}
	}
	if (allowSubmit == true)
	{
		//alert(document.getElementById('regForm').name);
		//document.regForm.submit();
		return allowSubmit;		
	}
}
