function showReplace(i) {
	to_hide = "submitted"+i;
	to_show = "replace"+i;
	replace_link="replace_link"+i;
	document.getElementById(to_hide).innerHTML = document.getElementById(to_show).innerHTML;
	document.getElementById(to_show).innerHTML = "";
	document.getElementById(replace_link).innerHTML = "";
}

function deleteDoc(course,section) {
	if (course=="resume") {
		msg = "resume/CV";
	}
	else {
		msg = "item associated with this entry";
	}
	var answer = confirm("Are you sure you want to delete the "+msg+"?");
	if (confirm) {
		location.replace("docmanagement.php?task=delete&course="+course+"&section="+section);
	}
	else {
		return false;	
	}
}	

function viewDoc(course,section) {
	location.replace("docmanagement.php?task=view&course="+course+"&section="+section);
}

function submitDoc(form_name,field) {
	if(isEmpty(form_name.doctitle)) {
		alert("You must enter the title of this item as you would like it to appear in your portfolio.");	
		returnval= false;
	}
	else {
		if(isEmpty(form_name[field])) {
			alert("You must press the 'browse' button (or 'choose file' button in Safari) and find the file you wish to place in your portfolio before pressing the 'submit' button.");
			returnval= false;
		}
		else {
			if(form_name.name=='submitNonMajorNew') {
				dropdown="full";
				if(form_name.dept.value=='x') { 			
					dropdown="empty";
				}
				else {
					if (form_name.ind.value=='x') {
						dropdown="empty";
					}
					else {
						if(form_name.section.value=='x') {
							dropdown="empty";
						}
					}
				}
				if(dropdown=="empty") {
					alert("You must completely fill out the course information to add a new item.");
					returnval= false;
				}
				else {
					returnval= true;
				}
			}
			else {
				returnval= true;
			}
		}
	}
	return returnval;
}
