function checkEmailForm() {
	var valid = true;
	alertMsg = "";
	if($("input[name='name']").attr("value") === "") { alertMsg += "Name required\n"; valid = false; }
	if($("input[name='email']").attr("value") === "") { alertMsg += "Email required\n"; valid = false; }
	if($("input[name='subject']").attr("value") === "") { alertMsg += "Subject required\n"; valid = false; }
	if($("input[name='classification']").attr("value") === "") { alertMsg += "Classification required\n"; valid = false; }
	if($("textarea[name='message']").attr("value") === "") { alertMsg += "Message required\n"; valid = false; }
	if($("input[name='captcha_response']").attr("value") === "") { alertMsg += $("#get_captcha_question").text(); valid = false; }
	
	if( !valid )
		alert(alertMsg);
	return valid;
}

var validExtensions = new Array(".jpg", ".jpeg", ".gif", ".png", ".tif", ".swf", ".pdf");
$(document).ready(function() {
	//ensures degradability
	$("#file_upload2").hide();
	$("#file_upload3").hide();
	$("#nojs").remove();
	$("#loadingProgress").show();

	//Begin ajax upload
	var filePrefix = document.createElement("input");
	filePrefix.setAttribute("value", "");
	filePrefix.setAttribute("id", "file_prefix");
	filePrefix.setAttribute("type", "hidden");
	filePrefix.setAttribute("name", "hiddenFilePrefix");
	
	var isAjax = document.createElement("input");
	isAjax.setAttribute("value", "true");
	isAjax.setAttribute("type", "hidden");
	isAjax.setAttribute("name", "isAjax");
	
	$("#fileUpload").append(filePrefix);
	$("#fileUpload").append(isAjax);

	$("#file_upload1").removeAttr("name");		
	new AjaxUpload('#file_upload1', {
	  // Location of the server-side upload script
	  action: baseURL + '/contact_us/upload.php',
	  // File upload name
	  name: 'userfile',
	  //extra params
	  data: { ajax : 'true' },
	  // Submit file after selection
	  autoSubmit: true,
	  // The type of data that you're expecting back from the server.
	  // Html (text) and xml are detected automatically.
	  // Only useful when you are using json data as a response.
	  // Set to "json" in that case.
	  responseType: false,
	  // Fired after the file is selected
	  // Useful when autoSubmit is disabled
	  // You can return false to cancel upload
	  // @param file basename of uploaded file
	  // @param extension of that file
	  onChange: function(file, extension){},
	  // Fired before the file is uploaded
	  // You can return false to cancel upload
	  // @param file basename of uploaded file
	  // @param extension of that file
	  onSubmit: function(file, extension) {
		var ext = file.slice(file.lastIndexOf(".")).toLowerCase();
		allowUpload = false;
		for (var i = 0; i < validExtensions.length; i++) {
			//check to see if it's the proper extension
			if (validExtensions[i] == ext) allowUpload = true;
		}
		if( allowUpload == false ) {
			alert("You can only upload files of type: " + validExtensions.join("  ").toUpperCase());
			return false;
		}
		var myData = {};
		if(uploadCount == 0) myData = {"ajax": true, "first": true};
		else  {
			myData = {"ajax": true, "prefix": $("#file_prefix").attr("value")};
		}
		this.setData(myData);
		$("#file_upload1").attr("disabled", "disabled");
		$("#loadingProgress").attr("className","fileUploading");
	  },
	  // Fired when file upload is completed
	  // @param file basename of uploaded file
	  // @param response server response
	  onComplete: function(file, response) {
		var uploadError = false;
		var responseText = response.split( "|||" );
		if(responseText[0] == "PREFIX") {
			$("#file_prefix").attr("value", responseText[1].replace(/^\s+|\s+$/g, ''));
		} else if(responseText[0] == "ERROR") {
			alert(responseText[1]);
			uploadError = true;
		}
		if(!uploadError) {
			var li = document.createElement('li'); 
			li.appendChild(document.createTextNode(file)); 
			document.getElementById('file_list').appendChild(li);
			uploadCount++;
		}
		$("#file_upload1").removeAttr("disabled");
			$("#loadingProgress").attr("className","fileUploaded");
	  }
	});
});
